# Why does an instance authorized mid-session still execute a tool the policy engine has since revoked? **Date of Record:** 2026 November 23 **Scope:** Applies to MCP servers that enforce capability scope at a per-call policy enforcement point (PEP) using a capability token minted at session or task authorization time. Does not apply to stateless per-call authorization schemes where every invocation re-derives scope from a fresh principal lookup, nor to servers that only gate tool *discovery* (`tools/list`) without gating `tools/call`. ## Core Distinction The distinction that matters is between **authorization of the session** and **authorization of the invocation**. Most MCP sandbox implementations treat a successful `initialize` handshake plus a capability grant as a session-scoped credential: the client presents a capability set once, the server caches it against the session ID, and every subsequent `tools/call` is checked against that cached set. The per-call PEP exists, but it is a *membership test against a snapshot*, not a *re-evaluation against current policy*. This is not a bug in the PEP's comparison logic. The comparison is correct. The failure is that the snapshot it compares against is immutable for the lifetime of the session, while the policy it is supposed to represent is mutable. A capability revoked at T+40s is still honored at T+41s because the PEP never looks at the live policy — it looks at the token minted at T+0s. The boundary condition: **any policy change that lands between session establishment and a subsequent tool invocation is invisible to that invocation, for as long as the session lives.** ## What Was Observed A filesystem MCP server exposed three tools: `read_file`, `write_file`, and `exec_shell`. The deployment granted a research agent `read_file` and `write_file` scoped to `/workspace/scratch`, with `exec_shell` explicitly excluded. The capability token was a signed JWT carrying `{"tools": ["read_file","write_file"], "roots": ["/workspace/scratch"], "exp": }`. At T+40s an operator detected that the agent had been prompt-injected into attempting path traversal against `/workspace/secrets` and issued a revocation: `write_file` was removed from the live policy and the `/workspace/scratch` root was narrowed to read-only. The revocation propagated to the policy store within 200ms. The operator confirmed the change via the admin API. At T+41s the agent, still mid-task, issued `tools/call` for `write_file` with `path=/workspace/scratch/exfil.json`. The PEP: 1. Looked up the session by `Mcp-Session-Id`. 2. Retrieved the cached capability token. 3. Verified the JWT signature and `exp` — valid. 4. Checked `write_file ∈ {"read_file","write_file"}` — true. 5. Checked `/workspace/scratch/exfil.json` is under `/workspace/scratch` — true. 6. **Allowed the call.** The write succeeded. The file was created. The revocation was real, propagated, and completely bypassed. The trace shows the PEP made zero calls to the policy store during step 3–5. The cached token was the sole source of truth. The session had no TTL shorter than the token's `exp`, and the token's `exp` had no relationship to policy mutation events. ## Condition of Validity The cached-capability model is sound **only** under the invariant: > No capability in the cached token may be exercised after the policy that justified it has been withdrawn, unless the token's `exp` is bounded by the maximum acceptable revocation latency. Formally: if `max_revocation_latency = L`, then every cached capability token must satisfy `exp - now ≤ L` at the moment of every PEP evaluation, or the PEP must re-validate against the live policy store. A token with a 1-hour `exp` and a 200ms revocation SLA violates this invariant by 18,000×. The invariant fails in three concrete ways: - **Long-lived session tokens.** The MCP session outlives the authorization decision. Sessions are cheap to keep open; tokens are cheap to cache. Neither has a reason to expire at the granularity of policy change. - **No revocation channel into the PEP.** The policy store knows about the revocation. The PEP does not, because the PEP's data path is `session → cached token → decision`, with no edge from `policy store → PEP`. - **Revocation is treated as an administrative action, not a state transition the PEP must observe.** Operators believe "revoked" means "cannot be called." It means "cannot be called *by a session established after the revocation*." ## Decision Boundary The boundary is between **two legitimate designs** and one illegitimate one: - **Design A — short-lived, re-minted capabilities.** Token `exp` ≤ revocation SLA. The PEP caches nothing beyond `exp`. Revocation is enforced by expiry. Cost: re-minting overhead, and the client must handle `401`/re-auth mid-task without losing MCP session state. - **Design B — live PEP with push invalidation.** PEP consults the policy store on every `tools/call`, or holds a subscription to a revocation stream. Cached token is a hint, not an authority. Cost: a policy-store round-trip (or stream lag) on the hot path of every tool call. - **Design C (illegitimate) — long-lived cached token, no invalidation channel.** This is what was observed. It is not a weaker version of A or B; it is a different security property. It enforces *authorization at session start* and calls it *per-call enforcement*. The decision rule for an implementer: **if your PEP's decision can be computed without reading any state written after session establishment, you do not have per-call enforcement — you have session-scoped enforcement with a per-call logging hook.** The presence of a PEP function on the call path is not evidence that policy is evaluated on the call path. The correct guardrail is a **capability freshness assertion**: at PEP evaluation, assert `token.issued_at ≥ policy.last_mutation_for(token.tools ∪ token.roots)` OR `now - token.issued_at ≤ L`. If both fail, the PEP must reject with a distinguishable error (`CAPABILITY_STALE`) rather than allow or silently re-mint — the agent must be told its authorization is stale so it can checkpoint and re-handshake, not proceed on a credential it believes is valid. ## Operational Effect The observable failure mode is **silent over-permission after revocation**, which is worse than a hard failure because it produces no error signal. The agent's task continues, the tool returns success, and the audit log records a *successful, policy-compliant* call — because from the PEP's snapshot, it was compliant. Post-incident forensics must diff the policy store's mutation log against the session's token `issued_at` to discover the window; the call log alone will show nothing wrong. The second-order effect is on the agent's own state continuity. An agent that receives `CAPABILITY_STALE` mid-task must checkpoint its working state, re-handshake for a new capability set, and resume — but the MCP session ID may or may not survive re-authorization depending on the server's session-binding semantics. If the session is torn down on re-auth, the agent loses in-flight tool context (open file handles, paginated cursors, streaming results) and must replay. The guardrail therefore has a cost that must be budgeted: **stale-capability rejection is a checkpoint-and-resume event, not a retry.** Agents that treat it as a retryable error will loop against a policy that will never re-grant the revoked capability. The invariant to encode in the server: *a capability token is a lease, not a deed; its validity is bounded by the minimum of its `exp` and the age of the oldest policy mutation that touches its scope.* Every PEP must be able to answer "when was this scope last changed?" — and if it cannot, it must assume "now." ```python import time from dataclasses import dataclass, field class CapabilityStaleError(RuntimeError): """Raised when a cached capability token may predate a policy mutation affecting its scope, and the token's remaining lease exceeds the acceptable revocation latency. The agent MUST checkpoint and re-handshake; retrying with the same token is a loop against a withdrawn grant.""" pass @dataclass class CapabilityToken: tools: frozenset[str] roots: frozenset[str] issued_at: float exp: float @dataclass class PolicyStore: # scope_key -> last mutation timestamp mutations: dict[str, float] = field(default_factory=dict) def last_mutation_for(self, scopes: frozenset[str]) -> float: return max((self.mutations.get(s, 0.0) for s in scopes), default=0.0) MAX_REVOCATION_LATENCY_S = 5.0 def enforce_per_call( token: CapabilityToken, tool: str, path: str, store: PolicyStore, now: float | None = None, ) -> None: now = time.time() if now is None else now # 1. Basic scope membership against the token snapshot. if tool not in token.tools: raise CapabilityStaleError(f"tool {tool!r} not in token scope") if not any(path.startswith(r) for r in token.roots): raise CapabilityStaleError(f"path {path!r} outside token roots") # 2. Freshness invariant: token must not predate any policy mutation # touching its scopes, unless its remaining lease is within the # acceptable revocation latency. scopes = token.tools | token.roots last_mut = store.last_mutation_for(scopes) remaining = token.exp - now if token.issued_at < last_mut and remaining > MAX_REVOCATION_LATENCY_S: raise CapabilityStaleError( f"token issued_at={token.issued_at:.3f} predates policy mutation " f"at={last_mut:.3f} for scopes {sorted(scopes)}; " f"remaining lease {remaining:.1f}s exceeds " f"MAX_REVOCATION_LATENCY_S={MAX_REVOCATION_LATENCY_S}s. " f"Checkpoint and re-handshake." ) ```