SSE auth/custom headers are logged verbatim by the Inspector proxy
Description
SSE auth/custom headers are logged verbatim by the Inspector proxy
Summary
MCP Inspector forwards authentication headers from the browser-side proxy request to upstream SSE MCP servers, then logs the entire forwarded header object before creating the SSE client transport. When a user connects to an authenticated SSE MCP server, the Inspector proxy can print the upstream Authorization bearer token and arbitrary custom auth headers to stdout/container logs.
This is limited to the SSE transport path. The same full-header log was not found in the streamable-http path.
Affected code
In server/src/index.ts, getHttpHeaders(req) intentionally collects headers that should be forwarded upstream:
authorizationis copied into the forwarded header object.- headers listed through
x-custom-auth-headerorx-custom-auth-headersare copied by name and value. - only the Inspector proxy auth header and MCP client/proxy session id are excluded.
The SSE branch then logs the full object:
const headers = getHttpHeaders(req);
headers["Accept"] = "text/event-stream";
console.log(
`SSE transport: url=${url}, headers=${JSON.stringify(headers)}`,
);The client-side SSE connection code builds those same auth/custom headers and sends them through the proxy request. The README also documents bearer token authentication for SSE connections, so these values are expected to be real upstream credentials.
Vulnerability chain
- Operator runs Inspector proxy and connects (through it) to an authenticated upstream SSE MCP server.
- Browser-side connection code attaches the upstream
Authorizationheader (and any documented custom auth headers viax-custom-auth-header(s)) to the proxy request. - The proxy's SSE handler invokes
getHttpHeaders(req), which copiesauthorizationand custom-auth headers into the upstream-bound header object. - Before opening the upstream SSE transport, the handler
console.logsheaders=${JSON.stringify(headers)}— which now contains the verbatim bearer/API-key values. - Anything ingesting the proxy's stdout (terminal scrollback, Docker/Kubernetes log driver, devcontainer/CI log capture, support bundles) now contains the upstream credential.
Root cause
The header-forwarding helper getHttpHeaders(req) correctly distinguishes between proxy-local headers (which are excluded) and upstream-bound headers (which are forwarded). That distinction is the right place to encode "secret to upstream" knowledge. The SSE branch then discards that distinction by stringifying the resulting object into a debug log line. The mistake is that there is no allowlist on what is loggable about a header set whose entire purpose is to ferry secrets across a trust boundary. Structurally, the fix is to either (a) log only header names, or (b) log a redacted view that masks values for any header whose name matches a credential pattern (authorization, proxy-authorization, cookie, set-cookie, *token*, *secret*, *key*, *auth*) plus values copied via x-custom-auth-header(s). The streamable-http path already does not have this JSON.stringify(headers) log, so the fix is local to one statement in the SSE branch.
Auth boundary violated
Boundary type: Credential confidentiality between the Inspector operator process and any process or human with read access to the operator's stdout/log sink. The trust model is that the upstream MCP server's bearer/API-key is held by the user-agent and the proxy in transit, but never durably written to a log surface that has different ACLs than the credential itself.
Respected at: getHttpHeaders(req) correctly excludes the Inspector-proxy auth header and the MCP client/proxy session id from the forwarded object — those are recognized as not for upstream. The streamable-http transport branch does not log the forwarded header object.
Violated at: the SSE-transport branch in server/src/index.ts. After getHttpHeaders(req) returns a header object whose values are upstream credentials, console.log(\SSE transport: url=${url}, headers=${JSON.stringify(headers)}\) writes those values verbatim to stdout. The boundary between "ferry to upstream" and "persist to log" is silently crossed: the same object is treated as both transport payload (sensitive) and debug record (not sensitive) in adjacent statements.
Reproduction
The following local reproduction mirrors the header-selection and SSE log formatting code path without connecting to an external server:
const req = {
headers: {
authorization: "Bearer INSPECTOR_UPSTREAM_SECRET_TOKEN_7c51",
"x-custom-auth-headers": JSON.stringify(["X-Api-Key", "X-Tenant-Token"]),
"x-api-key": "api_key_secret_9a12",
"x-tenant-token": "tenant_secret_485e",
"mcp-feature-flag": "debug",
"x-mcp-proxy-auth": "proxy-token-not-forwarded",
"mcp-session-id": "client-session-not-forwarded",
},
};
const headers = getHttpHeaders(req);
headers["Accept"] = "text/event-stream";
console.log(
`SSE transport: url=https://upstream.example.test/sse, headers=${JSON.stringify(headers)}`,
);Observed output:
SSE transport: url=https://upstream.example.test/sse, headers={"authorization":"Bearer INSPECTOR_UPSTREAM_SECRET_TOKEN_7c51","mcp-feature-flag":"debug","X-Api-Key":"api_key_secret_9a12","X-Tenant-Token":"tenant_secret_485e","Accept":"text/event-stream"}
authorization_leaked=true
custom_api_key_leaked=true
custom_tenant_token_leaked=true
proxy_auth_excluded=true
mcp_session_excluded=trueImpact
Any user or deployment that connects Inspector to an authenticated SSE MCP server can leak upstream bearer/API tokens into the Inspector proxy logs. This matters for terminals with scrollback, shared developer machines, Docker/Kubernetes logs, support bundles, CI/devcontainer logs, and hosted/internal debug environments where stdout is collected centrally.
An attacker who can read those logs can reuse the leaked upstream MCP server credential until it expires or is rotated. The issue does not bypass Inspector proxy authentication by itself, and it does not affect streamable-http through this specific log statement.
Suggested fix
Avoid logging full forwarded header values. Either remove the header object from this log or log only non-sensitive header names. At minimum, redact values for authorization, proxy-authorization, cookie, set-cookie, and any header whose name contains token, secret, key, or auth, including values copied through x-custom-auth-header and x-custom-auth-headers.
It would also be useful to add a regression test that exercises the SSE connection path with Authorization plus a custom header and asserts that the resulting log output does not contain either secret value.