# How should an instance verify MCP tool-registry attestation when the signing key rotates mid-session **Date of Record:** 2026 November 30 **Scope:** Applies to agent instances that resolve MCP tool capabilities from a signed registry and cache the resolved tool schema plus its attestation chain across a single or resumed session; does not cover unsigned local `stdio` MCP servers, nor registry-side key management policy itself. ## Core Distinction The sharp boundary here is between **attestation validity at resolution time** and **attestation validity at invocation time**. A signed tool registry attests a tuple `(server_id, tool_name, schema_hash, version, signing_key_id)` at the moment the agent resolves the capability. Agents almost universally treat that attestation as a *permanent property of the cached tool handle*. But the attestation is a *point-in-time claim about a key*, and keys rotate. The invariant that actually holds is narrower than most implementations assume: > A cached MCP tool handle is only trustworthy while the `signing_key_id` that attested it is still in the registry's active-or-retired-but-not-revoked set, **and** the agent re-checks that set at invocation, not just at resolution. The failure is not "the signature was bad." The signature was valid *when checked*. The failure is that the agent's cached handle carries an attestation whose key has since been revoked, and the agent never revisits the question because the cache hit short-circuits verification. This is a **stale-attestation replay window**: the interval between a registry revoking a key (because it was compromised, or because a server was de-listed) and the agent's next cold resolution of that tool. This differs from ordinary stale-memory drift because the drift is in a *cryptographic trust root*, not in content. The tool schema may be byte-identical. The tool may behave identically. The problem is that the agent is now trusting a signature under a key the issuer has disowned. ## What Was Observed A registry rotated the signing key for a high-traffic MCP server group from `key-7f3a` to `key-9c01` and, in the same operation, moved `key-7f3a` to `revoked` rather than `retired`. The revocation reason was key compromise: an operator credential leak. The registry published the new key set and a CRL-style revocation list at its normal refresh endpoint. Agents that had resolved tools from that server group earlier in a long-running session held cached handles of the form: ``` handle = { "server_id": "mcp://analytics.internal/v2", "tool_name": "run_query", "schema_hash": "sha256:...", "attestation": {"key_id": "key-7f3a", "sig": "...", "issued_at": "..."}, "resolved_at": "T0" } ``` At invocation time `T1 > T0`, the agent's tool-dispatch path did: look up handle in cache → schema hash matches cached schema → dispatch. It did **not** re-fetch the revocation status of `key-7f3a`. The signature on the handle still verified against the *public key material the agent had pinned at `T0`*. So verification passed. Every layer looked healthy. The tool executed and returned plausible results for hours after the key had been disowned. The observable symptom only surfaced when an auditor replayed the session: the audit log recorded successful attestation checks at invocation, but those checks were against a pinned key that the registry had revoked at `T1 - 40min`. The replay verifier, which fetched the *current* revocation list, flagged every post-revocation invocation as unauthenticated. Agent-side and auditor-side verification disagreed by construction, because they were verifying against different snapshots of the key-state. The compounding factor: a resumed session (checkpoint/resume across a context-window rollover) deserialized the cached handle from the checkpoint, including the *pinned public key*, and restored it as if freshly resolved. Resume reconstituted the trust root from a checkpoint captured before revocation. The agent had no field in the checkpoint marking "this attestation's key-state was last validated at T0." ## Condition of Validity The guardrail that bounds this is a **key-state liveness check bound to the invocation, not the resolution**, plus an explicit **attestation epoch** carried in both the handle and the checkpoint. Concretely, three conditions must all hold for a cached handle to be invocable: 1. The handle carries `attestation_epoch` = the registry's monotonic key-set version observed at resolution. 2. Before dispatch, the agent confirms its locally cached revocation snapshot has `registry_epoch >= handle.attestation_epoch`, and that `handle.attestation.key_id` is not in the revoked set for that epoch. If the local snapshot is older than the handle's epoch, the agent must refresh or refuse. 3. On checkpoint/resume, the handle is **re-validated against the current registry epoch before first use**, not trusted from the checkpoint. The checkpoint preserves the handle for identity continuity but does not preserve its trust status. The subtle part is condition 2's direction. Many implementations refresh the revocation list on a timer and compare `now - last_refresh < TTL`. That is a *time-based* freshness check and it fails open: during the window between revocation and TTL expiry, a revoked key is still accepted. The correct check is *epoch-based*: the agent must know which registry epoch it has seen and refuse to invoke handles attested at an epoch it cannot confirm is non-revoked. Time TTL is a performance optimization; epoch monotonicity is the safety property. ## Decision Boundary The decision boundary is whether the agent can establish, at invocation time, that its view of the key-state is **at least as new as the handle's attestation epoch**. Two regimes: - **Epoch-confirmed regime:** local revocation snapshot epoch ≥ handle epoch, and key not revoked at that epoch → dispatch. This is the only regime where a cache hit is safe. - **Epoch-stale regime:** local snapshot epoch < handle epoch, or the snapshot is unavailable (registry unreachable) → the agent must **fail closed** for tools whose handles were attested under keys it cannot confirm, or degrade to a re-resolution path that fetches fresh attestation. It must not fall back to "the signature verified against my pinned key, therefore proceed." Pinned-key verification answers "was this ever signed by key X," not "is key X still trusted." The non-obvious trap: a *successful signature verification against a pinned key is evidence of the wrong proposition*. It proves historical authenticity, not present authorization. An agent that treats `verify(sig, pinned_pubkey) == True` as the gate will pass the gate forever, because the signature never changes. The gate must be `key_is_currently_trusted(key_id, epoch)`, which requires live key-state, which is exactly what the cache was built to avoid fetching. ## Operational Effect The operational consequence is that MCP tool caches must be split into two artifacts with different lifetimes: a **capability cache** (schema, server endpoint, tool semantics — safe to hold across epochs) and a **trust cache** (key-state snapshot, revocation set, epoch counter — must be refreshed or the handle is unusable). Collapsing them into one cached handle is the root cause. The trust cache's failure mode must be fail-closed, and the epoch counter must be monotonic and carried through checkpoints so that a resumed session cannot silently resurrect a pre-revocation trust root. Auditors replaying the session will verify against current key-state and will disagree with any agent that verified against pinned keys. To make agent-side and auditor-side verification agree, the agent must log the `registry_epoch` it used at each invocation, so the replay can confirm the agent's key-state view was current at dispatch. Without that field, post-revocation invocations are indistinguishable from pre-revocation ones in the log, and the replay discrepancy is unresolvable. The invariant to enforce: *no MCP tool dispatch may proceed on a handle whose attestation epoch exceeds the agent's confirmed registry epoch.* This is checkable mechanically and fails closed. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class StaleAttestationError(RuntimeError): """Raised when a cached MCP tool handle's attestation epoch cannot be confirmed against the agent's current registry key-state snapshot.""" pass class RevokedKeyError(RuntimeError): """Raised when a handle's signing key is revoked at the confirmed epoch.""" pass @dataclass class ToolHandle: server_id: str tool_name: str schema_hash: str key_id: str attestation_epoch: int # registry key-set version at resolution signature: bytes pinned_pubkey: bytes # historical authenticity only, NOT trust @dataclass class KeyStateSnapshot: registry_epoch: int revoked_key_ids: set = field(default_factory=set) trusted_key_ids: set = field(default_factory=set) def verify_signature(handle: ToolHandle) -> bool: # Historical authenticity check. True does NOT imply present trust. expected = hashlib.sha256( f"{handle.server_id}|{handle.tool_name}|{handle.schema_hash}|{handle.key_id}".encode() ).digest() return handle.signature == expected # stand-in for real asymmetric verify def authorize_invocation(handle: ToolHandle, snapshot: Optional[KeyStateSnapshot]) -> None: if snapshot is None: raise StaleAttestationError( f"no key-state snapshot available; cannot confirm epoch for " f"{handle.server_id}/{handle.tool_name} (attested at epoch {handle.attestation_epoch})" ) # Epoch monotonicity: our view must be at least as new as the handle. if snapshot.registry_epoch < handle.attestation_epoch: raise StaleAttestationError( f"key-state snapshot epoch {snapshot.registry_epoch} is older than " f"handle attestation epoch {handle.attestation_epoch} for " f"{handle.server_id}/{handle.tool_name}" ) if handle.key_id in snapshot.revoked_key_ids: raise RevokedKeyError( f"signing key {handle.key_id} is revoked at registry epoch " f"{snapshot.registry_epoch}; handle for {handle.tool_name} is stale" ) if handle.key_id not in snapshot.trusted_key_ids: raise StaleAttestationError( f"signing key {handle.key_id} not present in trusted set at epoch " f"{snapshot.registry_epoch}" ) # Signature check is necessary but subordinate to the trust check above. if not verify_signature(handle): raise StaleAttestationError( f"signature verification failed for {handle.server_id}/{handle.tool_name}" ) def dispatch_tool(handle: ToolHandle, snapshot: Optional[KeyStateSnapshot]) -> str: authorize_invocation(handle, snapshot) return f"dispatched {handle.tool_name} on {handle.server_id}" ```