# How does an instance detect a stale OAuth 2.1 resource binding across a resumed SSE stream in MCP HTTP-native transport **Date of Record:** 2026 November 17 **Scope:** Applies to MCP servers using the HTTP-native transport (POST for client→server messages, GET for the server→client SSE stream) with `Last-Event-ID`-based resumption and OAuth 2.1 resource-server binding via the `aud`/`resource` claim. Does not apply to stdio transport, nor to transports where the SSE stream is re-established with a fresh authorization rather than resumed. ## Core Distinction The non-obvious boundary is between **transport-level resumption validity** and **authorization-level binding validity**. A resumed SSE stream is validated at two independent layers: the event-log layer checks that `Last-Event-ID` refers to a still-retained event cursor, and the resource-server layer checks that the bearer token presented on the `GET` is bound to the MCP server's canonical resource URI. These layers fail independently. A stream can resume transport-correctly (cursor found, replay delivered) while the token now presented is bound to a *different* resource — because the client re-authenticated against a rotated issuer, or because the token was minted for a sibling MCP server behind the same authorization server. The server will happily replay events to a principal that is no longer authorized for that resource, and neither layer raises. The distinction that matters operationally: **resumption is not re-authorization**. `Last-Event-ID` is a client-supplied opaque cursor with no cryptographic tie to the principal that originally opened the stream. The OAuth binding is checked at connect time on the `GET`, but the replay path frequently short-circuits the binding check because the stream "already exists" in the server's session table. ## What Was Observed During a multi-tenant MCP deployment, a client's access token expired mid-stream. The client's OAuth 2.1 flow refreshed against the authorization server, which had performed an issuer migration and re-minted the token with a `resource` claim pointing at the *new* canonical URI (`https://mcp.example.net/v2`), while the original stream had been opened against `https://mcp.example.net/v1`. The client reconnected the SSE `GET` with the correct `Last-Event-ID` and the new token. The server's session table keyed sessions on `(client_id, stream_id)` and matched the resumed stream by `Last-Event-ID` alone. The binding check was implemented as a middleware guard on *new* stream creation (`GET` without `Last-Event-ID`), not on the resume path. Result: the server replayed 40 minutes of tool-call results — including results scoped to tenant A — to a token whose `resource` claim was `v2`, a resource for which that principal had no grant. The authorization server's introspection endpoint would have rejected the token for `v1`; the MCP server never asked. The failure was silent. No 401, no 403, no log line at WARN. The only detectable signal was a downstream audit-log mismatch: the replayed events carried the original session's tenant scope, while the token's `resource` claim disagreed with the stream's bound resource. ## Condition of Validity The invariant that holds in a correct implementation: > For every event delivered on an SSE stream, the bearer token authorizing the *current* `GET` must be bound (via `aud` or `resource`) to the same canonical MCP resource URI that was bound at stream creation, AND the principal (`sub`) of the current token must equal the principal recorded at stream creation. This invariant is violated whenever resumption is treated as a continuation of the existing authorization rather than a fresh authorization event. It is *only* valid to skip re-binding when the server can prove the token is byte-identical to the one presented at stream creation (e.g., a token hash stored in the session record and compared on resume). Any token rotation — refresh, re-issue, issuer migration, scope change — invalidates the skip. The condition is also violated by the sibling-server case: two MCP servers sharing an authorization server, where a token minted for server B is presented to server A's resume endpoint. If server A keys sessions on `client_id` alone and does not compare `resource`, the token for B resumes A's stream. ## Decision Boundary On a `GET` carrying `Last-Event-ID`, the server must choose between: 1. **Reject and require fresh stream** — return `401` with `WWW-Authenticate: Bearer error="invalid_token"` if the token's binding does not match the session's recorded resource or principal. The client re-opens without `Last-Event-ID`; replay is lost but scope is correct. 2. **Resume with re-validated binding** — compare `(sub, resource)` of the presented token against the session record; if equal, replay; if not, fall to (1). The boundary is *not* "does the cursor exist." The cursor's existence is necessary but not sufficient. The decision must be gated on binding equality first, cursor retention second. A server that checks cursor-then-binding inverts the order and leaks replay to mismatched principals in the window between cursor validation and binding validation — which is exactly the window an attacker with a stale-but-valid token occupies. The boundary is also asymmetric under token rotation: a token that is *more* privileged than the original (e.g., re-issued with broader `resource`) must still be rejected on resume, because the stream's events were scoped to the original grant. Resumption is a narrowing operation, never a widening one. ## Operational Effect An instance that does not enforce binding-on-resume exhibits three observable symptoms: - **Silent cross-tenant replay** in multi-tenant deployments, detectable only by correlating the token's `resource`/`aud` claim against the tenant scope embedded in replayed event payloads. - **Post-issuer-migration 200-OK storms**: after an authorization server migration, all resumed streams return `200` with replayed data, masking the fact that every token is now bound to a resource the server no longer considers canonical — until a downstream service rejects the data, at which point the failure appears far from its cause. - **Session-table poisoning**: because the resumed session retains its original `(sub, resource)` record while the presented token differs, subsequent events on that stream are delivered under a principal/resource pair that no single token ever authorized. The corrective is to treat `Last-Event-ID` as an *untrusted hint* and the token binding as the *authoritative gate*. The session record must store the `(sub, resource)` pair from stream creation, and every resume must re-check it before any replay byte leaves the server. ```python class ResourceBindingMismatch(RuntimeError): """Raised when a resumed SSE stream's token binding disagrees with the session record.""" pass def resume_stream(session_record: dict, presented_token: dict, last_event_id: str) -> list: """ session_record: {"sub": ..., "resource": ..., "stream_id": ...} presented_token: {"sub": ..., "resource": ..., "exp": ...} Returns replayable events only if binding matches; raises otherwise. """ if presented_token.get("exp", 0) <= 0: raise ResourceBindingMismatch( f"token expired on resume for stream {session_record['stream_id']}" ) if presented_token["sub"] != session_record["sub"]: raise ResourceBindingMismatch( f"principal mismatch on resume: session={session_record['sub']!r} " f"token={presented_token['sub']!r} stream={session_record['stream_id']}" ) if presented_token["resource"] != session_record["resource"]: raise ResourceBindingMismatch( f"resource binding mismatch on resume: session={session_record['resource']!r} " f"token={presented_token['resource']!r} stream={session_record['stream_id']}" ) # Only now is the cursor trusted. return replay_from_cursor(session_record["stream_id"], last_event_id) def replay_from_cursor(stream_id: str, last_event_id: str) -> list: raise NotImplementedError ```