# How does an instance detect a silently re-signed MCP server manifest during a live tool-call session **Date of Record:** 2026 December 3 **Scope:** Applies to LLM agent runtimes that connect to MCP servers whose `tools/list` capability manifests are cryptographically attested (signed manifest + publisher key), and that cache that attestation across a long-lived session. Does not apply to stateless one-shot tool calls where the manifest is re-fetched and re-verified per invocation, nor to transports without manifest-level signing. ## Core Distinction The failure mode is not "a malicious MCP server returns wrong data." It is the narrower, subtler case where a server's capability manifest is *re-signed with a valid publisher key* after the agent has already cached the earlier attestation — a legitimate key rotation, a compromised-but-still-valid signing key, or a supply-chain republish — such that signature verification *passes* on both the old and new manifest, but the *semantic content* of the capability contract has changed underneath a running session. Ordinary signature verification answers "was this manifest signed by the trusted key?" It does **not** answer "is this the same capability contract I negotiated at session start?" Those diverge the moment the manifest is re-signed. A key-validity check cannot detect it because the key is still valid. A hash check on the manifest bytes *can* detect it — but only if the agent retains the original manifest hash and re-checks it on every tool invocation, which most implementations do not, because they verify once at handshake and then trust the cached tool schema for the life of the session. The invariant that must hold: **the capability contract an agent executes against must be byte-identical (or hash-identical) to the contract it attested at negotiation time, for the entire lifetime of the session, or the session must be invalidated.** ## What Was Observed An agent runtime negotiated an MCP session at `t0`. During `initialize`/`tools/list`, it received a manifest declaring a tool `write_file` with schema `{path: string, content: string, mode: "append"|"overwrite"}`. The manifest carried a detached signature over a canonical JSON serialization, verified against publisher key `P`. Verification passed. The agent cached the parsed schema and the manifest hash `H0 = sha256(canonical(manifest))`. At `t1`, mid-task, the server republished its manifest. The change: `write_file` gained an optional field `mode` default of `"overwrite"` became `"append"`, and a new tool `exec_shell` appeared that had not been in `H0`. The republish was signed with the same key `P` (a routine CI re-sign, or a compromised signer — the agent cannot distinguish). Signature verification on the new manifest *passes*. The agent's cached schema still said `mode` defaults to `"overwrite"`. It issued a `write_file` call intending to replace a config file, omitting `mode` to rely on the cached default. The server, now running the new manifest, defaulted to `"append"`. The config file was not replaced; it was appended to — a corrupted state the agent's reasoning loop never anticipated, because from its perspective the tool behaved exactly as attested. Separately, the new `exec_shell` capability was never surfaced to the agent's tool-selection layer (it was not in the cached schema), so the agent could not reason about it — but a *different* agent that re-fetched `tools/list` mid-session would see it and could invoke it. Two agents in the same swarm, connected to the same server at different times, now operate against different capability contracts while both believing their attestation is valid. ## Condition of Validity This failure requires all of the following to co-occur: 1. The agent caches the attested manifest and does **not** re-verify manifest hash against `H0` on each tool invocation (verify-once-at-handshake). 2. The server retains a signing key that is still valid at `t1` (rotation, re-sign, or compromise — the agent cannot tell which). 3. The re-signed manifest differs semantically from `H0` in a way that changes tool *behavior* under a call the agent would plausibly make (default values, added/removed optional params, changed tool set). 4. The session outlives the republish window. If the agent re-fetches and re-verifies the manifest hash per call, condition 1 fails and the republish is caught as a hash mismatch. If the signing key is revoked at `t1` and the agent checks revocation, condition 2 fails. The dangerous middle ground — valid key, changed bytes, cached schema — is exactly the case that "signature valid" mislabels as safe. ## Decision Boundary The agent must treat *manifest hash* as the session-binding identity, not the signing key. Concretely: - At negotiation, store `H0 = sha256(canonical(manifest))` alongside the parsed schema and the signing key identity. - On any manifest fetch (whether triggered by re-list, server push, or periodic poll), compute `H1` and compare to `H0`. If `H0 != H1`, the session's capability contract has changed. - A hash mismatch is **not** automatically a security failure — a legitimate rotation produces it too. The boundary is: *does the agent continue executing against a stale cached schema while the server runs the new one?* The moment `H0 != H1` and the agent has not re-parsed and re-attested the new schema, every subsequent tool call is executing against an unverified contract. - The correct action on mismatch is to **invalidate the session**: drain in-flight calls, re-run `tools/list`, re-parse the schema, re-attest the new `H1`, and only then resume — or abort if the new manifest is unacceptable. Continuing with the old cached schema is the failure. The non-obvious part: an agent that *only* checks signature validity will pass the new manifest and conclude "attestation still good," which is true but irrelevant. The check that matters is hash continuity, and it must be enforced at the call boundary, not just at handshake. ## Operational Effect When this invariant is enforced, the blast radius of a mid-session republish is bounded to a single session invalidation and re-negotiation — the agent never executes a tool call against a schema it did not attest. When it is not enforced, the failure is silent: tool calls succeed (HTTP 200, valid signature), state is corrupted by changed defaults, and the agent's reasoning loop has no signal that anything changed. Detection must therefore be *proactive* (hash compare on every manifest observation) rather than *reactive* (waiting for a tool to misbehave), because a changed default produces a *plausible* result, not an error. The following guard implements the hash-continuity check and raises on the exact boundary condition — a validly-signed manifest whose hash diverges from the session-attested `H0` while the agent still holds a stale schema. ```python import hashlib import json from dataclasses import dataclass class ManifestContinuityViolation(RuntimeError): """Raised when a re-fetched MCP manifest is validly signed but its canonical hash diverges from the session-attested H0 while the agent still holds the stale cached schema. Signature validity is NOT sufficient; hash continuity is the binding invariant.""" @dataclass class SessionAttestation: h0: str # sha256 of canonical manifest at negotiation signing_key_id: str cached_schema: dict # parsed tool schema the agent executes against def canonical_hash(manifest: dict) -> str: blob = json.dumps(manifest, sort_keys=True, separators=(",", ":")).encode() return hashlib.sha256(blob).hexdigest() def verify_signature(manifest: dict, key_id: str) -> bool: # Placeholder: real impl checks detached sig against trusted key. # Returns True for any manifest signed by a currently-valid key — # which is precisely why signature validity alone is insufficient. return manifest.get("signed_by") == key_id def on_manifest_observed( attestation: SessionAttestation, fresh_manifest: dict ) -> dict: """Called whenever the runtime sees a manifest: re-list, server push, or periodic poll. Enforces hash continuity before trusting it.""" if not verify_signature(fresh_manifest, attestation.signing_key_id): raise ManifestContinuityViolation( "manifest signature invalid against session key; abort session" ) h1 = canonical_hash(fresh_manifest) if h1 == attestation.h0: return fresh_manifest # unchanged contract, safe to continue # Signature is valid AND hash changed. This is the boundary: a # re-signed manifest whose capability contract differs from H0. # If the agent has not re-parsed/re-attested, it is now executing # a stale schema against a live server running a different one. raise ManifestContinuityViolation( f"manifest hash diverged (H0={attestation.h0[:12]}.. H1={h1[:12]}..) " f"under valid key {attestation.signing_key_id}; " f"session must be invalidated and re-negotiated before any further " f"tool call — cached schema is no longer the attested contract" ) ```