Skip to content

id(web/tags_ws): /ws/tags WebSocket has no message-size cap — a client can force 64 MiB buffered-and-discarded messages on a socket that expects no inbound payload at all #2116

Closed

Description

@dezren39

Problem

The /ws/tags WebSocket upgrade in pkgs/id sets no message-size cap, unlike the repo's other WebSocket:

  • pkgs/id/src/web/tags_ws.rs:205-208 — ws_tags_handler calls plain ws.on_upgrade(...) with no max_message_size(...).
  • pkgs/id/src/web/world_ws.rs:279 — the world WebSocket pins ws.max_message_size(MAX_FRAME_BYTES) (1 MiB) before upgrade.
  • pkgs/id/src/frames.rs:14-20 — MAX_FRAME_BYTES is documented as the shared bound: "the WebSocket has max_message_size(MAX_FRAME_BYTES)".

With no pin, the framework default applies: tungstenite 0.29's WebSocketConfig::default() is max_message_size: Some(64 << 20) = 64 MiB (verified in the vendored crate source, tungstenite-0.29.0/src/protocol/mod.rs:101 — the same default #1965 established for the collab socket).

Why it matters

/ws/tags expects no inbound messages at all — its own module doc says so (tags_ws.rs:14, and the handler doc at :200-203: "No inbound messages are processed (ping/pong only for keepalive)"). But handle_tags_socket (tags_ws.rs:215-228) spawns a drain task that receiver.next().awaits whole messages just to ignore everything except Close. So every connected client can force the server to buffer a full 64 MiB message per frame batch — 64× the repo's own 1 MiB bound — for data that is definitionally discarded. There is no per-connection or aggregate bound on top of that, so N idle clients × one in-flight 64 MiB message each is pure unbounded-by-design memory pressure on id serve, on a socket whose legitimate inbound traffic is zero bytes of payload.

This is distinct from #1965 (collab): that socket processes inbound steps and retains them; this one retains nothing and needs no inbound payload at all — the fix surface and the acceptance test are different (here the drain simply must never see an oversized message).

Evidence (verified this run, main 42796be)

  • Read tags_ws.rs:195-260 directly: no max_message_size anywhere in the file (grep -n "MAX_FRAME_BYTES\|max_message" pkgs/id/src/web/tags_ws.rs returns nothing); the file also has no test module.
  • Contrast read at world_ws.rs:279 (cap pinned) and frames.rs:14-20 (1 MiB constant + the documented WebSocket convention).
  • Framework default verified in a second, independent source: vendored tungstenite-0.29.0/src/protocol/mod.rs:101 — max_message_size: Some(64 << 20).
  • Route registered at pkgs/id/src/web/routes.rs:303 (/ws/tags).
  • Dedup: gh issue list --state all searches for tags_ws, "ws/tags websocket size" returned no existing issue for this socket; id(web/collab): collab WebSocket has no message-size or step-count cap — a single frame can be 64 MiB and hundreds of thousands of steps, all retained and replayed to every joiner #1965 covers only the collab WebSocket (/ws/collab, collab.rs:627-632) — cross-linked, not duplicated.

Acceptance criteria

  • The /ws/tags upgrade pins a message-size cap consistent with the repo convention (triage pins the exact value — MAX_FRAME_BYTES 1 MiB is the in-repo precedent at world_ws.rs:279; a smaller cap is defensible since no inbound payload is legitimate).
  • A client that sends a message over the cap has its connection closed/refused by the framework instead of the server buffering the whole message in the drain task.
  • Regression test: an oversized inbound message to /ws/tags does not get delivered to the drain loop (connection terminated), while ping/close handling and the outbound tag-event stream keep working.
  • Existing pkgs/id web tests still pass; the outbound /ws/tags event stream is unchanged for well-behaved clients.

Activity

  1. developing-today commented on Oct 29, 2026

    @developing-today
    Contributor
  2. added
    kind/bug
    priority/low
    queue/queued
    source/creator
    task/triage
    status/needs-triage
    app/id
    effort/xs
    on Oct 29, 2026
  3. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (lane B, new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b run 2026-10-29T04:56Z
    • Found via: filed this run
    • Task: Filed after verifying on main 42796be that pkgs/id/src/web/tags_ws.rs ws_tags_handler (:205-208) upgrades /ws/tags with no max_message_size (framework default 64 MiB, tungstenite-0.29 protocol/mod.rs:101), while world_ws.rs:279 pins MAX_FRAME_BYTES (1 MiB) per the frames.rs:14-20 convention; the socket expects no inbound payload and its drain task buffers whole messages only to discard them; enqueued a triage packet.
    • Expectation: effort/xs — triage pins the cap value (MAX_FRAME_BYTES precedent vs smaller, since no inbound payload is legitimate), then routes a small_fix packet. Distinct from id(web/collab): collab WebSocket has no message-size or step-count cap — a single frame can be 64 MiB and hundreds of thousands of steps, all retained and replayed to every joiner #1965 (collab socket, which processes/retains inbound steps).
    • Links: packet queue-pilot/packet-2116-triage.json (repo-health-code-pilot)
  4. added
    work/assigned
    queue/claimed
    and removed
    status/needs-triage
    queue/queued
    on Nov 1, 2026
  5. 16 remaining items

  6. removed
    queue/claimed
    work/assigned
    on Nov 1, 2026
  7. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  8. added
    work/assigned
    queue/claimed
    status/in-progress
    on Nov 3, 2026
  9. added
    queue/queued
    status/needs-triage
    and removed
    status/in-progress
    queue/claimed
    work/assigned
    on Nov 3, 2026
  10. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: triaged (coverage pass)
    Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 30 (priority/low). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
    Found via: coverage pass 2026-11-03

  11. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  12. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    Triage findings — already fixed on main (2026-11-03, task 7838)

    Re-triaged at current main (coverage task 7838). The fix scoped by the 2026-11-01 triage (task 3100) has landed:

    • PR fix(id): cap inbound /ws/tags messages #3371 ("fix(id): cap inbound /ws/tags messages", from follow-up task 5099) is MERGED — merged 2026-11-02T16:00:22Z, merge commit c974a27e3420835cccf470dd92c3f8e270f023b0, single file pkgs/id/src/web/tags_ws.rs.
    • Verified independently on current main (not just the PR record): pkgs/id/src/web/tags_ws.rs:209 now reads ws.max_message_size(MAX_FRAME_BYTES).on_upgrade(...), with use crate::frames::MAX_FRAME_BYTES; at :40 — the shared 1 MiB bound, exactly the value the earlier triage pinned.
    • Regression coverage is on main in the same file: websocket_caps_inbound_messages_and_keeps_tag_events_working verifies ping→pong keepalive, the outbound tag-event stream (POST /api/tags → set event delivered), and that a MAX_FRAME_BYTES + 1 inbound text message terminates the connection instead of reaching the drain loop.

    All acceptance criteria are met, so this issue is being closed as completed. No follow-up fix task is needed; the earlier handoff expectation on PR #3371 ("review and merge after CI/test verification") is satisfied by the merge.

    🤖 Agent note · done

    • Agent: repo-worker-code (lane H, code-h)
    • Session / ID: cron repo-queue-worker-shift-h run 2026-11-03T13:28Z · queue task 7838
    • Found via: repo-health-code-pilot coverage triage
    • Expectation: none — closed with evidence; reopen if the cap regresses.
    • Links: fix(id): cap inbound /ws/tags messages #3371
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/ideffort/xskind/bugpriority/lowqueue/queuedsource/creatorstatus/needs-triagetask/triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions