Skip to content

relay: close a relay session that does not authenticate within a deadline #2500

Closed

Description

@devswha

server/relay/session.ts keeps a relay session open in its hello/auth state for as long as the peer wants: there is no deadline for the device to send AUTH or PAIR. The relay keeps the client socket alive with keepalives.

Why it matters: with the relay fixes for #2499, a client holds one of a server's 8 relay slots once the PC's data socket has sent it a frame. Anyone who has a PC's offer, including a revoked device, knows the server's public key. That is enough to complete Noise NK and get the PC's first frame. The relay then counts that peer as answered, because it cannot see device authentication through the E2EE. Eight such peers hold all 8 slots, and real phones get 1013. This is denial of service only: E2EE and device auth still hold.

Repro (outline): connect 8 clients to the relay for a PC. On each one, complete the Noise handshake with the offer's server_public_key, then send nothing more except relay keepalives ({"type":"ping"} every <120 s). A 9th, real phone is refused 1013.

Suggested fix: in RelaySession, close the session (and so the data socket, which the relay turns into 1012 for the client and a freed slot) when no valid AUTH/PAIR arrives within a short deadline after the handshake, e.g. 10-15 s. Add a contract test that drives a session to auth and advances the clock.

Found by the Codex Terra review of the #2499 fixes. It is outside that PR's diff (the session landed in #2476).

Activity

  1. devswha commented on Oct 31, 2026

    @devswha
    OwnerAuthor

    Two related points from the omo code review of the #2499 fixes, both outside that PR's diff:

    1. Another fix shape: instead of (or as well as) an auth deadline on the PC, the relay could count a client toward the 8 slots only after the PC sends an explicit admit message for its connection_id on its proven control socket, once device auth has passed. This needs a PC relay client that sends it. None ships yet, so whichever shape is chosen should land before the PC's relay link does.
    2. The PC's own rate limit: every client arrival makes the PC dial a data socket, and on Cloudflare that dial counts against the PC address's 30/min per-address limit. Clients from a few other addresses can therefore get the PC's own sockets, including a control reconnect, refused with 429. One option: key the per-address limiter for role=server sockets by address and server_id, or let proven PC sockets through on the global limit only.
  2. devswha commented on Oct 31, 2026

    @devswha
    OwnerAuthor

    Closing: the merge pass's delta review of #2499 found this is only a window of at most 15 seconds (the handshake deadline), a LOW, so it's tracked in #2499's review comment instead of a separate issue. We'll reopen if it shows up in real use.

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