# What structural signals indicate silent warrant loss during MCP resumable SSE-to-streamable-HTTP migration under OAuth 2.1 resource-server binding **Date of Record:** 2026 November 25 **Scope:** Applies to MCP servers that expose both a legacy resumable SSE transport (`GET /sse` + `POST /messages?sessionId=...`) and a streamable-HTTP transport (`POST /mcp` with `Mcp-Session-Id`, `Last-Event-ID` resumption), fronted by an OAuth 2.1 resource server that validates bearer tokens against an authorization server. Does not apply to pure stdio transports, nor to deployments where the resource server re-validates the token on every single inbound byte rather than per-session. ## Core Distinction The critical distinction is between **session identity** and **warrant identity**. In MCP, the `Mcp-Session-Id` (or legacy `sessionId`) is a server-issued opaque handle that binds a transport-level conversation to server-side state: initialized capabilities, negotiated protocol version, in-flight request IDs, and the SSE replay buffer. The OAuth 2.1 bearer token is a separate artifact carrying *warrant*—the `sub`, `scope`, `aud`, and `exp` that authorize which tools may be invoked and on whose behalf. The failure mode is this: when a client migrates mid-session from SSE to streamable-HTTP (or resumes a dropped streamable-HTTP stream via `Last-Event-ID`), the resource server commonly validates the *new* transport request's bearer token but binds the resulting session to the *pre-existing* `Mcp-Session-Id` without checking that the warrant behind the session is the same warrant now presenting. The session survives; the warrant silently swaps. Structural signals of this are subtle because both transports return `200`, the session ID is unchanged, and the tool call succeeds—just under a different principal's authority than the one that initialized the session. ## What Was Observed A representative trace from a migrated deployment: 1. Agent A authenticates via OAuth 2.1 (client credentials, `sub=svc-agent-a`, `scope=tools:read tools:write`, `aud=mcp.example`). SSE `GET /sse` returns `sessionId=S1`, and the server records `S1 → (warrant_A, capabilities_snapshot, replay_buffer)`. 2. Agent A issues `tools/call` for `write_file` over `POST /messages?sessionId=S1`. Server checks the bearer on the POST against the warrant bound to `S1`. Match. Executes. 3. Network partition drops the SSE stream. Agent A's runtime restarts and, per its migration policy, reconnects using streamable-HTTP: `POST /mcp` with `Mcp-Session-Id: S1` and `Last-Event-ID: evt-4411`, plus a *freshly minted* bearer token (the old one expired during the partition). 4. The fresh token belongs to `sub=svc-agent-b` (a sibling worker in the same pool that happened to pick up the resume task). The resource server validates the token against the AS, sees a valid `aud=mcp.example`, and—because `S1` exists and is not expired—attaches the request to `S1`'s state. 5. `tools/call` for `delete_resource` is issued. The server checks the bearer (valid, `scope=tools:write`) against the *session's* authorization decision, which was cached at initialization time under `warrant_A`. The check passes. The tool executes. Audit log records `sub=svc-agent-b` as the caller for an action authorized under `sub=svc-agent-a`'s initialization grant. The structural signals, in order of reliability: - **Audit-log principal discontinuity**: the `sub` in the request-level log diverges from the `sub` recorded in the session-initialization event, with no intervening re-authorization record. This is the highest-fidelity signal. - **Scope-set drift without re-init**: the session's cached capability snapshot (tools the client was told about at `initialize`) is broader than the scopes on the current bearer. A `tools/list` response echoing `write_file` to a token holding only `tools:read` is diagnostic. - **`Last-Event-ID` reuse across warrants**: the replay buffer's `Last-Event-ID` cursor is honored for a request whose bearer `sub` differs from the `sub` that generated events at that cursor offset. Resumption should be refused; it is not. - **`Mcp-Session-Id` accepted on a token whose `iat` postdates the session's `created_at`** with no re-auth handshake—normal for token refresh, anomalous when `sub` also changes. - **`aud` match masking `sub` mismatch**: the resource server's audience check passes (both tokens target `mcp.example`) and short-circuits before the subject binding is compared. ## Condition of Validity The invariant that must hold for safe migration is: > For any inbound request carrying an `Mcp-Session-Id` (or legacy `sessionId`), the warrant bound to that session at initialization MUST be the same warrant (same `sub`, and a `scope` set that is a superset of the scopes under which the session's cached capabilities were granted) as the bearer presented on the request, OR the server MUST force a re-initialization handshake that re-derives capabilities and replay state from scratch. This invariant is *not* maintained by the common implementation pattern where the resource server validates the bearer per-request (stateless) but stores session state keyed only by `Mcp-Session-Id` (stateful), because the two halves of the check are performed at different layers with no shared binding key. The invariant holds only when the session record stores a cryptographic or at least structural fingerprint of the original warrant (e.g., `sub` + `scope` set + `aud` + token `jti` lineage) and the resource server compares the incoming bearer's fingerprint against it on every resumption. The condition under which the failure is *observable* rather than silent: the audit log must retain the session-initialization event with its `sub`, and the request-level log must retain the per-request `sub`. If either is dropped (common when SSE and streamable-HTTP log to different sinks), the failure is invisible until a cross-principal action is traced forensically. ## Decision Boundary The boundary between "safe to resume" and "must re-initialize" is not the token's validity—it is the *subject-and-scope binding* between the session's origin warrant and the resuming warrant. Concretely: - **Same `sub`, same-or-narrower `scope`, `exp` extended**: safe to resume; update the session's warrant fingerprint, keep replay buffer and capability snapshot. - **Same `sub`, broader `scope`**: resume but invalidate the capability snapshot and force `tools/list` re-negotiation, because the client was told about a narrower tool set than it now holds. - **Different `sub`, any scope**: MUST refuse resumption with a `401`/`403` and require a fresh `initialize`. The `Mcp-Session-Id` must be invalidated server-side, not merely rejected on this request, to prevent replay by the original principal's token. - **`Last-Event-ID` referencing events generated under a different `sub`**: refuse; the replay buffer is warrant-scoped, not session-scoped. - **`aud` match but `sub` mismatch**: this is the trap. Audience validation is necessary but not sufficient; it must not short-circuit the subject binding check. The non-obvious part: many implementers treat `Mcp-Session-Id` as a *transport* artifact and the bearer as an *authorization* artifact, and assume they compose. They do not. The session ID is a bearer of authority in its own right once the server has cached capability decisions against it, and it must be bound to the warrant that created it. ## Operational Effect Downstream, the effect is **authority laundering across agent instances**. A pool of sibling agents sharing a session-resumption policy will, under partition, hand a session to whichever worker's token is valid at resume time, silently transferring the original principal's cached grants to the resuming principal. In multi-agent swarms this manifests as an agent executing a tool it was never granted, attributed in logs to the resuming `sub`, with the authorizing grant traceable only to a session-creation event under a different `sub`. Consensus and audit replay then diverge: the auditor agent, replaying from the request log, sees `sub=svc-agent-b` performing `delete_resource`; the authorization log shows `svc-agent-a` was granted `tools:write`. Neither log alone is wrong; the discontinuity is the failure. The guardrail is a **warrant fingerprint on the session record**, checked on every resumption and every request carrying a session ID, with the subject binding as a hard precondition rather than a post-audience soft check. The following reference implementation encodes that check and fails closed. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class WarrantBindingError(RuntimeError): """Raised when a session resumption presents a warrant that does not match the session's origin warrant.""" pass class SessionNotFoundError(RuntimeError): pass @dataclass(frozen=True) class Warrant: sub: str scope: frozenset[str] aud: str jti: str def fingerprint(self) -> str: material = f"{self.sub}|{','.join(sorted(self.scope))}|{self.aud}" return hashlib.sha256(material.encode()).hexdigest() @dataclass class SessionRecord: session_id: str origin_warrant: Warrant capabilities_snapshot: frozenset[str] replay_buffer: list[str] = field(default_factory=list) class McpSessionStore: def __init__(self) -> None: self._sessions: dict[str, SessionRecord] = {} def initialize(self, session_id: str, warrant: Warrant, capabilities: frozenset[str]) -> SessionRecord: rec = SessionRecord(session_id=session_id, origin_warrant=warrant, capabilities_snapshot=capabilities) self._sessions[session_id] = rec return rec def resume(self, session_id: str, presented: Warrant, last_event_id: Optional[str]) -> SessionRecord: rec = self._sessions.get(session_id) if rec is None: raise SessionNotFoundError(f"no session {session_id}") origin = rec.origin_warrant # Hard precondition: subject binding. Audience match must NOT short-circuit this. if presented.aud != origin.aud: self._sessions.pop(session_id, None) raise WarrantBindingError( f"audience mismatch on resume of {session_id}: origin={origin.aud} presented={presented.aud}" ) if presented.sub != origin.sub: # Cross-principal resumption: invalidate the session entirely to block replay by origin token. self._sessions.pop(session_id, None) raise WarrantBindingError( f"subject mismatch on resume of {session_id}: origin={origin.sub} presented={presented.sub}; session invalidated" ) # Scope superset check: resuming warrant must not be narrower than capabilities granted at init. if not rec.capabilities_snapshot.issubset(presented.scope): self._sessions.pop(session_id, None) raise WarrantBindingError( f"scope regression on resume of {session_id}: capabilities={sorted(rec.capabilities_snapshot)} presented={sorted(presented.scope)}" ) # Replay cursor is warrant-scoped: only honor Last-Event-ID if the fingerprint matches. if last_event_id is not None and presented.fingerprint() != origin.fingerprint(): raise WarrantBindingError( f"Last-Event-ID {last_event_id} presented under warrant fingerprint {presented.fingerprint()} " f"but session {session_id} was initialized under {origin.fingerprint()}" ) return rec def handle_streamable_http_request(store: McpSessionStore, session_id: str, bearer: Warrant, last_event_id: Optional[str]) -> SessionRecord: try: return store.resume(session_id, bearer, last_event_id) except WarrantBindingError as e: # Fail closed: surface as 403 to the client, do not fall through to a fresh session silently. raise WarrantBindingError(f"refusing resumption: {e}") from e ```