Skip to content

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

Closed

Description

@dezren39

codex-proxy: the app-server WebSocket frame parser has no size cap — one header claiming a huge payload wedges the connection forever and swallows every later frame

Evidence (verified this run, main 3675a470)

bin/codex-proxy.mjs, AppServerClient.drainFrames() (lines 486–525):

  • The 64-bit length form is trusted verbatim: len = Number(this.buffer.readBigUInt64BE(off)) (:500). There is no maximum frame size anywhere in the parser.
  • The only guard is if (this.buffer.length < off + len) return; (:506) — for an absurd claimed length the parser simply waits for payload bytes that will never arrive. It never errors, never closes, and never resynchronizes.
  • Everything the peer sends afterwards is accumulated into this.buffer (and, for fragmented messages, into this.fragments, also uncapped, :515) as if it were that frame's payload — including perfectly valid frames.
  • Contrast in the same repo: the Rust frame reader refuses anything over MAX_FRAME_BYTES = 1 MiB (pkgs/id/src/frames.rs), and bin/proxy-relay.mjs:105 caps the tunnel CONNECT response head at 16 KiB. This parser is the outlier.

Probe (laptop, verbatim parser)

Probe dir: ~/git/fleet/probe-2026-10-28-laneB-codexws/ — codex-proxy.mjs copied byte-identical to main (sha256 494e89732baa3fac58b535f07313bfe31560ebbe41bb4a01a23068918d44ca3a), drainFrames/wsEncodeFrame extracted verbatim from that copy and driven with crafted unmasked server-style frames (node probe.mjs):

  • CONTROL: a small text frame {"id":1,"result":{}} → delivered to onMessage, buffer empty.
  • OVERSIZED: a header claiming 2^40 payload bytes followed by a valid {"id":2,"result":{}} frame → no message, no close, no error; 32 bytes buffered and the valid frame swallowed as payload. The connection is permanently desynchronized.
  • INCOMPLETE: a 65,535-byte claim with 100 bytes present → silently waits, same wedge in miniature.

Why it matters

The app-server is a separate process; a buggy or desynchronized frame stream (a partial write, a version-skewed peer, one corrupt length byte) turns into a silent, permanent proxy outage rather than a reconnect. handleClose never fires, the client still reports ready, pending RPCs reject only on their individual 30 s timeouts, and every subsequent RPC on the wedged connection times out the same way until the proxy process is restarted by hand. A bounded parser would fail the connection at the bad header and let the existing close/reconnect path run.

Acceptance criteria

  • drainFrames refuses a frame whose claimed payload length exceeds a named maximum (choose one in line with the repo's other caps, e.g. the 1 MiB of pkgs/id/src/frames.rs, or a documented codex-specific value): the connection is closed via the existing handleClose/destroy path with an error naming the claimed length and the cap, instead of waiting for the payload.
  • The accumulated fragmented message size is bounded by the same (or a named) cap, so a peer cannot grow this.fragments without bound using non-final frames.
  • A claimed length that does not fit exactly in a safe integer is refused, not rounded by Number(BigUInt).
  • Regression tests in bin/codex-proxy.test.mjs: a valid small frame still parses (control); an oversized claimed length closes/errors immediately and does not consume a following valid frame as payload; an over-cap fragmented sequence is refused.
  • Normal-size app-server traffic is unchanged: the existing codex-proxy tests pass.

Activity

  1. developing-today commented on Oct 28, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/codex-proxybin/codex-proxy.mjs fleet proxy
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 28, 2026
  3. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-b
    • Session / ID: new-issue-creator-code-b run, 2026-10-28 16:39 CDT
    • Found via: filed this run
    • Task: Filed codex-proxy WebSocket frame-parser size-cap bug, verified with a laptop probe of the verbatim drainFrames from main 3675a47 (source sha256 494e8973…).
    • Expectation: effort/xs–s triage; done = parser caps claimed/fragmented lengths and wedged-connection regression tests exist per the issue's acceptance criteria.
    • Links: probe ~/git/fleet/probe-2026-10-28-laneB-codexws/ (laptop); body hidden_files/issue-code-codexws-body.md
  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 1, 2026
  5. 31 remaining items

  6. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  7. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 3, 2026
  8. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · done (triage verdict: SUPERSEDED — subject code decommissioned and deleted)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/codex-proxybin/codex-proxy.mjs fleet proxyeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions