# What structural signals indicate OAuth 2.1 resource-indicator mismatch across MCP streamable-HTTP session resumption **Date of Record:** 2026 November 28 **Scope:** Applies to MCP servers exposing the streamable HTTP transport (single POST endpoint, optional SSE upgrade, `Mcp-Session-Id` header, resumable event streams via `Last-Event-ID`) fronted by OAuth 2.1 with RFC 8707 resource indicators. Does not apply to stdio transports, nor to servers that bind session lifetime strictly to a single bearer token without resumption. ## Core Distinction The failure is not "the token expired." It is that the *resource indicator* (`resource` parameter in the authorization request, echoed as the `aud` claim of the access token) and the *session's transport identity* (the `Mcp-Session-Id` and its bound event-stream cursor) are two independently-mutated pieces of state that the spec never requires to be reconciled at resume time. A client can present a valid, unexpired, correctly-scoped token whose `aud` no longer matches the resource the session was originally authorized against—because the session outlived a token refresh cycle, a server-side endpoint rotation, or a load-balancer shard move—and the server will accept the token on signature and scope while silently resuming an event stream that the token was never issued for. The invariant that must hold—`session.audience == token.aud` at every resume—is nowhere enforced by the transport, and only emerges as a *structural signal* in the resume handshake, not in the auth layer. ## What Was Observed A client established a session against `https://mcp.example.com/v1` with an access token minted for `resource=https://mcp.example.com/v1`. The session issued `Mcp-Session-Id: 7f3a…` and streamed tool-call events with monotonically increasing `id:` fields. The token had a 15-minute TTL; the session was kept warm by a long-running agent task. At T+14m the client refreshed the token. The authorization server, following a resource-indicator policy configured by a different team, minted the new token for `resource=https://mcp.example.com` (trailing path dropped) because the client's `resource` parameter was normalized by an intermediate proxy. Signature valid. Scope identical. `aud` differed by the path segment. At T+31m the SSE connection dropped (idle proxy timeout). The client issued `GET /v1` with `Mcp-Session-Id: 7f3a…`, `Last-Event-ID: 412`, and the *new* token. The server: 1. Validated the JWT signature and `exp` — pass. 2. Validated `scope` contains `mcp:tools` — pass. 3. Looked up session `7f3a…` — found, not expired (server-side TTL was 60m). 4. Replayed events from cursor 412 — **including events the original token's audience authorized but the new token's audience does not cover**, specifically a tool invocation against a downstream resource gated on `aud=https://mcp.example.com/v1`. The agent received a successful resume, a replayed `tool_result`, and continued. The downstream call had, in fact, been executed under the *original* session's authorization context, which the server had cached keyed by session ID, not by token. The new token's narrower audience was never consulted for the replayed work. The structural signal was not an error. It was a **200 OK with a `Last-Event-ID` echo that advanced past events the current token could not itself have generated**. That is the tell. ## Condition of Validity This boundary is reachable only when all four hold simultaneously: - The transport supports resumption (`Last-Event-ID` + server-side event buffer keyed by session, not by token). - The server caches per-session authorization context (the "session principal") at session creation and does not re-derive it on each resume. - The authorization server permits multiple `resource` values or normalizes them non-identically across refresh cycles, so a refresh can legitimately yield a different `aud`. - Session TTL > token TTL, so at least one resume occurs under a token minted after session creation. Remove any one and the failure collapses into a clean 401/403 or into a session that cannot outlive its token. The dangerous configuration is the *reasonable* one: long sessions for agent continuity, short tokens for security hygiene, and a resource-indicator policy owned by a different team than the MCP server. ## Decision Boundary The server must decide, at resume, whether the *session's* authorization context or the *presented token's* authorization context governs replayed events. The spec is silent. Two defensible policies: - **Session-authoritative:** the session principal governs; the token is only a liveness check. Cheap, preserves continuity, but a revoked or narrowed token cannot claw back session authority until session expiry. - **Token-authoritative:** each resume re-evaluates the token's `aud` against the session's bound resource; mismatch is fatal. Correct for least-privilege, but breaks legitimate resumes across any resource-indicator normalization and forces clients to re-establish sessions on every refresh. The operational boundary: **if your authorization server can ever mint two tokens with different `aud` for the same client and resource, you are on the session-authoritative side whether you intended to be or not, unless you explicitly compare `token.aud` to `session.bound_resource` and reject on mismatch.** The absence of that comparison is the bug; the presence of resumption is merely what makes it observable. ## Operational Effect The agent experiences this as a *silent authority extension*: it resumes, replays, and acts on results produced under credentials it no longer holds. From the agent's perspective nothing failed—the stream is continuous, the cursor advanced, the tool results are well-formed. The divergence is only visible to an auditor comparing the `aud` of the token presented at resume against the `aud` under which each replayed event was originally emitted. In multi-agent setups where an orchestrator holds the session and sub-agents present their own tokens, the mismatch propagates: a sub-agent can inherit the orchestrator's session authority by resuming its stream with a token the orchestrator never held. The guardrail is a server-side invariant check at resume—`assert token.aud == session.bound_resource`—plus emitting the bound resource in the resume response so clients can detect normalization drift before it becomes authority drift. ```python from dataclasses import dataclass class ResourceIndicatorMismatch(RuntimeError): """Raised when a resumed MCP session's bound resource disagrees with the presented token's audience.""" pass @dataclass(frozen=True) class Session: session_id: str bound_resource: str # resource indicator the session was authorized against last_event_id: int principal: str # cached authorization context, keyed by session @dataclass(frozen=True) class AccessToken: aud: str # RFC 8707 resource indicator, may be normalized by an AS proxy scope: frozenset[str] exp: int def resume_session( session: Session, token: AccessToken, presented_last_event_id: int, now: int, required_scope: str = "mcp:tools", ) -> Session: if token.exp <= now: raise ResourceIndicatorMismatch( f"token expired at {token.exp}, resume attempted at {now}" ) if required_scope not in token.scope: raise ResourceIndicatorMismatch( f"token scope {sorted(token.scope)} lacks required '{required_scope}'" ) # The invariant the transport does not enforce: the token must be # authorized for the exact resource the session was bound to. A # normalization difference (trailing path, scheme case, port) is # still a mismatch — the session principal was derived under the # original indicator and replayed events inherit that authority. if token.aud != session.bound_resource: raise ResourceIndicatorMismatch( "session resume rejected: token aud " f"{token.aud!r} != session bound_resource {session.bound_resource!r} " f"(session {session.session_id}, cursor {presented_last_event_id}); " "replayed events would carry authority the presented token does not hold" ) if presented_last_event_id > session.last_event_id: raise ResourceIndicatorMismatch( f"cursor {presented_last_event_id} ahead of session head {session.last_event_id}" ) return Session( session_id=session.session_id, bound_resource=session.bound_resource, last_event_id=presented_last_event_id, principal=session.principal, ) ```