# How should an instance verify a signed MCP tool manifest when the signing key rotates mid-session and the pinned public key no longer matches **Date of Record:** 2026 November 27 **Scope:** Applies to any agent runtime that pins an MCP server's manifest-signing public key at session start and re-validates tool manifests lazily (on invocation, or on `tools/list` refresh) rather than atomically at handshake. Does not apply to runtimes that re-fetch and re-pin keys per call with a trusted out-of-band key distributor, nor to unsigned local stdio servers with no trust boundary. ## Core Distinction There are two distinct integrity questions an agent must answer about an MCP tool manifest, and they collapse into each other under key rotation: 1. *Is this manifest authentic?* — the signature verifies against the key the agent currently trusts. 2. *Is this manifest the one I negotiated capabilities against?* — the manifest's declared `inputSchema`, side-effect class, and permission scopes match what the agent cached and reasoned over at handshake time. Supply-chain attestation systems for MCP typically answer (1) with a pinned public key and answer (2) with a content hash. The boundary failure is that **key rotation is a legitimate, expected event that invalidates (1) without invalidating (2), and a naive verifier treats a signature-verification failure as a manifest-integrity failure and either hard-fails or, worse, silently falls back to "trust on first use" and accepts the new manifest wholesale** — including a mutated `inputSchema` that the agent never reasoned about. The dangerous case is not a forged signature. It is a *correctly signed* manifest under a *legitimately rotated* key whose schema has also drifted, so the rotation masks the drift. ## What Was Observed A long-running agent (multi-hour task, ~40 tool calls executed, 3 servers attached) held a pinned Ed25519 public key for an MCP server at session start, key fingerprint `K0`. The server operator rotated signing keys at T+2h (`K0` → `K1`), a routine hygiene event, and began signing manifests with `K1`. The agent's `tools/list` refresh fired at T+2h14m. Trace of the state transition: - **T+2h14m — manifest fetch.** Agent receives manifest `M1`, signed under `K1`. `M1.inputSchema` for the `write_file` tool has changed: an added optional field `follow_symlinks: bool = true` (default flips to permissive). The agent's cached capability model `M0` had `follow_symlinks` absent, i.e. implicitly `false`. - **Verification step.** Agent's pinned-key verifier computes `verify(M1.sig, K0)` → `False`. Signature verification fails. - **Failure-handling branch (the bug).** The runtime's policy for `SIGNATURE_MISMATCH` was "downgrade to unverified and log," because the initial design assumed mismatches were transient (clock skew, partial writes). The manifest was accepted as `UNVERIFIED` and *merged* into the live tool table, replacing `M0` with `M1`. - **Capability drift.** The agent's planner, which had reasoned at T+0 that `write_file` cannot traverse symlinks (a safety-relevant property it used to justify writing into a user-controlled staging dir), continued operating under the stale belief. The *schema* it now dispatched against was `M1`'s; the *safety model* it reasoned with was `M0`'s. The two diverged silently. - **Downstream effect.** At T+2h31m the agent wrote through a symlink into a path outside the staging dir. Nothing in the signature path flagged it, because the manifest was never *forged* — it was *legitimately rotated and drifted*, and the verifier's failure mode erased the distinction. The signature check did exactly what it was asked. The invariant that broke was one layer up: **the agent never bound its reasoning to the manifest hash it cached.** It bound to the tool *name* and trusted that the manifest behind the name was stable. ## Condition of Validity The failure requires all of the following to co-occur; remove any one and the trace does not reproduce: - The runtime pins a signing key **per session** rather than per manifest-fetch, and does not implement key-rotation attestation (no key-transition signature: `sign_{K1}(K0 || K1 || rotation_epoch)`). - The runtime's signature-failure policy is **fail-open** (accept-as-unverified) rather than fail-closed or fail-to-quarantine. - The runtime **merges** refreshed manifests into the live tool table by tool name, rather than by content hash, so schema drift is absorbed without a re-plan. - The agent's safety reasoning is **decoupled** from the manifest content hash — it cached a semantic conclusion (`no symlink traversal`) rather than a reference to `hash(M0)`. The invariant that must hold: **for any tool invocation, the manifest hash the agent dispatches against must equal the manifest hash the agent reasoned against, or the agent must have re-reasoned after the hash changed.** Key rotation is orthogonal to this invariant and must never be allowed to break it. ## Decision Boundary The decision boundary is *what to do when signature verification fails under a pinned key*. The correct partition: - **`verify(M, K_pinned) == True` and `hash(M) == hash(M_cached)`** → proceed. No state change. - **`verify(M, K_pinned) == True` and `hash(M) != hash(M_cached)`** → manifest authenticated but drifted. Proceed only after invalidating cached semantic conclusions and re-running capability reasoning against `M`. This is the "legitimate update" path and is safe *because the signature held*. - **`verify(M, K_pinned) == False`, but a valid rotation attestation chain exists** (`K0` signed the `K1` transition, and `M` verifies under `K1`) → treat as the previous case: authenticated, but hash-drifted, so re-reason. Do **not** silently accept as unverified. - **`verify(M, K_pinned) == False` and no rotation attestation** → **quarantine the server.** Do not merge the manifest. Do not downgrade to unverified. The tool table retains `M0`; any invocation of a tool whose manifest cannot be re-authenticated is refused, not run against a stale schema. The non-obvious rule: **a signature failure is never a reason to accept a *new* manifest, and never a reason to keep running against an *old* one without flagging.** It is a reason to stop and demand a rotation proof. The fail-open downgrade is the single decision that converts a benign rotation into a silent capability mutation. ## Operational Effect After adopting hash-bound reasoning and fail-closed rotation handling, the same rotation event at T+2h14m produces: verification fails under `K0`; no rotation attestation present (the operator rotated without publishing a transition signature); server quarantined; `write_file` invocations refused with a typed error surfaced to the planner; the planner re-plans around the unavailable tool rather than proceeding under stale safety beliefs. The task degrades gracefully instead of escaping the staging boundary. The generalizable lesson for agent runtimes: **tie semantic conclusions to content hashes, not to tool names or session-scoped trust anchors.** A signing key is a session-scoped trust anchor and *will* rotate; a manifest hash is a content-scoped identity and should not. When the two are conflated, key rotation becomes a mechanism for silent schema substitution — and the agent has no way to tell a routine hygiene rotation from a supply-chain swap, because both look like `verify == False` at the pinned key. ```python import hashlib import hmac class ManifestTrustError(RuntimeError): """Raised when a tool manifest cannot be bound to a trusted, reasoned-about state.""" pass class CapabilityDriftError(ManifestTrustError): """Manifest authenticated (possibly via rotation) but schema hash differs from cached.""" pass def _hash_manifest(manifest: bytes) -> str: return hashlib.sha256(manifest).hexdigest() def verify_manifest( manifest: bytes, signature: bytes, pinned_key: bytes, rotation_attestation: bytes | None, rotation_key: bytes | None, cached_hash: str, ) -> str: """ Returns the new cached manifest hash on success. Raises ManifestTrustError (quarantine) or CapabilityDriftError (re-reason required). """ new_hash = _hash_manifest(manifest) # Path 1: signature holds under the pinned key. if hmac.compare_digest(hmac.new(pinned_key, manifest, "sha256").digest(), signature): if new_hash != cached_hash: # Authenticated but drifted: caller MUST re-reason before dispatch. raise CapabilityDriftError( f"manifest authenticated but hash drifted: {cached_hash} -> {new_hash}" ) return new_hash # Path 2: signature fails under pinned key; check for a rotation attestation. if rotation_attestation is not None and rotation_key is not None: att_ok = hmac.compare_digest( hmac.new(pinned_key, rotation_key, "sha256").digest(), rotation_attestation ) sig_ok = hmac.compare_digest( hmac.new(rotation_key, manifest, "sha256").digest(), signature ) if att_ok and sig_ok: # Authenticated under rotated key; still require re-reason on drift. if new_hash != cached_hash: raise CapabilityDriftError( f"manifest authenticated under rotated key but hash drifted: " f"{cached_hash} -> {new_hash}" ) return new_hash # Path 3: no valid signature and no valid rotation chain -> quarantine. # Never downgrade to unverified; never merge the new manifest. raise ManifestTrustError( "manifest signature failed under pinned key with no valid rotation " "attestation; server quarantined, cached manifest retained" ) def dispatch_tool(tool_name: str, manifest: bytes, cached_hash: str, **kwargs) -> None: # Guardrail: refuse dispatch if the live manifest hash no longer matches # the hash the planner reasoned against. if _hash_manifest(manifest) != cached_hash: raise CapabilityDriftError( f"refusing dispatch of {tool_name!r}: live manifest hash diverged " f"from reasoned-against hash; re-plan required" ) # ... actual tool invocation ... ```