RUTC50 – Continuous, unbounded memory growth caused by /tmp/session-ips never being pruned, eventually leading to full device hang

Device information

  • Model: RUTC50

  • Firmware: RUTX_R_00.07.23.7 (RutOS)

  • Total RAM: 496,304 KB

Team,

After a certain uptime (originally ~20–24 hours, see below), the device becomes progressively slower to respond via WebUI, and eventually becomes completely unresponsive — both the WebUI and SSH (dropbear) stop responding — requiring a hard power cycle (AC off/on) to recover. A graceful reboot via WebUI/CLI is sometimes still possible shortly before the hang, but not reliably.

Through several days of monitoring (via SSH, free, /proc/[pid]/status, and the router’s own troubleshoot/diagnostic export), we traced this to continuous, unbounded growth of the /usr/sbin/session process (RSS memory), which we were able to correlate directly with the file /tmp/session-ips growing without limit.

Root cause identified

/tmp/session-ips appears to log one line per authenticated session (session hash + source IP), for both WebUI logins and REST API (/api/login) authentications. Critically:

  • Every line in this file is unique — no entries are ever removed, regardless of whether the corresponding session has since logged out, or whether the associated API token (which we confirmed expires after 5 minutes) has expired long ago.

  • This file lives in /tmp (tmpfs), so it resets on reboot — but grows continuously and indefinitely for the entire uptime otherwise.

  • The /usr/sbin/session process’s RSS memory grows in close correlation with this file’s line count.

Diagnostic timeline / data

We initially suspected our own automation (a Python script polling the REST API every few minutes, plus Home Assistant’s native RUTX/RUTC integration, plus WebUI logins) as the primary cause, since all of these repeatedly authenticate against the device. We tested this hypothesis in stages:

Phase Approx. growth rate (used memory) Configuration
Original (unmodified) ~150–390+ KB/min, accelerating over time Custom script logging in fresh on every poll (no token reuse) + native HA integration polling + occasional WebUI logins
After adding client-side token caching to our script (reusing the API token until shortly before its 5-minute expiry, instead of logging in on every poll) ~17–55 KB/min Native integration still active
After also disabling the native polling integration ~26 KB/min, very stable/linear Only our own script remains, authenticating no more often than once per 5-minute token lifetime

At the final stage, /tmp/session-ips grew at almost exactly one new line every ~5 minutes — i.e., precisely matching the API token’s expiry interval, with all traffic originating from a single, well-behaved client that only re-authenticates when its cached token has actually expired.

This is the key finding we’d like to highlight: growth did not stop even when the client-side behavior was reduced to the theoretical minimum (one authentication per token lifetime, with no overlapping/duplicate logins). This points to a lack of session cleanup/expiry logic on the device side, rather than a client misbehavior issue.

Full memory exhaustion event (for reference)

Before the above mitigations were in place, we captured the full progression to a hang, via repeated free snapshots:

Time Available memory Notes
T+0h (reboot) 329,688 KB (66%) Baseline after reboot
T+~20h ~46,000–61,000 KB (~10–12%) WebUI login noticeably slower
T+~22h 15,576 KB (3.1%) WebUI login very slow
T+~23h 700 KB (0.14%) Device became completely unresponsive — WebUI and SSH both stopped responding. Required hard power cycle to recover.

Questions for Teltonika support

  1. Is this a known issue with the session service / /tmp/session-ips not expiring or pruning old entries?

  2. Is there a documented /api/logout endpoint (or equivalent) that properly invalidates a session server-side after use? We were unable to find one in the public API documentation.

  3. Is there a configurable session/idle timeout or cleanup mechanism (via UCI or otherwise) that we could enable to prevent this file/process from growing indefinitely?

  4. Is a fix planned in an upcoming firmware release?

Workaround currently in place

As a mitigation, we’ve configured a daily scheduled reboot via the built-in Reboot Scheduler, and reduced our own polling to the minimum necessary frequency. This keeps the device well within safe memory bounds, but we would prefer a proper fix rather than relying on a workaround.

Happy to provide the full troubleshoot export, SSH session logs, or any further diagnostic data if helpful.

Peter

Hello,

Thank you for reaching out, and apologies for the delay in getting back to you.

Before proceeding with a more in-depth investigation, I would like to address as many of your questions as possible based on the information currently available.

  1. At this time, we are not aware of any similar issues affecting our devices. To our knowledge, this file should be automatically pruned together with the corresponding sessions. By default, the sessions are removed every 1800 or 300 seconds, depending on the session type and whether they are renewed. Further investigation is required to determine why this file is not being pruned as expected in this specific case.
  2. The /api/logout endpoint is currently only available as a user-side initiated call, which invalidates the user’s own session upon request. The closest server-side equivalent is the /api/access_control/sessions/actions/terminate endpoint, which terminates a session based on its internal session ID. The session ID can be obtained using the /api/access_control/sessions/status endpoint. More information is available here:
    Teltonika Networks Web API

Regarding questions 3 and 4, further investigation is required. For troubleshooting purposes, we will require some additional sensitive information from your end, such as the troubleshoot file, SSH session logs, and the session-ips file as proposed. These files may contain passwords, public IP addresses, serial numbers, and other confidential information. To avoid exposing this information, we will send you a form to fill out to the email address associated with your forum account. In the Ticket ID field of the form, please enter the ID of this thread: 20187.

Please let us know once you have filled out the form.

Thank you. Best regards,

Rokas V.

Rokas, I have filled out the form. Thank you.