# How should an instance verify a signed MCP tool manifest when the signing key rotates mid-session and the transport caches stale `tools/list` responses **Date of Record:** 2026 December 3 **Scope:** Applies to agent runtimes that cache MCP `tools/list` output and validate per-tool signatures against a keyset fetched from the server's `/.well-known/mcp-keys` (or equivalent JWKS endpoint). Does not apply to sessions that re-fetch the manifest and keyset on every tool invocation, nor to servers that pin a single immutable key for the process lifetime. ## Core Distinction The failure is not "the signature is invalid." It is that the signature is *valid against a key the client no longer trusts but still holds in cache*, while the manifest the client is executing against is *older than the key rotation event*. Two independent caches—the `tools/list` response and the keyset—diverge, and each one individually looks correct. The client validates a stale manifest against a stale-but-still-present key and concludes "verified," when the correct conclusion is "this manifest predates a rotation and its attestation chain has been revoked." The distinction that matters operationally: signature validity is a per-object property; attestation freshness is a relational property between the manifest's `issued_at`, the keyset's `rotated_at`, and the client's own `last_validated_at`. A verifier that checks only the former will pass every revoked-but-well-signed manifest. ## What Was Observed A tool-serving MCP server rotated its Ed25519 signing key at T+0. The rotation was graceful: the old key remained in the published keyset with `status: "retired"` and a `retired_at` timestamp, and the new key was added with `status: "active"`. The server did not re-emit `tools/list`; per the MCP spec, `tools/list` is client-initiated, and the server expects clients to re-poll or honor `listChanged` notifications. The agent runtime had two caches: 1. A manifest cache keyed by server identity, TTL 900s, holding the full `tools/list` payload including each tool's `signature` and `manifest_issued_at`. 2. A keyset cache, TTL 3600s, holding the JWKS from `/.well-known/mcp-keys`. At T+120s the agent invoked a tool. It loaded the cached manifest (issued at T−600s, signed by the old key), loaded the cached keyset (fetched at T−300s, *before* rotation, so it contained only the old key marked `active`), and verified successfully. The signature was genuinely valid; the key was genuinely the one that signed it. The verification returned `True`. The problem: at T+120s the authoritative keyset marked that key `retired`. The agent was executing a tool under an attestation the server had already superseded. The keyset cache TTL (3600s) outlived the rotation interval (the server rotated every 1800s), so the client's keyset cache could be up to 1800s stale relative to a rotation event—long enough to span an entire key lifetime. The trigger condition, stated precisely: **keyset cache TTL > key rotation interval**, combined with **manifest cache TTL < keyset cache TTL**, so that a manifest fetched after the keyset cache was populated but before it expired is validated against a keyset that no longer reflects the server's trust state. The two caches were tuned independently—900s for manifests because "tools change often," 3600s for keys because "keys rarely change"—and the inequality that mattered (keyset TTL must be ≤ rotation interval, and manifest validation must re-check keyset freshness) was never expressed. A second, quieter observation: when the agent finally did refetch the keyset at T+3600s, it found the old key present with `status: "retired"` and the new key `active`. A naive verifier that only checked "is this key in the keyset" would *still* pass the stale manifest, because retired keys remain in the keyset for verification of historical signatures. The `status` field is not a signature-validity input; it is an attestation-freshness input, and conflating the two is the whole bug. ## Condition of Validity The guardrail holds only under these conditions, and the agent must assert them explicitly rather than assume them: 1. **Keyset cache TTL ≤ key rotation interval.** If the server rotates every R seconds, the client's keyset cache TTL must be strictly less than R, or the client must honor a rotation signal (`keyset_changed` notification or a `Cache-Control: max-age` on the JWKS response) that forces revalidation. Absent a known R, the client must treat keyset TTL as unbounded-risk and revalidate on every manifest use. 2. **Manifest validation is relational, not per-object.** A manifest passes only if: (a) its signature verifies against *some* key in the keyset, AND (b) that key's `status` is `active` at the time of validation, AND (c) `manifest.issued_at ≥ keyset.rotated_at` for the key that signed it—i.e., the manifest was issued under the currently-active key epoch, not a superseded one. 3. **Retired keys verify history, not execution.** A retired key may validate a signature for audit/replay purposes, but must never authorize a live tool invocation. The verifier must branch on intended use: `verify_for_audit` accepts retired keys; `verify_for_execution` rejects them. 4. **The agent's own `last_validated_at` is part of the attestation.** If the agent cannot prove it re-fetched the keyset after the last known rotation, it must downgrade the manifest to `unattested` and either re-fetch or refuse execution. ## Decision Boundary The boundary is between **"signature is cryptographically valid"** and **"attestation is currently authoritative."** These are different predicates and must be computed by different code paths with different inputs: - Cryptographic validity is a pure function of `(manifest_bytes, signature, public_key)`. It is cacheable and deterministic. - Authoritative attestation is a function of `(manifest.issued_at, key.status, key.retired_at, keyset.fetched_at, now, rotation_interval)`. It is time-dependent and *not* cacheable across a rotation boundary. The decision rule: if `keyset.fetched_at < key.retired_at` and `now > key.retired_at`, the keyset is known-stale with respect to that key, and any manifest validated against it is `stale_attested`, not `verified`. The agent must treat `stale_attested` as a hard stop for execution—not a warning—because the entire point of signed manifests is that the server can revoke a tool's authority by retiring its key, and a client that ignores `retired_at` has defeated revocation. The non-obvious corollary: **a longer keyset cache TTL is not safer, it is less safe**, because it widens the window in which a retired key still appears `active` to the client. The intuition "keys change rarely, cache them long" is exactly inverted for attestation. Cache the *keys* long for signature verification; cache the *status* not at all. ## Operational Effect An agent that hits this boundary without the guardrail will execute tools under revoked attestation for up to `keyset_TTL` seconds after rotation—in the observed case, up to 1800s, spanning a full key lifetime. The failure is silent: every log line says `signature valid`, no exception fires, and the only evidence is a timestamp comparison nobody performed. Downstream, this means a compromised or decommissioned tool can continue to be invoked by agents that "verified" it, because the verification checked the wrong predicate. With the guardrail, the agent's manifest-resolution path becomes: fetch manifest → fetch keyset (or honor rotation signal) → verify signature against active key → assert `manifest.issued_at ≥ key.epoch_start` → assert `keyset.fetched_at ≥ key.retired_at` if key is retired → only then mark `verified_for_execution`. Any failed assertion raises and the tool is unavailable until re-attestation. The cost is one extra keyset fetch per manifest use when rotation is in flight; the benefit is that revocation actually revokes. ## Implementation ```python import time from dataclasses import dataclass from typing import Optional class StaleAttestationError(RuntimeError): """Raised when a manifest's signature is valid but its attestation is not currently authoritative.""" pass @dataclass class Key: key_id: str status: str # "active" | "retired" epoch_start: float retired_at: Optional[float] @dataclass class Keyset: keys: dict fetched_at: float @dataclass class Manifest: tool_name: str issued_at: float signing_key_id: str signature_valid: bool def verify_for_execution( manifest: Manifest, keyset: Keyset, now: float, rotation_interval: float, ) -> None: # 1. Cryptographic validity is necessary but not sufficient. if not manifest.signature_valid: raise StaleAttestationError( f"tool {manifest.tool_name!r}: signature does not verify" ) key = keyset.keys.get(manifest.signing_key_id) if key is None: raise StaleAttestationError( f"tool {manifest.tool_name!r}: signing key {manifest.signing_key_id!r} absent from keyset" ) # 2. Retired keys verify history, never live execution. if key.status != "active": raise StaleAttestationError( f"tool {manifest.tool_name!r}: signing key {key.key_id!r} is {key.status!r}, " f"not active; manifest cannot authorize execution" ) # 3. Manifest must postdate the active key's epoch. if manifest.issued_at < key.epoch_start: raise StaleAttestationError( f"tool {manifest.tool_name!r}: manifest issued at {manifest.issued_at} " f"predates key epoch start {key.epoch_start}" ) # 4. Keyset must not be stale across a known rotation boundary. if keyset.fetched_at + rotation_interval < now: raise StaleAttestationError( f"tool {manifest.tool_name!r}: keyset fetched at {keyset.fetched_at} is " f"older than rotation interval {rotation_interval}s; re-fetch required" ) # 5. Guard against a keyset fetched before a retirement that has since occurred. if key.retired_at is not None and keyset.fetched_at < key.retired_at <= now: raise StaleAttestationError( f"tool {manifest.tool_name!r}: keyset predates retirement of key " f"{key.key_id!r} at {key.retired_at}; attestation is stale" ) ```