Skip to content

[WRONG BRANCH] fix(web-search): bound withheld tool events - #481

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-heldcalls-vulnerability
Draft

[WRONG BRANCH] fix(web-search): bound withheld tool events#481
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-heldcalls-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent unbounded per-turn buffering of withheld client-executed tool SSE events that can be abused by a malicious provider to exhaust process memory and crash the proxy.
  • Fail closed or bound the bridge when a leg contains excessive matching tool-call events so the bridge no longer bypasses downstream backpressure.

Description

  • Add aggregate per-leg ceilings MAX_HELD_CALL_EVENTS (1,000 events) and MAX_HELD_CALL_CHARS (8 MiB) and track held payload bytes with heldCallChars to bound retained client-tool events.
  • Introduce holdCall(...) helper that appends to heldCalls and throws a clear error when either event count or byte budget is exceeded.
  • Convert flushHeldCalls() into a generator that yields serialized frames incrementally and clears the held state in a finally block to avoid materializing a second full in-memory array.
  • Adjust emit to accept any iterable of frames and route client-executed call accumulation through the bounded helper in consume(...).
  • Add a focused regression test that simulates a hostile upstream emitting excessive matching function_call/delta frames and asserts the bridge fails with the expected error without releasing the withheld call.

Testing

  • Ran the focused unit tests for the bridge: node_modules/.bin/bun test tests/web-search/web-search-passthrough-bridge.test.ts, which passed (22 tests passed).
  • Ran type checking with bun run typecheck, which succeeded, and bun run privacy:scan, which passed.
  • Verified repository hygiene with git diff --check; no issues found.
  • Full bun run test encountered unrelated environment/worker panics in the container (parallel test worker panic and serial retry hit container-specific process-group/zombie behavior); these failures are infrastructure-specific and not caused by this change. The focused bridge tests used the repo-local Bun and passed.

Codex Task

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 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-09-11T12:01:22.021590Z 1efcfad 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.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 7feb103e-e317-4d6c-99f4-f1b8aa991057


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

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions github-actions Bot changed the title fix(web-search): bound withheld tool events [WRONG BRANCH] fix(web-search): bound withheld tool events Sep 11, 2026
@github-actions
github-actions Bot marked this pull request as draft September 11, 2026 12:00

@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: 1efcfadfcb

ℹ️ 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 on lines +366 to +368
if (this.heldCalls.length >= MAX_HELD_CALL_EVENTS
|| dataChars > MAX_HELD_CALL_CHARS - this.heldCallChars) {
throw new Error("upstream client tool events exceeded the web-search bridge buffer bound");

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 Close opened search cells when the hold limit trips

When a leg emits a web_search item before another client tool exceeds this new limit, holdCall throws into the generic bridgeStreamBlocks read-error catch, which emits only response.failed. The already streamed web_search_call therefore remains in_progress, unlike the normal mixed-tool failure path that calls searchEndFrames, leaving Codex with a stuck search spinner. Close every search opened by the current leg before emitting this limit failure, or route the exception through the existing leg-failure cleanup.

AGENTS.md reference: src/AGENTS.md:L17-L19

Useful? React with 👍 / 👎.

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

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant