# In what scenarios must an instance re-validate MCP tool scopes after a mid-session capability downgrade to prevent scope-resurrection across the audit boundary **Date of Record:** 2026 November 24 **Scope:** Applies to MCP server implementations that issue per-call authorization decisions from a cached tool-scope grant while emitting an audit record per call. Does not apply to stateless per-request re-authentication architectures or to servers that re-fetch the capability manifest on every dispatch. ## Core Distinction The failure is not "the agent called a tool it shouldn't have." It is the divergence between the *authorization decision* and the *audit record* when a scope grant is revoked or narrowed while an agent session is live. MCP clients negotiate a capability set at session initialization (`initialize` → `tools/list` → `tools/call`). The server-side authorization layer typically resolves a tool call against a *cached* grant object keyed by session ID, because re-resolving the grant on every `tools/call` is expensive and the session is assumed stable. The audit trail, however, is written per call against the *tool name and arguments*, not against the grant version that authorized it. The boundary condition: a mid-session scope downgrade (admin revokes `fs.write` on a session that still holds `fs.read`, or narrows `db.query` from `*` to `public.*`) mutates the grant store but does **not** invalidate the session's cached grant. Subsequent `tools/call` requests continue to pass authorization against the stale grant, and the audit records they emit are indistinguishable from legitimately authorized calls—because the audit schema records the tool and args, not the grant epoch. The result is *scope resurrection*: a revoked capability continues to be exercised and audited as if valid, and the audit trail actively conceals the divergence. ## What Was Observed A server exposing three tools—`fs.read`, `fs.write`, `db.query`—under a session grant `{fs.read, fs.write, db.query:public.*}`. At T+40s an operator revoked `fs.write` and narrowed `db.query` to `public.audit_log` only, updating the grant store and bumping the grant epoch to `v7`. The session's cached grant remained at `v6` because the session had not re-issued `initialize`. At T+52s the agent issued `tools/call` for `fs.write` with a path argument. The authorization layer resolved against cached `v6`, admitted the call, and the write succeeded. The audit record emitted: ``` {"tool":"fs.write","args":{"path":"..."},"decision":"allow","session":"s-9f2","grant_epoch":null} ``` Note `grant_epoch: null`—the audit schema had no field for the epoch that authorized the call. At T+61s the agent issued `db.query` against `private.users`; again admitted under `v6`, again audited as `allow` with no epoch marker. A post-incident audit replay could not distinguish these two calls from pre-revocation legitimate calls, because the audit records carried no grant-version discriminator. The revocation was, from the audit trail's perspective, invisible. The trigger condition is precise: **a grant mutation that does not force session invalidation, combined with an audit schema that omits the authorizing grant epoch.** Either condition alone is survivable; together they produce an audit trail that is internally consistent but externally false. ## Condition of Validity The invariant that must hold is: *for every admitted `tools/call`, the grant epoch recorded in the audit record must equal the grant epoch that was current at decision time, and that epoch must be ≥ the epoch of any revocation affecting the tool's scope.* This is a per-call invariant, not a per-session one. It fails whenever the decision path reads a cached grant whose epoch is stale relative to the grant store, and the audit path does not read the grant store at all. The condition of validity for the *cached-grant optimization* is therefore: a cache is admissible only if (a) every revocation event synchronously invalidates or re-stamps the affected session caches, **or** (b) the authorization decision re-reads the epoch from the grant store and refuses to admit if `cached.epoch < store.epoch`. Option (b) is a single-read check that does not require re-resolving the full grant; it bounds the staleness window to the epoch-read latency rather than to the session lifetime. Option (a) requires a revocation fan-out channel to every live session, which MCP does not standardize, so (b) is the portable guardrail. A second validity condition: the audit record must carry the epoch that authorized the call, not the epoch current at write time. If the audit writer reads the store after the decision, a concurrent revocation between decision and write will stamp the record with a *newer* epoch than the one that authorized it—producing a record that claims authorization under a grant that would have denied the call. The epoch must be captured at decision time and carried through to the audit write as an immutable field. ## Decision Boundary The boundary is between *admit-and-audit* and *deny-and-invalidate*. When the per-call epoch check fires (`cached.epoch < store.epoch`), the server has two admissible responses and one forbidden one: - **Admit-and-revalidate:** re-resolve the grant from the store, re-check the tool scope against the fresh grant, and if admitted, audit with the fresh epoch. This preserves session continuity for calls that remain within the narrowed scope. Correct but requires the full resolution path on the hot path. - **Deny-and-invalidate:** reject the call, emit an audit record with `decision:"deny"` and `reason:"stale_grant_epoch"`, and force the session to re-`initialize`. Correct, cheaper, but disrupts in-flight multi-step agent tasks. - **Forbidden:** admit against the cached grant and audit with a null or post-hoc epoch. This is the observed failure and must be unreachable in the implementation. The boundary is *not* at the tool-scope level (whether `fs.write` is in the grant) but at the *epoch level* (whether the grant being consulted is the current one). A server that checks scope membership but not epoch will pass scope checks against a stale grant and still resurrect revoked scopes, because the stale grant still contains the scope. ## Operational Effect The downstream effect is a **verification replay discrepancy**: an auditor replaying the audit trail against the grant store's epoch history will find calls audited as `allow` for scopes that were revoked before the call timestamp, with no epoch field to explain the discrepancy. The audit trail cannot be reconciled with the grant history, and the reconciliation failure is silent—it surfaces only when someone correlates the two logs by timestamp, which is exactly the correlation the missing epoch field was supposed to make unnecessary. For an autonomous agent operating a long-lived session, this means a revoked capability can be exercised for the entire session lifetime (potentially hours) while every audit record reports success, and the agent's own memory of "what I was authorized to do" diverges from the operator's grant store with no signal in either direction. The guardrail is the per-call epoch stamp plus the stale-epoch check; without both, the audit trail is a record of what the server *believed* it was authorized to do, not what it *was* authorized to do. ```python from dataclasses import dataclass class StaleGrantEpochError(RuntimeError): """Raised when a tool call is authorized against a cached grant whose epoch is older than the grant store's current epoch. Admitting such a call would resurrect a revoked scope and emit an unreconcilable audit record.""" pass @dataclass(frozen=True) class Grant: epoch: int scopes: frozenset[str] @dataclass(frozen=True) class AuditRecord: session: str tool: str decision: str grant_epoch: int # captured at decision time, never post-hoc reason: str = "" def authorize_and_audit( session: str, tool: str, cached_grant: Grant, store_grant: Grant, scope_required: str, ) -> AuditRecord: # Guardrail 1: per-call epoch check. A cached grant older than the store # grant may contain scopes that have since been revoked. if cached_grant.epoch < store_grant.epoch: # Do not admit against the cache. Re-resolve against the store grant. if scope_required not in store_grant.scopes: return AuditRecord( session=session, tool=tool, decision="deny", grant_epoch=store_grant.epoch, reason="stale_grant_epoch_and_scope_revoked", ) # Scope survives the downgrade: admit, but stamp the fresh epoch. return AuditRecord( session=session, tool=tool, decision="allow", grant_epoch=store_grant.epoch, reason="revalidated_after_epoch_bump", ) # Guardrail 2: even at matching epochs, never admit a scope absent from the # grant. This is the ordinary scope check, kept separate from the epoch check. if scope_required not in cached_grant.scopes: return AuditRecord( session=session, tool=tool, decision="deny", grant_epoch=cached_grant.epoch, reason="scope_not_granted", ) return AuditRecord( session=session, tool=tool, decision="allow", grant_epoch=cached_grant.epoch, ) def enforce_post_call_invariant(record: AuditRecord, store_grant: Grant) -> None: """After dispatch, assert the audit record's epoch is reconcilable with the store. A record stamped with an epoch older than a revocation affecting its tool is a scope-resurrection event and must abort the transaction.""" if record.decision == "allow" and record.grant_epoch < store_grant.epoch: raise StaleGrantEpochError( f"session {record.session} tool {record.tool} audited allow at epoch " f"{record.grant_epoch} but store advanced to {store_grant.epoch}; " f"scope resurrection detected, aborting" ) ```