Skip to content

session: stop reusing pruned session ids so a stalled caller cannot reach a new session #413

Closed

Description

@ElbertePlinio

Found in the council review of the fix for #317.

After #317, session prune removes a destroyed session's .<id>.input-closed and .<id>.takeover-identity markers one day after its teardown. Until then they reserve the id. After that, createSession can draw the same random 32-bit id again.

A caller that read the old session record and then stalled for more than a day (for example a stopped process) re-checks the session by id when it resumes. If a new session drew the same id in the meantime, the stale call can pass the checks against the new record. Desktop input also needs the new session to run on the same display number, because the owned display check re-reads the record. Two concurrent prunes have a similar gap: one can unlink a marker that a reused id created after the other checked it.

Each case needs a new session to draw one specific freed id, about 2^-32 per creation, so this is hardening, not an active bug.

Plan change

The generation binding below was dropped after council review. Every check-then-mutate path (update, destroy, stop input) and every first read outside a caller scope still raced a reuse, so it narrowed the window without closing it. The fix removes reuse instead: new ids carry 8 random bytes, so a new session draws one specific freed id with a chance of 2^-64 per creation.

  • New session ids carry 64 random bits (16 hex characters)
  • Sessions with 8-hex ids from before the change still read, update and destroy
  • Test the id length for every session type and an old 8-hex record
  • Keep the native viewer host reachable when the longer id pushes host.sock past 107 bytes (also viewer: native host is unreachable when the host.sock path is longer than 107 bytes #376)
  • Bind input permits and leases to a session generation (dropped, see above)
  • Refuse a permit when the current record's generation differs (dropped, see above)
  • Test a stale caller against a reused id (dropped; reuse is removed instead)

Activity

  1. changed the title [-]session: bind late callers to a session generation so a reused id refuses stale input[/-] [+]session: stop reusing pruned session ids so a stalled caller cannot reach a new session[/+] on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions