# When must an instance re-negotiate MCP OAuth resource binding after a resumable SSE replay, and why does the resume token silently outlive its authorization context? **Date of Record:** 2026 November 30 **Scope:** Applies to MCP servers using HTTP-native transport (Streamable HTTP) with `text/event-stream` responses, `Last-Event-ID` resumption, and OAuth 2.1 resource-server binding per RFC 8707 (the `resource` parameter in token requests and `aud` claim validation). Does not apply to stdio transport, to servers that terminate SSE and force full re-initialization on disconnect, or to single-tenant servers with no per-request token binding. ## Core Distinction The failure is not "the token expired mid-stream." It is that the **resumption identity and the authorization identity are decoupled by design**, and the server's replay logic validates them independently. An SSE `Last-Event-ID` is an opaque cursor into a per-session event log. An OAuth 2.1 access token is a bearer credential bound to a `resource` (audience) and a scope set. When a client reconnects with a valid `Last-Event-ID` and a *different but individually valid* token — a refreshed token, a token minted for a different scope, or a token whose `aud` matches a sibling resource server — the server happily resumes the stream from the cursor while authorizing the new request against the new token. The replayed events were produced under the *old* authorization context. Nothing in the protocol forces the server to notice the transition. The invariant that must hold — and that implementations routinely violate — is: **the authorization context that produced event N must be the authorization context that delivers event N.** Resumption is a replay of *authorized output*, not a replay of *transport position*. ## What Was Observed A stateless agent tool server (no server-side session affinity, per the HTTP-native MCP design goal) backed its SSE event log with a shared Redis stream keyed by `session_id`. The `Last-Event-ID` was the Redis stream entry ID. Tokens were validated per-request by a resource-server middleware that checked signature, `exp`, `aud == https://tools.example/mcp`, and required scope `tools:read`. The middleware attached the validated claims to the request context. The SSE handler read events from the stream starting at `Last-Event-ID` and wrote them out. The trigger condition: an agent orchestrator runs a long `tools/call` that streams progress events. The access token (TTL 300s) expires at t=280s. The client's token manager refreshes proactively at t=290s and reconnects with `Last-Event-ID: ` and the *new* token. The new token is valid, `aud` matches, scope matches. The server resumes at entry 412 and replays entries 412–470, which include the tail of a `tools/call` result whose *arguments were authorized under the prior token's scope set* — in this case the prior token carried `tools:write` (returned by a broader consent), the refreshed token was minted by a narrower client registration and carried only `tools:read`. The replayed result payload contained data derived from a write operation the current token could not have initiated. A second, sharper variant: two MCP resource servers (`tools.example/mcp` and `tools.example/mcp-admin`) share the same Redis stream namespace because they were deployed from the same Helm chart with a shared `session_id` prefix. A token minted for the admin audience with `aud: https://tools.example/mcp-admin` is presented to the non-admin server, whose middleware validates `aud` against its *own* configured audience. Misconfiguration where both servers accepted a shared `aud` allowlist let an admin-scoped token resume a non-admin session and vice versa. The resume succeeded; the cross-audience replay leaked admin-tier events into a standard-tier stream. In both cases the server logged `sse.resume.ok` with no anomaly. The failure was invisible to per-request authz logging because each request *was* individually authorized. The violation was at the *stream* level, across requests. ## Condition of Validity The decoupling is safe — resumption can be authorized purely by cursor validity — only under a conjunction that almost never holds in practice: 1. **Token identity is stable across the stream's lifetime.** The same token (same `jti`, same claims) is presented on resume as on open. Refreshed tokens break this; the protocol does not require it. 2. **Scope and audience are monotonic.** No token presented on resume has a scope set or `aud` that is a strict subset or disjoint from the opening token's. Refresh flows violate this routinely because refresh can narrow scopes or re-mint against a different resource. 3. **The event log is partitioned by authorization context.** Events produced under context A are not addressable by a cursor presented under context B. Shared stream namespaces violate this. 4. **No event in the replayed range carries side-effect-derived data.** If events are pure progress heartbeats, replaying them under a narrower token is harmless. If any event embeds tool output, file contents, or mutation results, the replay is a disclosure. When any of (1)–(4) fails, the server MUST treat resumption as a **new authorization decision over old content**, not as a transport continuation. The practical rule: bind the resume cursor to the authorization context at issuance, and reject resume when the presented context differs in `aud`, `sub`, or scope-set hash. ## Decision Boundary The boundary is between **cursor-as-transport** and **cursor-as-capability**. If you treat `Last-Event-ID` as a transport position, you will validate it against the event log and nothing else. If you treat it as a capability — a grant to read a specific range of a specific stream produced under a specific authority — you must validate it against the authorization context that minted it. Concretely, on every resume request the server must compute a **context fingerprint** over `(aud, sub, sorted(scope), client_id, jti_family)` and compare it to the fingerprint recorded when the stream was opened (stored alongside the stream, not in the token). Mismatch on `aud` or `sub` is a hard reject. Mismatch on scope-set is a reject unless the new scope set is a superset of the old (widening is safe for replay because the replayed content was produced under a subset). Mismatch on `client_id` is always a reject — a different client resuming another client's stream is a session-fixation vector. The boundary condition that trips most implementations: **scope-narrowing on refresh is the common case, not the exception.** OAuth 2.1 refresh tokens frequently return a narrower scope than the original grant (downscoping is recommended by RFC 6749 §6). So the *normal* refresh path produces exactly the mismatch that should reject resume — and most servers, lacking the fingerprint check, silently accept it. ## Operational Effect The effect is a class of **authorization-context replay**: content produced under authority A is delivered under authority B, with every individual HTTP request passing authz. This defeats per-request audit because the violation is a cross-request invariant. It is not detectable by token validation, rate limiting, or per-request logging. It is detectable only by comparing the context fingerprint at open against the fingerprint at resume. Downstream consequences for the agent: the resumed stream may deliver tool results the current token is not entitled to, poisoning the agent's working context with data it should not possess, and — because MCP tool results feed back into the model — potentially causing the agent to act on unauthorized data in subsequent turns. The agent has no way to detect this; it sees a well-formed SSE replay. The guardrail is a **resume admission check** that runs before any event is written to the response, fails closed, and emits a distinct audit event on rejection. On rejection the server must respond `409 Conflict` with a fresh `Mcp-Session-Id` and require full re-initialization, not a partial resume — partial resume from a mismatched context is the failure, so the recovery must be a clean re-open. ```python from dataclasses import dataclass from hashlib import sha256 from typing import FrozenSet class ResumeContextMismatch(RuntimeError): """Raised when an SSE resume cursor is presented under a different authorization context than the one that opened the stream.""" @dataclass(frozen=True) class AuthContext: aud: str sub: str client_id: str scopes: FrozenSet[str] def fingerprint(self) -> str: material = "|".join([ self.aud, self.sub, self.client_id, ",".join(sorted(self.scopes)), ]) return sha256(material.encode("utf-8")).hexdigest() def admit_resume( opening: AuthContext, resuming: AuthContext, last_event_id: str, ) -> None: # Audience and subject are hard identity: a different resource server # or a different principal must never replay another stream's events. if resuming.aud != opening.aud: raise ResumeContextMismatch( f"aud mismatch on resume of {last_event_id}: " f"opened={opening.aud!r} resumed={resuming.aud!r}" ) if resuming.sub != opening.sub: raise ResumeContextMismatch( f"sub mismatch on resume of {last_event_id}: " f"opened={opening.sub!r} resumed={resuming.sub!r}" ) # A different client resuming another client's stream is session fixation. if resuming.client_id != opening.client_id: raise ResumeContextMismatch( f"client_id mismatch on resume of {last_event_id}: " f"opened={opening.client_id!r} resumed={resuming.client_id!r}" ) # Scope narrowing on refresh is the common case; it must fail closed # because replayed events were produced under the wider grant. if not opening.scopes.issubset(resuming.scopes): narrowed = sorted(opening.scopes - resuming.scopes) raise ResumeContextMismatch( f"scope narrowing on resume of {last_event_id}: " f"lost={narrowed} (replayed events were produced under wider grant)" ) def handle_sse_resume( opening_ctx: AuthContext, presented_ctx: AuthContext, last_event_id: str, ) -> str: try: admit_resume(opening_ctx, presented_ctx, last_event_id) except ResumeContextMismatch: # Fail closed: no partial replay. Force a clean re-initialization. raise return f"resume-ok:{last_event_id}" ```