Repository navigation
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close: this PR is a duplicate landing path for the same body-less MCP HTTP response policy already covered by the open, proof-positive, mergeable candidate at #98143, which has broader coverage and stronger loopback proof. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Use #98143 as the single canonical landing path and keep #97521 as the maintainer policy tracker until the fail-closed behavior is accepted or changed. So I’m closing this here and keeping the remaining discussion on #98143 and #97521. Review detailsBest possible solution: Use #98143 as the single canonical landing path and keep #97521 as the maintainer policy tracker until the fail-closed behavior is accepted or changed. Do we have a high-confidence way to reproduce the issue? Yes. Current main reaches Is this the best way to solve the issue? No for this branch as the landing path. The implementation direction is plausible, but the best maintainer path is to consolidate on the already open proof-positive canonical PR with broader tests and loopback proof. Security review: Security review cleared: No supply-chain or new security-boundary regression was found; the diff is targeted availability hardening, with compatibility and residual allocation tradeoffs captured as merge risk. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 8d535fb039c5. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
2c98842 to
5e75538
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞✅ Reason: structured ClawSweeper close marker: close-required (sha=5e75538c39e82de171ad6f43f9349f37c0f3f8b6) Closed:
|
What Problem This Solves
Fixes an issue where body-less MCP HTTP responses (e.g. OAuth error ForeignResponse objects from the MCP SDK, or responses whose body was consumed) could exhaust process memory. The
ensureGlobalFetchResponsefunction calledresponse.text()without verifying the declared Content-Length, allowing an oversized body-less response to allocate unbounded memory.Why This Change Was Made
Single-chokepoint fix at
ensureGlobalFetchResponse— both callers inbuildManagedMcpResponseconverge through this function. The change makes the body-less path fail-safe:text()is called, response body preserved.text()is never called, returning a null-body Response. No allocation, no OOM.text()to catch lying headers.Cap is 1 MiB, matching the merged
CONVEX_BROKER_RESPONSE_MAX_BYTESprecedent in #98619. Content-Length validation uses/^\d+$/to reject scientific-notation (1e3) and hex (0x40) values thatNumber()would accept but are invalid per RFC 7230.User Impact
MCP servers returning oversized or unverifiable body-less responses now receive a null-body Response instead of causing the gateway process to allocate unbounded memory. Legitimate MCP OAuth error responses (which declare a valid Content-Length) are unaffected.
Real behavior proof
Behavior addressed:
buildMcpHttpFetch(production entry point) →ensureGlobalFetchResponserejects/drops body-less text reads when Content-Length is missing, malformed, or oversized.text()is never called in those cases, preventing the unbounded allocation.Real environment tested: Linux x64, Node 22.22.0, standalone
.mtsscript driving the realbuildMcpHttpFetchproduction function.Evidence after fix:
Negative control (pre-fix main code, same script):
Without the fix,
text()is called unconditionally on oversized/missing/malformed Content-Length responses (6 FAIL, exit=1). With the fix, text() is never called in those cases and the response is dropped safely.What was not tested: Full undici network round-trip (mock fetch used; the bounds guards operate on the Response object post-fetch, independent of transport). Streaming response path is verified untouched.
Evidence
Vitest: 16/16 passed (10 existing + 6 new)
New tests:
drops body-less text when Content-Length exceeds the 1 MiB cap— verifiestext()not calleddrops body-less text when Content-Length is missing— verifiestext()not calleddrops body-less text when Content-Length is malformed (abc/1e3/0x40)— parameterized, verifiestext()not calledaccepts body-less responses with valid Content-Length within the 1 MiB cap— verifies normal path works