@modelcontextprotocol/sdk
Affected
- introduced
1.10.0, fixed1.26.0(semver)
Fixed versions
1.26.0
Fix
- Fixed version
1.26.0npm install @modelcontextprotocol/[email protected]
Advisory
Also known as: CVE-2026-25536
@modelcontextprotocol/sdk has cross-client data leak via shared server/transport instance reuse
Summary
Cross-client data leak via two distinct issues: (1) reusing a single StreamableHTTPServerTransport across multiple client requests, and (2) reusing a single McpServer/Server instance across multiple transports. Both are most common in stateless deployments.
Impact
This advisory covers two related but distinct vulnerabilities. A deployment may be affected by one or both.
Issue 1: Transport re-use
What happens: When a single StreamableHTTPServerTransport instance handles multiple client requests, JSON-RPC message ID collisions cause responses to be routed to the wrong client's HTTP connection. The transport maintains an internal requestId → stream mapping, and since MCP client SDKs generate message IDs using an incrementing counter starting at 0, two clients produce identical IDs. The second client's request overwrites the first client's mapping entry, routing the response to the wrong HTTP stream.
What is affected: All request types — tools/call, resources/read, prompts/get, etc. No server-initiated features are required to trigger this.
Conditions:
StreamableHTTPServerTransport instance is reused across multiple client requests (most common in stateless mode without sessionIdGenerator)Issue 2: Server/Protocol re-use
What happens: When a single McpServer (or Server) instance is connect()ed to multiple transports (one per client), the Protocol's internal this._transport reference is silently overwritten. The final response to a request is routed correctly (the Protocol captures the transport reference at request time), but any server-to-client messages sent during request handling use the shared this._transport reference, which may point to a different client's transport.
What is affected: This depends on what features your server uses:
sendNotification: Affected. These are dispatched through this._transport. When the transport has been overwritten and message IDs collide on the new transport, notifications are routed to the wrong client's HTTP stream.createMessage) and elicitation requests sent during tool execution via sendRequest: Affected. Same mechanism — the request is sent to the wrong client.Conditions:
McpServer/Server instance is connect()ed to multiple transports across requests or sessionsHow to tell if you're affected
Patches
The fix (v1.26.0) adds runtime guards that turn silent data misrouting into immediate, actionable errors:
Protocol.connect() now throws if the protocol is already connected to a transport, preventing silent transport overwriting (addresses Issue 2)StreamableHTTPServerTransport.handleRequest() now throws if called more than once, enforcing one-request-per-transport in stateless mode (addresses Issue 1)close(), and sendNotification/sendRequest in handler extras check the abort signal before sending, preventing messages from leaking after a transport is replacedServers that were incorrectly reusing instances will now receive a clear error message directing them to create separate instances per connection.
Workarounds
If you cannot upgrade immediately, ensure your server creates fresh McpServer and transport instances for each request (stateless) or session (stateful):
// Stateless mode: create new server + transport per request
app.post('/mcp', async (req, res) => {
const server = new McpServer({ name: 'my-server', version: '1.0.0' });
// ... register tools, resources, etc.
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
await server.connect(transport);
await transport.handleRequest(req, res);
});
// Stateful mode: create new server + transport per session
const sessions = new Map();
app.post('/mcp', async (req, res) => {
const sessionId = req.headers['mcp-session-id'];
if (sessions.has(sessionId)) {
await sessions.get(sessionId).transport.handleRequest(req, res);
} else {
const server = new McpServer({ name: 'my-server', version: '1.0.0' });
// ... register tools, resources, etc.
const transport = new StreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID()
});
await server.connect(transport);
sessions.set(transport.sessionId, { server, transport });
await transport.handleRequest(req, res);
}
});High Basis: The source's own band: HIGH
1.10.0, fixed 1.26.0 (semver)1.26.0
1.26.0npm install @modelcontextprotocol/[email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0