
Cloud Vulnerability DB
A community-led vulnerabilities database
StreamableHttpTransport documents and enforces a default 4 MiB upper bound for POST request bodies. However, middleware runs before the transport request handler, and the public OAuth /token and /register middleware endpoints consume their request bodies directly without any size limit.
An unauthenticated remote client can therefore send a body larger than the configured maxBodyBytes value to either endpoint. The same oversized body is rejected with HTTP 413 on an ordinary MCP POST, but /register fully decodes it and invokes the registrar, while /token parses, rebuilds, and forwards it upstream.
In an isolated container with PHP's memory limit set to 128 MiB, a single 16 MiB /token request terminated PHP in OAuthProxyMiddleware::handleToken(). A single 32 MiB /register request independently terminated PHP in ClientRegistrationMiddleware::handleRegistration().
modelcontextprotocol/php-sdkmcp/sdk16836d4e9a0f96831789ac6e64d5ec5238d2c8335e736830795dfabe2f7cff83d0079589b11cf6a0StreamableHttpTransport::DEFAULT_MAX_BODY_BYTES. This report conservatively scopes the affected range to releases where the SDK provides a configurable transport-wide POST body limit that these earlier middleware interceptors bypass.At least one affected middleware is enabled before the transport handler:
OAuthProxyMiddleware exposes unauthenticated POST /token; orClientRegistrationMiddleware exposes unauthenticated POST /register.
The official OAuth examples enable OAuthProxyMiddleware. Dynamic client registration is optional.
An upstream reverse proxy or web server with a lower independent body limit can mitigate exploitation, but the SDK does not require or enforce such a deployment control.StreamableHttpTransport::listen() builds the middleware pipeline around handleRequest(). The transport's bounded body reader executes only after every middleware has passed the request onward.
ClientRegistrationMiddleware intercepts /register first and performs:
$body = $request->getBody()->__toString();
$decoded = json_decode($body, false, 512, JSON_THROW_ON_ERROR);
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);It materializes the complete body and decodes valid JSON twice without consulting maxBodyBytes.
OAuthProxyMiddleware intercepts /token first and performs:
$body = $request->getBody()->__toString();
parse_str($body, $params);
// ...
$body = http_build_query($params);It materializes, parses, and reconstructs the complete form body before forwarding it. These operations create multiple copies and decoded representations of attacker-controlled input.
The attached PHPUnit test uses the real Streamable HTTP transport and both real middleware implementations. It creates a value one byte larger than the default 4 MiB limit and performs three controls:
/register. The middleware returns 201 and the registrar receives the complete value./token. The middleware returns 200 and the mock upstream receives a body larger than 4 MiB.
Default proof:vendor/bin/phpunit tests/Unit/Server/Transport/OAuthEndpointBodyLimitSecurityTest.php --testdoxObserved on v0.8.0, v0.8.1, and current main:
OAuth Endpoint Body Limit Security
✔ O auth endpoints bypass transport body limit
OK (1 test, 8 assertions)
Memory: 40.02 MBThe PoC accepts MCP_OAUTH_BODY_PROBE_BYTES so the resource effect can be confirmed locally without any external target.
With a 16 MiB body and no PHP memory cap, the complete test succeeded but reached approximately 136 MiB peak memory:
MCP_OAUTH_BODY_PROBE_BYTES=16777216 vendor/bin/phpunit \
tests/Unit/Server/Transport/OAuthEndpointBodyLimitSecurityTest.php --testdoxWith memory_limit=128M, the /token leg terminated the PHP process:
Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 50335744 bytes)
in OAuthProxyMiddleware.php on line 149Using MCP_OAUTH_PROBE_STOP_AFTER_REGISTER=1 to isolate /register, a 32 MiB JSON request under the same 128 MiB limit terminated independently:
Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 33554464 bytes)
in ClientRegistrationMiddleware.php on line 83All tests were performed locally in disposable PHP containers.
The affected endpoints are intentionally reachable before bearer-token authentication. A remote unauthenticated attacker can force a PHP worker to allocate multiple times the supplied request size. Depending on the PHP SAPI and process model, one or repeated requests can terminate workers, exhaust a shared memory budget, increase upstream traffic, and degrade or deny the MCP service. The demonstrated request-to-peak ratio for the combined 16 MiB proof was approximately 8.5x (about 136 MiB peak), although exact amplification varies by PHP version, SAPI, allocator, and which endpoint is exercised. This report does not claim a limit bypass where an independently configured reverse proxy rejects the request before PHP receives it.
Suggested CVSS v3.1:
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H — 7.5 High
Suggested weaknesses:
Enforce a shared request-body limit before any route-specific middleware can consume a body. The safest design is an outermost body-limiting middleware used by every POST endpoint, including /token, /register, and future well-known or proxy handlers.
The limiter should:
Content-Length above the configured limit before reading.Content-Length./token and /register requests receive 413 and neither the registrar nor upstream HTTP client is called.
Reverse-proxy limits remain useful defense in depth but should not be the SDK's only protection.On 2026-09-17, public issue searches for body size, request size, payload limits, memory exhaustion, and OAuth denial of service did not reveal this issue. The repository's only published advisory was unrelated.
AI-assisted tooling was used to inspect the source, construct isolated local proofs, compare tagged releases, and draft this report. The reporter reviewed and reproduced the behavior locally and takes responsibility for the submission. php-sdk-oauth-body-limit-bypass-poc.zip
Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."