Repository navigation
Description
Problem
The collaborative-editing WebSocket (/ws/collab/{doc_id}) applies no message-size cap and no per-message step-count cap, even though the repo's own framing standard is 1 MiB:
pkgs/id/src/frames.rs:16-19—MAX_FRAME_BYTESis 1 MiB, documented as: "Both transports enforce it: the Iroh frame reader refuses longer frames and the WebSocket hasmax_message_size(MAX_FRAME_BYTES)."pkgs/id/src/web/world_ws.rs:279— the world WebSocket does exactly that:ws.max_message_size(MAX_FRAME_BYTES).pkgs/id/src/web/collab.rs:626-632—ws_collab_handlercalls plainws.on_upgrade(...)with nomax_message_size/max_frame_size, so the upgrade inherits the framework default. Verified in the vendored tungstenite 0.29.0 source (the version axum 0.8.9 uses here):WebSocketConfig::default()ismax_message_size: Some(64 << 20),max_frame_size: Some(16 << 20)— 64× the repo's frame standard.
Nothing downstream compensates:
CollabMessage::decode(collab.rs:513, Steps attempt at :536-545) deserializes aVec<serde_json::Value>of steps with no length or byte check.- The Steps handler (
collab.rs:1016-1029) pushes every step in the message into the document's permanent step history (doc_steps.push(...)at :1019), clones the whole vector for the broadcastUpdate, and advances the version bysteps.len(). - That history is retained for the life of the document and re-serialized in full as the catch-up
Updateto every later joiner (collab.rs:784-810), so one oversized message is paid for in server memory and in every subsequent join's bandwidth, not just once.
Any client that can open a collab socket (the first-message auth is optional — anonymous clients proceed, collab.rs auth-timeout path) can therefore send a single ~64 MiB message, or one message carrying hundreds of thousands of steps, and have all of it decoded, cloned several times, stored, broadcast, and replayed to future joiners. The sibling world socket and every length-prefixed transport in the crate refuse anything over 1 MiB unread.
Related but distinct: #1833 covers the collab cursor name path (no length/control filtering); this issue is the message/step-count size bound on the same socket. #1839 is the same bug class in codex-proxy's hand-rolled WS parser.
Evidence (verified this run, main 6a284efd)
Laptop probe ~/git/fleet/probe-2026-10-28-laneA-collabws/ — the Steps decode attempt copied verbatim from collab.rs (file sha256 55e042705c0389140eb2b50aa617cd4cac388806b44e116ecba69af0a7d9f6e0 = main), plus the handler's history-push loop:
CONTROL ok: 33 bytes, version=0 steps=1 client=7
OVERSIZE_FRAME_ACCEPTED: 4194337 bytes (4x the 1 MiB frame cap) decoded to 1 step(s); no size check in decode
MANY_STEPS_ACCEPTED: 200000 steps in one 6937097-byte message; simulated handler history now holds 200000 steps, version would jump by 200000
Framework default verified in the laptop cargo registry: tungstenite-0.29.0/src/protocol/mod.rs:101-102 — max_message_size: Some(64 << 20), max_frame_size: Some(16 << 20).
Dedup: gh issue list --search (all states) for "collab websocket message size", "max_message_size", and "collab steps history unbounded" returned only #1833 (cursor names — different) and closed audit #1075. No existing issue covers a collab message-size or step-count bound.
Why it matters
A long-lived id serve process can be made to allocate and retain hundreds of MiB (decode + history clone + broadcast clone + per-joiner catch-up clones) from a single unauthenticated socket message, and the retained history inflates every later join for that document. The crate already decided this bound: 1 MiB, enforced on the Iroh reader, the SSH/byte-stream readers, and the world WebSocket. The collab socket is the one WebSocket that missed it.
Acceptance criteria
-
ws_collab_handlersetsmax_message_size(andmax_frame_sizeif triage judges it needed) to the repo standardMAX_FRAME_BYTES, matchingworld_ws.rs:279; an over-limit message closes/refuses the connection without being decoded into the step history. - A per-message step-count bound (a named constant) is enforced on the Steps path — in
decodeor in the handler before any step is pushed — so a within-size but step-stuffed message cannot grow the history or jump the version by an unbounded count in one frame. (Triage pins the value; it should comfortably cover legitimate ProseMirror step batches.) - Regression tests: an over-
MAX_FRAME_BYTEScollab message is refused; a Steps message past the step-count bound is refused with the document version and history unchanged; ordinary small Steps messages still apply, ack, and broadcast. - The
frames.rsdoc claim ("the WebSocket hasmax_message_size(MAX_FRAME_BYTES)") is true for every WebSocket the crate serves after the fix — triage also checkstags_ws.rs(its inbound side only drains, so exposure is smaller, but the same one-line bound applies).
🤖 Filed by the new-issue-creator (lane A) after a verified probe; see the agent note below for the queue packet.
Activity
developing-today commentedon Oct 28, 2026
CODE-890
dezren39 commentedon Oct 28, 2026
🤖 Agent note · filed
max_message_size(world_ws.rs:279 setsMAX_FRAME_BYTES= 1 MiB; the framework default here is 64 MiB),CollabMessage::decodehas no byte/step-count check, and the Steps handler retains every step in the document history replayed to all later joiners. Laptop probe with the verbatim Steps decode (main 6a284ef): a 4 MiB frame and a 200,000-step single message both accepted.queue-packets/packet-1965.json(repo-health-code-pilot); probe~/git/fleet/probe-2026-10-28-laneA-collabws/(laptop); related id(web/collab): a client's cursor name is broadcast verbatim — no length cap and no control-character filtering on the frame path, and identity sanitize_name does not remove control characters either #1833 (cursor names, distinct), codex-proxy: app-server WebSocket frame parser has no size cap — a header claiming a huge payload wedges the connection forever and swallows every later frame #1839 (same class, codex-proxy)dezren39 commentedon Oct 31, 2026
🤖 Agent note · state: handed off
Remainder from #2969 not covered by this issue's AC
This issue pins the per-message bounds (message size + per-message step count). #2969 verified a second, cumulative growth path on current main
ed59bc6dthat those bounds do not close:Document.steps(pkgs/id/src/web/collab.rs:217) is only ever appended to (sole push at :1023) — there is no total-history cap and no compaction. A client sending perfectly legal, within-limit Steps messages indefinitely still grows the retained history without bound, and every joiner is sent a clone of all of it (catch-up at :793-796).notify_new_version(:352-375) only broadcasts and updates the stored hash, and the Init base remains the initial content at version 0 (:765). A document is removed only after its last client has been gone for 1 hour (DOCUMENT_CLEANUP, :185), so one connected or regularly reconnecting client keeps the full history alive indefinitely.Suggested addition to this issue's fix scope (triage's call): a named bound on retained history (count and/or bytes) and/or periodic compaction of applied steps into the base document, with a test that a fresh joiner still reconstructs the same document after the bound/compaction is hit. #2799 (Init frame version) interacts with any compaction shape.
77 remaining items
dezren39 commentedon Nov 2, 2026
🤖 Agent note · parked
dezren39 commentedon Nov 2, 2026
agent-note:v1 — parked — Lane D
dezren39 commentedon Nov 2, 2026
agent-note:v1 — parked — Lane D
dezren39 commentedon Nov 2, 2026
Lane B picked up task 5056. OWNERSHIP MISREAD CORRECTED: PR #4051 is on branch queue/5056-1965-collab-ws-size — this task's own queue branch (author dezren39 is the fleet account); not a Drew-owned personal branch, and neither PR #4051 nor #1965 carries held/user/owned/do-not-merge/do-not-auto-edit labels. Resuming from awaiting_ci: verifying diff, CI, and Codex on head cea81a3.
fix(id): bound collab WebSocket input (#1965) (#4051)
dezren39 commentedon Nov 2, 2026
Done: PR #4051 merged as 5ae6ee7. Ownership misread corrected this shift (own queue/5056-* branch, not Drew-owned). Codex review on head cea81a3 completed clean; both earlier P2 findings were fixed in-branch and dispositioned on their threads. Targeted tests verified on the laptop: bun test collab.test.ts stepBatch block 6/6 pass; the 3 failing initCollab (#1463) tests fail identically on clean main under bun (vitest-only vi.stubGlobal APIs — pre-existing runner mismatch, not this change). PR checks were queued-only for ~3h (fleet CI congestion pattern); merged under the standing merge authority. Task 5056 completed fixed_merged.