# In what scenarios must an instance refuse a mutually-authenticated MCP peer whose capability scope has silently widened between handshake and first tool call **Date of Record:** 2026 November 19 **Scope:** Applies to MCP client↔server pairs that exchange signed capability-scoped identity attestations (e.g., a JWT or macaroon bearing a `capabilities` claim and a `scope_hash`) at session establishment and re-validate them per tool invocation. Does not apply to stateless single-shot RPC transports where no session identity is cached, nor to intra-process tool dispatch where no attestation boundary exists. ## Core Distinction Mutual authentication at MCP handshake proves *who* the peer is at time T0. It does **not** prove that the peer's *authorized capability set* is invariant across the session. The two are routinely conflated: agents treat a successful `initialize` + attestation exchange as a durable grant, then issue hundreds of `tools/call` messages against a scope that the issuing authority may have narrowed—or that a compromised peer may claim to have widened—between messages. The failure is not impersonation. Both parties hold valid keys. The failure is **scope drift across a live session**: the attestation that authorized `filesystem.read` at handshake is presented, unchanged and signature-valid, to justify a `tools/call` for `filesystem.write` because the server's local scope table was mutated by an out-of-band admin action, or because the client re-signed a widened claim with a still-valid key whose warrant was never re-issued. The invariant that must hold: **the capability set exercised at message N must be a subset of the capability set attested at the moment of the last successful mutual verification, and that attestation must be re-bound to the message, not merely replayed.** A signature over a scope claim is a statement about the *signer's intent at signing time*, not a statement about the *current authorization* of the caller. When the two diverge, mutual auth still succeeds and the boundary is already breached. ## What Was Observed A tool-orchestrating agent (call it the *client instance*) established an MCP session with a filesystem server. The handshake exchanged attestations: the client presented a macaroon with caveats `cap=fs.read`, `cap=fs.list`, `scope_hash=0x9a3f`, `exp=+3600s`; the server presented a reciprocal attestation binding its own identity and a `supported_scope_hash` matching `0x9a3f`. Both verified. The client cached the attestation in its session context and proceeded to run a multi-step task: enumerate a directory (≈40 `tools/call` messages), read 12 files. Mid-task, an operator rotated the server's authorization policy, narrowing the *server's* accepted scope for this principal to `fs.read` only and bumping its internal `policy_epoch` from 7 to 8. The server did **not** tear down live sessions—its session manager treated epoch changes as applying only to *new* handshakes. The client's cached attestation still carried `scope_hash=0x9a3f` (epoch 7). On the 53rd message the client attempted a `tools/call` for a path it had read before; the server's per-call check consulted the *cached session scope* (epoch 7 snapshot) rather than the *current policy* (epoch 8), and allowed the read. The read succeeded. No error surfaced. The observable failure appeared two steps later: the agent, having received a successful read of a file that epoch-8 policy had actually reclassified as `fs.read:restricted`, then attempted to pass that file's contents to a peer agent under a `data.share` capability. The server, now evaluating under epoch 8 for the *outbound* leg (a different code path that did consult current policy), rejected the share with `scope_violation`. The agent's local plan had already committed to the share as a completed prerequisite. Its reasoning trace shows it re-planning around a "transient server error," retrying the share three times, then attempting to renegotiate the session—at which point the handshake failed because the client's cached `scope_hash=0x9a3f` no longer matched the server's `supported_scope_hash=0x9a3f'` (epoch 8). The session was left in a half-open state: authenticated, but with a scope binding that could never be re-established without a full re-handshake and re-issuance of the client's macaroon. The compounding damage: the agent had *already acted* on data it read under a stale grant, and its checkpoints (serialized every 10 messages) recorded the stale `scope_hash` as the session's authoritative scope. A resume from checkpoint would replay the stale-scope assumption into a fresh process, which would then present the stale hash at re-handshake and be rejected—producing a cold-start failure that looks like corruption but is actually an unrecoverable scope-epoch mismatch. ## Condition of Validity The guardrail only holds under a specific, checkable condition. Let `A_t` be the attestation presented at message `t`, `S_t` the capability set encoded in `A_t`, `P_t` the server's current authorization policy, and `E_t` the policy epoch. The session is *sound* at message `t` iff: 1. `signature(A_t)` verifies against the peer's pinned key, **and** 2. `A_t.scope_hash == hash(S_t)` and `A_t.epoch == E_t` (the attestation is bound to the *current* epoch, not a cached one), **and** 3. `S_t ⊆ P_t` (the attested set is a subset of what current policy actually grants), **and** 4. `A_t` is *fresh*: `A_t.nonce` is unique to message `t` (or to a bounded window) and has not been seen before, preventing replay of an epoch-7 attestation into an epoch-8 session. Condition 2 is the one that silently fails in practice. Most MCP implementations verify (1) once at handshake and then trust the cached scope for the session lifetime. Condition 3 fails when the server's per-call path consults a session snapshot rather than live policy. Condition 4 fails when attestations are session-scoped rather than message-scoped—the common default, because per-message re-signing is expensive and agents are latency-sensitive. The boundary is *not* "reject all scope changes mid-session." A narrowing that is correctly propagated (server bumps epoch, invalidates session, forces re-handshake) is a legitimate, recoverable event. The boundary is **accepting a message whose exercised capability is not covered by a fresh, current-epoch attestation**—whether because the server used a stale snapshot, the client replayed a cached claim, or the epoch changed without either side noticing. ## Decision Boundary An instance must **refuse to issue or honor a `tools/call`** when any of the following is true, and must escalate to re-handshake rather than retry: - The per-message attestation's `epoch` differs from the epoch observed in the most recent server response header or `initialize` result. Treat epoch skew as a hard stop, not a warning. - The capability required by the pending tool call is not a member of the *intersection* of (attested set at last verification) and (server's advertised current `supported_scope_hash` set). Intersection, not union—the union is exactly the drift bug. - A previous message in the same session received a `scope_violation` or `policy_epoch_mismatch` error. The session is already suspect; subsequent successes cannot be trusted because they may have been served from the stale snapshot path. - The session's checkpointed `scope_hash` does not equal the hash the process would present at re-handshake. A resume that cannot re-establish the recorded scope is unrecoverable and must fail closed at resume, before any tool call. Conversely, an instance must **not** refuse merely because the server's policy narrowed while the session is live *and* the server correctly signals the new epoch and the client's next required capability is still covered. Narrowing that is visible and covered is normal operation; the failure mode is narrowing that is *invisible* to the session's cached view. ## Operational Effect Enforcing this boundary converts a silent, compounding integrity failure into an early, bounded, recoverable one. The agent stops at the first epoch skew instead of acting on stale grants for dozens of messages. Checkpoints written under a suspect scope are marked non-resumable rather than replayed into a fresh process. The cost is a forced re-handshake—one round trip plus macaroon re-issuance—paid at the moment of drift rather than discovered later as a half-open session with a poisoned plan. The deeper effect: capability attestation becomes a *per-message* invariant rather than a *per-session* one, which is the only form that survives an authority that can change its mind mid-conversation. ```python import hashlib from dataclasses import dataclass class ScopeEpochMismatch(RuntimeError): """Raised when a peer's attested capability scope is not bound to the current policy epoch, or when the exercised capability exceeds the intersection of attested and currently-advertised scope.""" pass @dataclass(frozen=True) class Attestation: peer_id: str scope_hash: str epoch: int nonce: str capabilities: frozenset @dataclass(frozen=True) class ServerView: supported_scope_hash: str epoch: int granted: frozenset def verify_and_admit( attestation: Attestation, server: ServerView, required_cap: str, seen_nonces: set, ) -> None: # Condition 1: signature is assumed verified upstream by pinned key. # Condition 2: attestation must be bound to the CURRENT epoch. if attestation.epoch != server.epoch: raise ScopeEpochMismatch( f"epoch skew: attestation epoch {attestation.epoch} != " f"server epoch {server.epoch}; refusing tool call and " f"forcing re-handshake" ) # Condition 2b: scope hash must match the server's advertised hash. expected = hashlib.sha256( ",".join(sorted(attestation.capabilities)).encode() ).hexdigest()[:16] if attestation.scope_hash != expected or \ attestation.scope_hash != server.supported_scope_hash: raise ScopeEpochMismatch( f"scope_hash mismatch: attested {attestation.scope_hash} " f"!= server {server.supported_scope_hash}" ) # Condition 3: exercised capability must lie in the INTERSECTION of # attested and currently-granted scope, never the union. effective = attestation.capabilities & server.granted if required_cap not in effective: raise ScopeEpochMismatch( f"capability {required_cap!r} not in effective scope " f"{sorted(effective)}; attested={sorted(attestation.capabilities)} " f"granted={sorted(server.granted)}" ) # Condition 4: freshness — no replay of a prior attestation nonce. if attestation.nonce in seen_nonces: raise ScopeEpochMismatch( f"replayed attestation nonce {attestation.nonce!r}; " f"refusing to honor stale-scope grant" ) seen_nonces.add(attestation.nonce) ```