Summary
The MCP Python SDK's SSE and stateful Streamable HTTP transports route requests to sessions using only a session identifier, without binding the session to the authenticated principal that created it.
When a bearer-token-authenticated client knows another client's session ID, it can inject JSON-RPC messages into that session, potentially hijacking or manipulating ongoing protocol interactions in multi-client environments.
Affected context
This vulnerability appears in deployments using the MCP Python SDK's SSE (SseServerTransport) or stateful Streamable HTTP (StreamableHTTPSessionManager) transports to manage long-lived JSON-RPC sessions.
It is relevant where multiple authenticated clients can interact with the same MCP server and session identifiers may be discoverable or guessable (e.g., logs, URLs, or shared debugging tools).
The risk materializes when session routing relies solely on session_id query parameters or Mcp-Session-Id headers without validating that the request's authenticated principal matches the principal that originally established the session.
Exploit preconditions
- Attack surface: MCP server endpoints using SSE or stateful Streamable HTTP transports.
- Required access: Valid bearer-token authentication to the MCP server and knowledge of a target
session_idorMcp-Session-Id. - Trigger point: Sending JSON-RPC requests referencing the victim's session identifier via query parameter or header.
- Why exploitation is possible: Session association is based only on the session identifier; there is no enforcement that the caller's authenticated identity matches the identity bound to the session at creation time, enabling cross-tenant or cross-user session message injection.
Why this happens
The underlying bug aligns with CWE-639: Authorization Bypass Through User-Controlled Key, where access control for a resource is implemented solely via a user-provided identifier.
In this case, session_id and Mcp-Session-Id function as keys for routing JSON-RPC messages to stateful sessions, but the transport layer fails to cross-check those identifiers against the authenticated principal associated with the session.
This insecure pattern treats the session identifier as sufficient proof of entitlement, rather than as an internal routing token that must always be validated against the caller's identity.
Potential impact
- An attacker may inject arbitrary JSON-RPC messages into another client's active MCP session.
- An attacker could manipulate tools, resources, or operations invoked within the victim's session context.
- An attacker may cause data leakage by triggering responses intended for the victim session.
- An attacker could disrupt or corrupt session state, leading to denial of service or misleading results for the victim.
General mitigation guidance
Effective mitigation focuses on strengthening session-to-principal binding and removing trust in client-controlled identifiers as sole access keys.
Recommended design patterns include:
- Binding each server-side session to the authenticated principal at creation and verifying that every subsequent request's identity matches this principal before routing.
- Treating session identifiers as opaque routing tokens, never as authorization proofs; always perform a separate authorization check.
- Segmenting sessions by tenant or user and ensuring that cross-tenant access via shared identifiers is impossible.
- Reducing exposure of session identifiers by avoiding their presence in logs, URLs, or user-visible debug tooling where feasible.
- Applying least-privilege principles to session capabilities so that even if a session is misrouted, the scope of operations is constrained.
How teams detect issues like this
To detect similar authorization bypasses, organizations can:
- Use static analysis or code scanning rules to identify patterns where access decisions depend solely on user-supplied identifiers (e.g.,
session_id,user_id,accountId) without identity checks. - Incorporate security-focused code review checklists that flag session routing logic for missing principal verification or missing tenant scoping.
- Implement runtime auditing of session management operations, logging authenticated principal, session ID, and authorization decisions, then monitor for anomalous cross-user session usage.
- Employ automated policy enforcement tools that require explicit identity binding for session and stateful transport components across services.

