Skip to content

Commit f682ffc

Browse files
1 parent 4ad90b8 commit f682ffc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

advisories/github-reviewed/2026/02/GHSA-345p-7cg4-v4c7/GHSA-345p-7cg4-v4c7.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"schema_version": "1.4.0",
33
"id": "GHSA-345p-7cg4-v4c7",
4-
"modified": "2026-02-05T00:34:41Z",
4+
"modified": "2026-02-09T14:52:39Z",
55
"published": "2026-02-04T20:04:16Z",
66
"aliases": [
77
"CVE-2026-25536"
88
],
99
"summary": "@modelcontextprotocol/sdk has cross-client data leak via shared server/transport instance reuse",
10-
"details": "### Summary\n\nCross-client response data leak when a single `McpServer`/`Server` and transport instance is reused across multiple client connections, most commonly in stateless `StreamableHTTPServerTransport` deployments.\n\n### Impact\n\n**Who is affected:** Any MCP server deployment using the TypeScript SDK where a single `McpServer` (or `Server`) instance is shared across multiple concurrent client connections. This is most likely in stateless mode (no `sessionIdGenerator`), where the natural but incorrect pattern is to create one server and transport and handle all requests through it. Stateful mode is also affected if the server instance is improperly shared across sessions, though this misconfiguration is less common since the stateful pattern naturally encourages per-session instances.\n\n**What happens:** When two or more MCP clients send requests concurrently through a shared server instance, JSON-RPC message ID collisions cause responses to be routed to the wrong client's HTTP connection. Client A can receive response data intended for Client B, and vice versa, even when authorization was correctly enforced on each individual request.\n\nThe MCP SDK's client generates message IDs using a simple incrementing counter starting at 0. When two clients connect to the same server instance, they produce identical message IDs, causing the transport's internal request-to-stream mapping to overwrite one client's entry with another's — routing responses to the wrong HTTP connection.\n\n**Conditions for exploitation:**\n- The server reuses a single `McpServer`/`Server` instance across requests or sessions (rather than creating fresh instances per request/session)\n- Two or more clients connect concurrently\n- Clients generate overlapping JSON-RPC message IDs (virtually guaranteed since the SDK's client uses an incrementing counter starting at 0)\n\n**Not affected:**\n- Stateful servers that create a new `McpServer` + transport per session (the typical and recommended stateful pattern)\n- Stateless servers that create a new `McpServer` + transport per request\n- Single-client environments (e.g., local development with one IDE)\n\n### Patches\n\nThe fix adds runtime guards that turn silent data misrouting into immediate, actionable errors:\n\n1. `Protocol.connect()` now throws if the protocol is already connected to a transport, preventing silent transport overwriting across both stateful and stateless modes\n2. Stateless `StreamableHTTPServerTransport.handleRequest()` now throws if called more than once, enforcing one-request-per-transport in stateless mode\n\nServers that were incorrectly reusing instances will now receive a clear error message directing them to create separate instances per connection.\n\n### Workarounds\n\nIf projects cannot upgrade immediately, ensure the server creates fresh `McpServer` and transport instances for each request (stateless) or session (stateful):\n\n```typescript\n// Stateless mode: create new server + transport per request\napp.post('/mcp', async (req, res) => {\n const server = new McpServer({ name: 'my-server', version: '1.0.0' });\n // ... register tools, resources, etc.\n const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });\n await server.connect(transport);\n await transport.handleRequest(req, res);\n});\n\n// Stateful mode: create new server + transport per session\nconst sessions = new Map();\napp.post('/mcp', async (req, res) => {\n const sessionId = req.headers['mcp-session-id'];\n if (sessions.has(sessionId)) {\n await sessions.get(sessionId).transport.handleRequest(req, res);\n } else {\n const server = new McpServer({ name: 'my-server', version: '1.0.0' });\n // ... register tools, resources, etc.\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID()\n });\n await server.connect(transport);\n sessions.set(transport.sessionId, { server, transport });\n await transport.handleRequest(req, res);\n }\n});\n```\n\n### Resources\n\n- https://github.com/modelcontextprotocol/typescript-sdk/issues/204\n- https://github.com/modelcontextprotocol/typescript-sdk/issues/243",
10+
"details": "### Summary\n\nCross-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.\n\n### Impact\n\nThis advisory covers two related but distinct vulnerabilities. A deployment may be affected by one or both.\n\n#### Issue 1: Transport re-use\n\n**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.\n\n**What is affected:** All request types — `tools/call`, `resources/read`, `prompts/get`, etc. No server-initiated features are required to trigger this.\n\n**Conditions:**\n- A single `StreamableHTTPServerTransport` instance is reused across multiple client requests (most common in stateless mode without `sessionIdGenerator`)\n- Two or more clients send requests concurrently\n- Clients generate overlapping JSON-RPC message IDs (the SDK's default client uses an incrementing counter starting at 0)\n\n#### Issue 2: Server/Protocol re-use\n\n**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.\n\n**What is affected:** This depends on what features your server uses:\n\n - **Final responses** (the return value from a tool/resource/prompt handler): Affected in most cases. The Protocol captures this._transport at [request-handling time](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/packages/core/src/shared/protocol.ts#L760), not the transport that delivered the request. This means:\n - If a request is already in-flight when a second connect() occurs (i.e., the request\n arrived before the transport was overwritten), the captured reference is correct and\n the response routes properly.\n - If a request arrives on the old transport after a second connect() has overwritten\n this._transport, the captured reference points to the new transport, and the response\n is mis-routed. The requesting client will time out.\n- **Progress notifications** sent during tool execution via `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.\n- **Sampling** (`createMessage`) and **elicitation** requests sent during tool execution via `sendRequest`: **Affected.** Same mechanism — the request is sent to the wrong client.\n- **Spontaneous server-initiated notifications** (outside any request handler): **Affected.** These are sent to whichever client's transport was most recently connected.\n\n**Conditions:**\n- A single `McpServer`/`Server` instance is `connect()`ed to multiple transports across requests or sessions\n- Two or more clients connect concurrently\n- For in-request notifications/requests: message ID collision on the other transport is required for silent data leaking (the SDK's default client uses an incrementing counter starting at 0). Without collision, the transport will throw an error rather than misroute.\n- For spontaneous notifications: no collision needed, messages are always sent to the last-connected client's transport\n\n#### How to tell if you're affected\n\n- **You use `sessionIdGenerator` (stateful mode) with a new `McpServer` per session** → not affected by either issue. Each session has its own transport and server instance.\n- **You use `sessionIdGenerator` but share a single `McpServer` across sessions** → not affected by Issue 1 (transport re-use), but affected by Issue 2 (server re-use) if your tools send progress notifications, sampling, or elicitation during execution.\n- **You are in stateless mode and reuse both a transport and a server across requests** → affected by both issues; all request types can leak.\n- **You are in stateless mode and create a new transport per request, but reuse the server** → affected by Issue 2 only; safe if your tools only return results without sending progress notifications, sampling, or elicitation during execution.\n- **You create a new server + transport per request** → not affected.\n- **Single-client environments** (e.g., local development with one IDE) → not affected.\n\n### Patches\n\nThe fix (v1.26.0) adds runtime guards that turn silent data misrouting into immediate, actionable errors:\n\n1. `Protocol.connect()` now throws if the protocol is already connected to a transport, preventing silent transport overwriting (addresses Issue 2)\n2. Stateless `StreamableHTTPServerTransport.handleRequest()` now throws if called more than once, enforcing one-request-per-transport in stateless mode (addresses Issue 1)\n3. In-flight request handler abort controllers are cleaned up on `close()`, and `sendNotification`/`sendRequest` in handler extras check the abort signal before sending, preventing messages from leaking after a transport is replaced\n\nServers that were incorrectly reusing instances will now receive a clear error message directing them to create separate instances per connection.\n\n### Workarounds\n\nIf you cannot upgrade immediately, ensure your server creates fresh `McpServer` and transport instances for each request (stateless) or session (stateful):\n\n```typescript\n// Stateless mode: create new server + transport per request\napp.post('/mcp', async (req, res) => {\n const server = new McpServer({ name: 'my-server', version: '1.0.0' });\n // ... register tools, resources, etc.\n const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });\n await server.connect(transport);\n await transport.handleRequest(req, res);\n});\n\n// Stateful mode: create new server + transport per session\nconst sessions = new Map();\napp.post('/mcp', async (req, res) => {\n const sessionId = req.headers['mcp-session-id'];\n if (sessions.has(sessionId)) {\n await sessions.get(sessionId).transport.handleRequest(req, res);\n } else {\n const server = new McpServer({ name: 'my-server', version: '1.0.0' });\n // ... register tools, resources, etc.\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID()\n });\n await server.connect(transport);\n sessions.set(transport.sessionId, { server, transport });\n await transport.handleRequest(req, res);\n }\n});\n```",
1111
"severity": [
1212
{
1313
"type": "CVSS_V3",

0 commit comments

Comments
 (0)