Skip to content

fix(codex-proxy): cap app-server WebSocket frames (#1839) - #4056

Closed
dezren39 wants to merge 1 commit into
mainfrom
queue/5047-1839-ws-frame-cap
Closed

dezren39 wants to merge 1 commit into
mainfrom
queue/5047-1839-ws-frame-cap

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

 drainFrames(frame)
- trust unbounded 64-bit lengths and accumulate fragments
+ reject unsafe lengths and frames/messages above 1 MiB
+ clear partial state and close with a size/cap diagnostic

The test Codex stub now returns a deterministic model catalog so app-server tests do not block on model discovery. Regression coverage includes the valid-frame control, oversized header followed by a valid frame, unsafe 64-bit length, and aggregate fragmented-message overflow.

Evidence

  • Before: the targeted oversized-frame test timed out before the fake app-server saw a request; the test stub blocked in codex debug models.
  • After: node --test bin/codex-proxy.test.mjs — 27/27 passed. node --check for both files and git diff --check pass.

Merge Danger

Door: Two-way; the cap can be reverted.

Blast Radius: Narrow; limited to app-server WebSocket frame/message parsing and its tests.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 23:02
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 81819722-7fb0-47d3-bb44-e625b0479fb6
Commits

Reviewing files that changed from the base of the PR and between df3f836 and 2618879.

Files selected for processing: 2
  • bin/codex-proxy.mjs
  • bin/codex-proxy.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T23:05:56.838755Z 2618879 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2618879102

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/codex-proxy.mjs
Comment on lines +640 to +642
if (this.fragmentBytes + len > MAX_APP_SERVER_FRAME_BYTES) {
this.rejectFrameLength(this.fragmentBytes + len, 'message');
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude control frames from the aggregate message-size check

When a ping arrives between fragments of a message near the cap, this check adds the ping payload to the accumulated message size before the ping handler can run. For example, a 1,048,575-byte first fragment, an interleaved 2-byte ping, and a 1-byte continuation form a valid message exactly at the limit, but the connection is destroyed on the ping with a claimed message length of 1,048,577. This unnecessarily fails active turns and triggers exec fallback, or a streaming error if output was already emitted. Apply the aggregate check only to data/continuation frames, excluding control frames.

Useful? React with 👍 / 👎.

Comment thread bin/codex-proxy.mjs
Comment on lines +606 to +607
this.handleClose(err);
try { this.sock && this.sock.destroy(); } catch {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Settle initialization safely before rejecting a buffered frame

If an initialize RPC response and an oversized frame header arrive in the same socket data event, parsing the response queues the initialization success callback, but this call marks the client dead before that callback runs. The callback in connect() then calls this.send({ method: 'initialized' }), which throws app-server not connected; its returned promise has no rejection handler, so Node's default unhandled-rejection behavior terminates the proxy instead of falling back to exec. Reproducing the same input against the parent commit initializes successfully, whereas this commit produces the unhandled rejection. Ensure frame rejection also safely settles initialization and prevents the queued success callback from sending on a dead client.

Useful? React with 👍 / 👎.

@developing-today

Copy link
Copy Markdown
Contributor

🤖 Agent note · closed as superseded (salvage check included)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant