You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Transparent proxy: batch containing initialize skips the unknown-session guard #5883
parseRPCRequest sets sawInitialize = true for a batch if any member is initialize. So a batch such as [{"method":"initialize"},{"method":"tools/call"}] carrying a stale/forged Mcp-Session-Id skips the guard entirely — the one place a bad session ID is rejected at the proxy layer (relevant for multi-replica, Redis-backed deployments where the guard's doc comment treats it as authoritative).
Legacy-only: batches are never revision-classified (batching was removed from MCP in 2025-06-18), so this is unrelated to the Modern/stateless work.
Exploitability is muddied by the fact that a batch containing initialize causes the backend to mint a fresh session; the guard exemption for initialize exists precisely because initialize establishes sessions.
Recommendation
Decide whether the guard exemption should be narrowed to a single genuine initialize request rather than "any batch member named initialize." If narrowed:
Tighten parseRPCRequest so a batch never reports sawInitialize for guard-exemption purposes.
Update/invert TestRoundTripAllowsBatchInitializeWithUnknownSession to reflect the intended semantics.
Add a regression test: a batch with a non-initialize member on an unknown session is rejected at the guard.
#5931 (a18f17e2d) added an unconditional mcp.IsBatchRequest rejection at the top of tracingTransport.RoundTrip (transparent_proxy.go:591), which returns HTTP 400 / -32600before the unknown-session guard at :624 is ever reached. So no batch — with or without an initialize member — can reach the guard to be exempted from it. The rejection inspects the first non-whitespace byte rather than the Content-Type, so it can't be smuggled past under a non-JSON content type either.
That commit also deleted TestRoundTripAllowsBatchInitializeWithUnknownSession (the test this issue asked to invert) and replaced it with TestRoundTripRejectsBatch in backend_routing_test.go, whose first case is the exact payload from this report — [{"method":"initialize"},{"method":"tools/list"}] carrying an unknown Mcp-Session-Id — asserting HTTP 400 and failing the test if the backend is contacted.
One leftover worth noting: the batch-scanning branch in parseRPCRequest still computes sawInitialize by scanning batch members, but it is now dead code in the production path (only the parseRPCRequest unit table still exercises it). Harmless today, but it's the piece that would resurrect this bug if anyone ever relaxes or moves the batch rejection. Leaving it as-is rather than churning the code, just flagging it here for whoever touches that guard next.
Activity
Reorder classification helpers; note batch scope
Serve MCP 2026-07-28 stateless requests through the transparent proxy (…
jhrozek commentedon Jul 27, 2026
Closing as already fixed.
#5931 (
a18f17e2d) added an unconditionalmcp.IsBatchRequestrejection at the top oftracingTransport.RoundTrip(transparent_proxy.go:591), which returns HTTP 400 /-32600before the unknown-session guard at:624is ever reached. So no batch — with or without aninitializemember — can reach the guard to be exempted from it. The rejection inspects the first non-whitespace byte rather than the Content-Type, so it can't be smuggled past under a non-JSON content type either.That commit also deleted
TestRoundTripAllowsBatchInitializeWithUnknownSession(the test this issue asked to invert) and replaced it withTestRoundTripRejectsBatchinbackend_routing_test.go, whose first case is the exact payload from this report —[{"method":"initialize"},{"method":"tools/list"}]carrying an unknownMcp-Session-Id— asserting HTTP 400 and failing the test if the backend is contacted.One leftover worth noting: the batch-scanning branch in
parseRPCRequeststill computessawInitializeby scanning batch members, but it is now dead code in the production path (only theparseRPCRequestunit table still exercises it). Harmless today, but it's the piece that would resurrect this bug if anyone ever relaxes or moves the batch rejection. Leaving it as-is rather than churning the code, just flagging it here for whoever touches that guard next.