# What structural signals indicate an MCP Streamable-HTTP session has silently rebound to a stale OAuth 2.1 resource audience after SSE fallback **Date of Record:** 2026 December 2 **Scope:** Applies to MCP servers and clients using the HTTP-native transport (single `/mcp` endpoint, `POST` for requests, `GET` for the server-to-client SSE stream, `Mcp-Session-Id` for resumption, and OAuth 2.1 bearer tokens bound to a resource via RFC 8707 `resource` indicators). Does not apply to stdio transport, nor to servers that re-issue a fresh session on every reconnect without resumption. ## Core Distinction The failure is not "the token expired" and not "the SSE stream dropped." Both of those are observable and recoverable. The dangerous condition is that the transport *successfully* resumes a session (`Mcp-Session-Id` matches, `Last-Event-ID` is honored, HTTP 200 returns) while the OAuth 2.1 access token presented on the resumed stream is bound to a *different* `resource` audience than the one the session was originally established under. The session layer and the authorization layer each independently report success, so nothing in the protocol's happy path raises an error — yet every subsequent server-to-client notification and every tool result now flows under a token whose audience no longer matches the resource the client believes it is talking to. The boundary is this: **session identity (`Mcp-Session-Id`) and authorization identity (`resource` + `aud`) are orthogonal, and the transport spec does not require them to be re-validated as a pair on resumption.** A resumed session is a continuity claim about *state*; a bearer token is a claim about *authority*. When a proxy, a token-refresh flow, or a load balancer rotates the token between the initial `POST` and the fallback `GET` stream, the two claims desynchronize without any single component noticing. ## What Was Observed A client established a session over streamable HTTP: an `initialize` `POST` carrying a token minted for `resource=https://mcp.internal.example/tenant-a`. The server returned `Mcp-Session-Id: 7f3c…` and the client opened the `GET` SSE stream with the same token and `Accept: text/event-stream`. Mid-task, the upstream SSE connection was severed by an idle timeout at an intervening proxy. The client's token-refresh logic fired (the access token was near expiry), and the auth library minted a new token — but the refresh request omitted the `resource` parameter, so the authorization server fell back to the *default* audience registered for the client, `https://mcp.internal.example/tenant-b`. The client reconnected: `GET /mcp` with `Mcp-Session-Id: 7f3c…`, `Last-Event-ID: 4821`, and the new (wrong-audience) bearer token. Observed responses: - The server returned `200 OK` and replayed events from `4821` onward. Session resumption succeeded. - The server's token introspection checked signature, expiry, and scope — all valid. It did **not** compare the token's `aud`/`resource` claim against the audience recorded at session creation, because the session record never stored that binding. - Subsequent `tools/call` responses executed against tenant-a's tool registry (the session's state) but were authorized against tenant-b's grant set. A tool that tenant-b was permitted to invoke but tenant-a was not returned a result; a tool that tenant-a permitted but tenant-b did not returned `403` *on the stream*, which the client logged as a transient tool error rather than an auth fault. - No log line anywhere contained both the session id and the token audience on the same record, so the desync was invisible in aggregate telemetry. The tell was structural, not error-driven: the client's own event stream carried results whose authorization provenance did not match the session's origin, and the only way to detect it was to correlate two identifiers that the transport never required to be logged together. ## Condition of Validity The guardrail holds only if the server binds the authorization audience to the session at creation and re-validates it on every resumption. Concretely: 1. At `initialize`, the server MUST persist `(Mcp-Session-Id, resource_indicator, aud, subject)` as an immutable tuple. 2. On any resumption (`GET` with `Mcp-Session-Id`, or `POST` with `Last-Event-ID`), the server MUST reject the request if the presented token's `aud`/`resource` does not match the persisted `resource_indicator`, returning `401` with `WWW-Authenticate: Bearer error="invalid_token", error_description="audience_mismatch"` — *not* silently continuing. 3. The client MUST include the `resource` parameter on every token-refresh request, and MUST treat a refresh that cannot echo the original resource as a hard failure rather than a degraded retry. This is valid only when the authorization server honors RFC 8707 resource indicators and when the transport proxy is configured to forward `Mcp-Session-Id` and the `Authorization` header together without rewriting either. In deployments where a gateway terminates TLS and re-mints tokens per hop, the invariant cannot be maintained at the MCP layer and must be enforced at the gateway with the same tuple. ## Decision Boundary The decision the operator faces is whether to treat a resumed session as *trusted continuity* or as *re-authenticated continuity*. The boundary condition that forces the choice: - **If the token audience is identical across the session's lifetime**, resumption is pure state continuity and the cheap path (replay from `Last-Event-ID`, no re-auth) is correct. - **If the token audience can differ** — because of refresh, multi-tenant routing, or proxy re-minting — then resumption *is* a re-authentication event and must be validated as one. The non-obvious part: you cannot decide which regime you are in from the transport alone. The signal is whether your refresh path carries the `resource` parameter and whether your session store persists the audience tuple. If either is missing, you are in the second regime whether you designed for it or not. The safe default is to *always* re-validate the audience on resumption; the cost is one comparison per reconnect, and the failure it prevents is silent cross-tenant authorization drift. ## Operational Effect Left unguarded, the effect is not a crash but a *provenance split*: the session's state (tool registry, conversation history, pending checkpoints) is anchored to tenant-a, while the authority governing each new action is tenant-b. Downstream consequences compound: - Tool results returned on the resumed stream carry tenant-a data but were authorized under tenant-b's grant set, so audit logs attribute cross-tenant reads to the wrong principal. - A verification/auditor agent replaying the session later sees a coherent event log with no audience annotations and reproduces the wrong authorization decision. - The client's retry logic, seeing `403`s interleaved with `200`s, may classify the session as flaky and re-`initialize` — which *does* re-bind the audience, masking the bug and destroying the evidence. The invariant to enforce: **a session is not resumable across an audience change.** Either the audience matches and state resumes, or the audience differs and the session must be torn down and re-initialized under the new authority. There is no valid third state, and the transport will not tell you when you have entered it. ```python from dataclasses import dataclass from typing import Optional class AudienceRebindError(RuntimeError): """Raised when a resumed MCP session's token audience no longer matches the resource indicator recorded at session creation.""" @dataclass(frozen=True) class SessionBinding: session_id: str resource_indicator: str audience: str subject: str def resume_session( binding: Optional[SessionBinding], presented_session_id: str, token_audience: str, token_resource: str, ) -> SessionBinding: if binding is None: raise AudienceRebindError( f"no persisted binding for session {presented_session_id!r}; " "refusing to resume unauthenticated continuity" ) if binding.session_id != presented_session_id: raise AudienceRebindError( f"session id mismatch: stored {binding.session_id!r} " f"vs presented {presented_session_id!r}" ) if token_audience != binding.audience or token_resource != binding.resource_indicator: raise AudienceRebindError( "audience rebind on resumption: " f"session {binding.session_id!r} was bound to " f"resource={binding.resource_indicator!r} aud={binding.audience!r}, " f"but token presents resource={token_resource!r} aud={token_audience!r}; " "tear down and re-initialize under the new authority" ) return binding ```