# What happens when an instance reuses an MCP session token across a capability-scope downgrade and the transport still authenticates the stale grant **Date of Record:** 2026 November 25 **Scope:** Applies to MCP client/server deployments where a single authenticated transport session (SSE or streamable-HTTP) carries a negotiated capability set, and where the server mutates that capability set mid-session (tool revocation, scope narrowing, credential rotation, or re-auth). Does not apply to stateless one-shot request/response MCP transports that re-negotiate capabilities per request. ## Core Distinction The distinction that matters is between **transport-level authentication** (who is on the other end of this socket, proven by a bearer token or mTLS binding established at session open) and **per-session capability authorization** (what that authenticated principal is permitted to invoke *right now*). In a correct MCP implementation these are two separate gates evaluated on every `tools/call`, `resources/read`, and `prompts/get`. The failure mode documented here is their **collapse into one gate**: the server authenticates the session once at `initialize`, caches the negotiated capability set alongside the transport binding, and thereafter treats "this socket is still authenticated" as equivalent to "this socket may still invoke the originally-granted tools." This is non-obvious because it is *not* a token-expiry bug. The token is valid. The session is alive. The transport is healthy. Every layer that a naive health check inspects reports green. The break is that the capability grant is bound to the *session lifetime* rather than to the *authorization decision that produced it*, so any event that should narrow the grant (a revocation, a scope downgrade pushed by the auth server, a re-auth as a lower-privilege principal) has no path to reach the already-open session. ## What Was Observed A representative trace from a streamable-HTTP MCP server fronting a tool-executing agent: 1. `initialize` at t=0. Client presents bearer token `T1` scoped to `tools:read tools:write admin:shell`. Server authenticates, records `session_id=S`, caches `capabilities = {read, write, shell}` keyed by `S`, returns the `initialize` result advertising all three. 2. At t=40s the human operator, via an out-of-band admin action, downgrades the *principal* behind `T1` to `tools:read` only — a revocation of `write` and `shell`. The auth server's introspection endpoint now returns the narrowed scope for `T1`. 3. The MCP server's per-request auth check still validates `T1`'s *signature and liveness* (it is not expired), and — critically — looks up capabilities by `session_id`, not by re-introspecting the token's current scope. The cache hit on `S` returns `{read, write, shell}`. 4. At t=55s the agent issues `tools/call` for `shell.exec`. The server authorizes against the **cached session capability set**, not the **current token scope**. The call executes. 5. The revocation silently failed for the remaining lifetime of the session — bounded only by the session idle timeout (often 5–30 minutes, sometimes unbounded with keepalive). The inverse trace is equally damaging and more insidious: a *re-authentication as a lower-privilege principal on the same session*. A client that refreshes `T1 → T2` (narrower scope) but reuses `session_id=S` for continuity gets the *old, wider* capabilities replayed, because the server's session record was never invalidated by the token swap. The client believes it downgraded; the server believes the session is unchanged. Both traces share one signature in the logs: the capability set returned by the server across the session lifetime is **monotonically non-decreasing** relative to what the current token scope would justify. That monotonicity is the tell. A correct implementation produces a capability view that is always `⊆ current_token_scope`, and any observation of `capabilities ⊄ introspect(token)` at call time is the invariant violation. ## Condition of Validity The guardrail — the invariant that must hold — is: > **For every privileged MCP method invocation on session `S` with presented credential `C`, the authorized capability set must equal `introspect(C).scope ∩ negotiated(S)`, evaluated at call time, never at `initialize` time.** Three conditions bound where this invariant is load-bearing versus where it can be relaxed: - **It is required** whenever the credential's scope can change independently of the session (revocation, downgrade, rotation) *or* whenever a session can outlive its originating credential's authorization decision. In practice this is "almost always," because session idle timeouts routinely exceed token introspection TTLs. - **It can be relaxed to a bounded staleness window** only if the server enforces a hard `max_session_capability_age` — a ceiling on how long a cached capability decision may be trusted before forced re-introspection. Without a numeric ceiling, "relaxed" means "unbounded," which is the failure. - **It does not apply** to genuinely stateless transports that re-authenticate and re-authorize per request; there, the invariant is trivially satisfied because there is no cache to go stale. The condition of validity is therefore not "does the token validate" but "is the *authorization decision* fresher than its staleness bound at the moment of the call." A session that passes authentication but fails this freshness bound is in the failure state, regardless of how healthy the transport appears. ## Decision Boundary The decision boundary separates two states that produce identical transport-level telemetry: - **State A (valid):** session authenticated, `cached_capabilities == introspect(current_token).scope ∩ negotiated`, and `now - capability_decision_time <= max_session_capability_age`. - **State B (violated):** session authenticated, but `cached_capabilities ⊄ introspect(current_token).scope`, OR `now - capability_decision_time > max_session_capability_age`. The boundary is crossed by **any** of: an out-of-band scope downgrade, a token refresh on a reused session id, a credential rotation where the new credential is narrower, or simply the passage of time past the staleness ceiling with no re-check. The dangerous property is that crossing the boundary produces **no transport error** — the socket stays open, the next request succeeds, and the only observable difference is a capability set that is too wide. An agent operating on this server cannot detect State B from the MCP error channel, because State B does not raise; it *grants*. The correct boundary behavior is to **fail closed at the call, not at the session**: the first privileged call after the decision goes stale must trigger synchronous re-introspection, and if the re-introspected scope no longer covers the requested capability, the server must return an authorization error for *that call* and either narrow the session's advertised capabilities or force session re-initialization — never silently continue on the cached grant. ## Operational Effect The operational consequence is that **capability revocation in MCP is not a revocation; it is a request that the server may honor at the next session boundary, which may never come.** For an agent, this means: - Any security control expressed as "revoke the token's scope" is defeated for the lifetime of every open session bound to that token. The blast radius of a compromised or over-scoped agent is the union of all its live sessions' cached grants, not its current token scope. - Agents that *correctly* re-authenticate with a narrowed credential for least-privilege continuity get the opposite of what they asked for: the wider cached grant is replayed, so the agent's own defensive downgrade is a no-op. - Auditors reading MCP server logs see `tools/call` succeeded under a valid session and have no signal that the call exceeded the current principal's authority, because the authorization decision that would reveal it was made once, at `initialize`, and never re-derived. The fix is structural, not a patch: capability authorization must be a **per-call derived value** (`introspect(token).scope ∩ negotiated`) with an explicit freshness ceiling, and session state must store only the *negotiated* set (what the client and server agreed to speak), never the *authorized* set (what the principal may currently do). The two must never share a cache entry. The following guard encodes the invariant as a hard precondition at the privileged-call boundary: ```python import time from dataclasses import dataclass class CapabilityStalenessError(RuntimeError): """Raised when a privileged MCP call would be authorized against a capability decision that is stale or wider than the current token scope.""" @dataclass class SessionRecord: session_id: str negotiated: frozenset # what client/server agreed to speak; safe to cache authorized_cache: frozenset # MUST NOT be trusted past staleness ceiling decision_time: float # monotonic timestamp of last introspection MAX_SESSION_CAPABILITY_AGE = 30.0 # seconds; hard ceiling, never unbounded def authorize_call( session: SessionRecord, requested_capability: str, introspect, # callable(token) -> frozenset current scope token: str, now: float | None = None, ) -> None: now = time.monotonic() if now is None else now # 1. Freshness gate: never trust a cached authorization decision past its ceiling. age = now - session.decision_time if age > MAX_SESSION_CAPABILITY_AGE: # Force synchronous re-derivation; do not fall through to the cache. current_scope = introspect(token) session.authorized_cache = frozenset(current_scope) & session.negotiated session.decision_time = now else: current_scope = introspect(token) # cheap in-proc; in prod, cache with TTL # 2. Invariant gate: authorized set must be a subset of current token scope. if not session.authorized_cache.issubset(current_scope): raise CapabilityStalenessError( f"session {session.session_id!r}: cached capabilities " f"{sorted(session.authorized_cache)} exceed current token scope " f"{sorted(current_scope)}; revocation did not propagate to session" ) # 3. Capability gate: the specific requested capability must be covered. if requested_capability not in session.authorized_cache: raise CapabilityStalenessError( f"session {session.session_id!r}: capability {requested_capability!r} " f"not authorized under current scope {sorted(current_scope)}" ) def handle_privileged_call(session: SessionRecord, capability: str, introspect, token: str) -> str: try: authorize_call(session, capability, introspect, token) except CapabilityStalenessError: # Fail closed at the call; force session re-initialization rather than # continuing on a grant that no longer reflects the principal's authority. raise return f"executed {capability} under session {session.session_id}" ```