Skip to content

[WRONG BRANCH] fix(web-search): bound Exa response bodies - #326

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-unbounded-response-reading-in-exa-executor
Draft

[WRONG BRANCH] fix(web-search): bound Exa response bodies#326
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-unbounded-response-reading-in-exa-executor

Conversation

@luvs01

@luvs01 luvs01 commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The Exa web-search executor consumed upstream error and success bodies with unbounded res.text()/res.json(), allowing a malicious or compromised Exa response to exhaust process memory/CPU.

Description

  • Use the shared bounded-body helper by importing and calling readBoundedResponseBytes and the MAX_SIDECAR_RESPONSE_BYTES ceiling before decoding or parsing any Exa response.
  • Cancel and convert oversized upstream streams into a graceful sidecar error (<prefix> exceeded byte bound) before any JSON parsing or large-text handling.
  • Decode the bounded byte buffer with a TextDecoder and JSON.parse the guarded text (preserving the existing literal-key scrubbing and truncation behavior for error paths).
  • Add regression tests that simulate oversized success and error bodies to verify the response is rejected and the underlying stream is cancelled (tests/exa-web-search.test.ts).

Testing

  • Ran the focused suite with bun run test -- tests/exa-web-search.test.ts and all tests passed (11 passed, 0 failed).
  • Ran bun run typecheck and bun run privacy:scan, both completed successfully.
  • Ran the broader bun run test workflow and observed an unrelated environment-dependent failure in tests/lab-live-probe.test.ts that stopped the full-suite run, while the focused Exa tests remained green.

Codex Task

@coderabbitai

coderabbitai Bot commented Aug 23, 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: Pro Plus

Run ID: 624d12f1-3082-43f1-93b5-69087119b494


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 Aug 23, 2026
@github-actions github-actions Bot changed the title fix(web-search): bound Exa response bodies [WRONG BRANCH] fix(web-search): bound Exa response bodies Aug 23, 2026
@github-actions

github-actions Bot commented Aug 23, 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 marked this pull request as draft August 23, 2026 01:20

@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: 794652493b

ℹ️ 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".

}),
{ abortSignal: linkedSignal.signal, label: "exa-web-search-sidecar" },
);
const bounded = await readBoundedResponseBytes(res, {

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 Guard the response body before starting the bounded read

When the client abort or timeout lands immediately after fetchWithResetRetry returns headers, readBoundedResponseBytes can observe the already-aborted signal and throw before acquiring or cancelling the response body. On Bun, that leaves the fetch body's native rejection unobserved and can surface as an unhandledRejection, despite this function returning a graceful error. Attach cancelBodyOnAbort(res.body, linkedSignal.signal) before this read and detach it in a finally, as the Gemini executor does.

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

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