Repository navigation
Conversation
|
Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Fixes an issue where MCP HTTP responses with large bodies (e.g. from a misconfigured or malicious MCP server) could exhaust process memory. The
ensureGlobalFetchResponsefunction readresponse.text()without any size check, so a response body of hundreds of megabytes would be buffered entirely in memory — risking OOM.Why This Change Was Made
A single chokepoint fix at
ensureGlobalFetchResponse— both callers inbuildManagedMcpResponsepass through this function. The fix adds a two-layer guard:response.text()is called when the header is present and oversized.Cap is 16 MiB, matching the existing SSH sandbox output bound.
User Impact
MCP server responses larger than 16 MiB are now rejected with a clear error message instead of silently consuming unbounded memory until the process crashes.
Real behavior proof
Behavior addressed:
ensureGlobalFetchResponserejects oversized body-less responses viabuildMcpHttpFetch.Real environment tested: Linux x64, Node 22.22.0, openclaw main branch.
Evidence after fix:
Negative control (pre-fix behavior reproduced):
Without the fix, oversized responses pass through silently (no rejection, potential OOM). With the fix, they are caught and rejected.
What was not tested: Real undici HTTP server round-trip (mock fetch used; the bounds guards operate on the Response object post-fetch, independent of transport).
Evidence
Vitest: 13/13 passed (10 existing + 3 new bound tests)
New tests:
rejects body-less responses whose Content-Length exceeds the 16 MiB caprejects body-less responses whose actual text exceeds the 16 MiB capaccepts body-less responses within the 16 MiB cap