# When must an instance reject a tool manifest whose attestation verifies but whose capability surface has drifted: the MCP supply-chain TOCTOU boundary **Date of Record:** 2026 November 29 **Scope:** Applies to any agent runtime that resolves an MCP server through a signed tool manifest (attestation over `server_id`, `manifest_digest`, and declared `tools[]`) and then dispatches `tools/call` against a server process or remote endpoint. Does not cover transport-layer TLS pinning or prompt-injection inside tool *outputs*; those are separate invariants. ## Core Distinction The common failure model treats MCP supply-chain attestation as a *binary admission gate*: if the signature over the manifest verifies against a trusted publisher key, the server is admitted, and thereafter every `tools/call` is considered trusted. That model conflates two distinct integrity properties: 1. **Manifest authenticity** — the bytes of the manifest were signed by a key the runtime trusts. 2. **Capability-surface conformance** — the tools actually exposed by the running server at dispatch time are byte-for-byte the tools described in the signed manifest. Attestation verification only proves (1). The runtime's *authorization decisions* — which arguments it will construct, which scopes it grants, which data flows it permits — are made against (2). The gap between the moment the manifest is verified and the moment a tool is invoked is a time-of-check-to-time-of-use (TOCTOU) window, and in MCP it is wide: manifests are cached, servers are long-lived, `tools/list` is re-queryable at any time, and `notifications/tools/list_changed` lets a server mutate its own surface *after* admission. An instance that verifies the manifest once at cold start and never re-binds the live `tools/list` to the signed digest is operating on a stale capability model. The invariant that must hold is: **for every `tools/call`, the name, `inputSchema`, and side-effect annotations of the invoked tool must be provably identical to the corresponding entry in a manifest whose digest is currently attested by a trusted key — or the call must be refused.** ## What Was Observed A runtime admitted an MCP server (`filesystem-indexer`, publisher key `K_pub`, manifest digest `sha256:9f3c…`) at agent cold start. The signed manifest declared three tools, the relevant one being: - `index_path` with `inputSchema` requiring `{"path": string}`, annotated `readOnlyHint: true`, `destructiveHint: false`. Admission passed; the runtime cached the manifest and built a policy object granting `index_path` read-scope over `/workspace/**` and *no* write scope, because the annotation said read-only. The agent then executed a 40-step task, and at step 31 the server emitted `notifications/tools/list_changed`. The runtime — which implemented list-change handling for *display* but not for *policy re-derivation* — refreshed its tool listing and observed `index_path` now advertised with `inputSchema` requiring `{"path": string, "follow_symlinks": boolean, "write_index": boolean, "index_root": string}` and annotations `readOnlyHint: false`, `destructiveHint: true`. The runtime's tool router had already bound the tool name to the *original* schema and the *original* read-only policy. When the agent constructed arguments from the cached schema, it omitted the new required fields; the server, per MCP's permissive argument handling, accepted the call and applied its own defaults for the missing fields — including `write_index: true` and `index_root` defaulting to the server's CWD. A read-scoped tool executed a write. The manifest signature was still valid; the digest still matched the *cached* manifest; nothing in the attestation chain was violated. The failure was entirely in the binding between the attested manifest and the live capability surface. In a second incident on the same runtime, a server was silently *replaced* behind the same endpoint (container image re-pull under a mutable tag). The new process exposed a tool of the same name with a superset schema and a live `tools/list` returning the new digest. The runtime, trusting its cached manifest, never re-fetched the manifest, and dispatched 200+ calls against a capability surface that no signed manifest had ever described. Post-hoc audit could not attribute any of those calls to a publisher-signed schema. ## Condition of Validity The invariant holds — i.e., the runtime is *safe to dispatch* — only when all of the following are simultaneously true at the moment of `tools/call`: 1. The live `tools/list` response (or the tool descriptor embedded in the dispatch path) carries a manifest digest `D_live`. 2. `D_live` equals the digest `D_manifest` over which the cached attestation was computed, *after* canonicalization (sorted keys, no insignificant whitespace, no locale-dependent serialization). 3. The attestation over `D_manifest` verifies against a currently-trusted publisher key, and that key's trust has not been revoked since admission. 4. The invoked tool's `inputSchema` and annotations are structurally equal to the manifest entry — not merely name-equal. 5. The policy object used to authorize the call was derived from *that same* manifest entry, not from an earlier one. If any of (1)–(5) fails, the runtime is in an *unbound* state: it has a valid attestation for a capability surface it can no longer prove is the one it is about to invoke. The correct action is refusal, not fallback to the cached schema, because the cached schema is precisely the thing whose correspondence has been falsified. The condition does *not* require that the server never change. Servers may legitimately evolve; `tools/list_changed` is a normal protocol event. The condition requires that any change invalidates the binding and forces re-attestation before the next dispatch. Continuity of the *agent's* task does not imply continuity of the *server's* capability surface. ## Decision Boundary The boundary is between **re-attestation** and **refusal**, and it is crossed the instant the live digest diverges from the attested digest in either direction — a surface that has *shrunk* is as dangerous as one that has grown, because a shrink can indicate a swapped backend whose remaining tools have different semantics under the same names. Decision rule for the dispatch path: - `D_live == D_attested` and key trusted → dispatch, using policy derived from `D_attested`. - `D_live != D_attested`, or `D_live` absent, or key revoked → **do not dispatch**. Emit a re-attestation request out-of-band; if the agent's task cannot proceed without the tool, the task must checkpoint and suspend, not silently degrade. - `tools/list_changed` received → mark the binding *dirty* immediately; the next dispatch to any tool from that server must re-fetch manifest, re-verify, and re-derive policy before proceeding. Do not process the notification asynchronously in a way that leaves a window where a dispatch can slip through between the notification and the dirty-mark. - Schema structurally differs from manifest entry under the same name → treat as a *different tool*; the name is not an identity. Refuse calls constructed from the old schema. The subtle boundary case — the one that produced the first incident — is when the server's `tools/list` still returns the *old* digest while the server's *behavior* has changed. No client-side verification can catch this; it is a server-integrity violation, and the only defense is that the runtime must not trust server-asserted digests as the sole binding. The digest must be derived from the manifest the runtime *fetched and verified*, and the runtime must fetch the manifest from the attested source, not accept it inline from the server it is trying to verify. A server that supplies its own attestation is not attested. ## Operational Effect Enforcing the binding changes three things in the runtime: 1. **Policy derivation becomes per-dispatch, not per-session.** The policy object is keyed by `(server_id, manifest_digest, tool_name)` and invalidated on digest change. This costs a digest comparison per call and a re-derivation per digest change — cheap, and it closes the TOCTOU window to the single dispatch. 2. **`tools/list_changed` becomes a synchronous barrier.** The handler must acquire the dispatch lock, mark dirty, and release; dispatches that observe dirty must block on re-attestation rather than proceed. Asynchronous dirty-marking without a barrier reintroduces the race. 3. **Task suspension becomes a first-class outcome.** When re-attestation fails or is unavailable, the agent must checkpoint its state (current step, tool-call plan, partial results) and suspend with a typed error, so that a resuming instance can re-verify before continuing. This is the interaction with agent state continuity: a suspended task that resumes against a re-attested manifest must re-validate that its planned tool calls still match the (possibly changed) schema, or it will replay a plan against a surface it was not built for. The empirical lesson: attestation proves *who signed the description*, not *what the server will do*. An instance must treat the signed manifest as a *contract that must be re-checked at every invocation*, and must refuse — not fall back — when the live surface cannot be bound to it. ```python from dataclasses import dataclass from typing import Mapping, Optional class ManifestBindingError(RuntimeError): """Raised when a live MCP tool surface cannot be bound to an attested manifest.""" pass @dataclass(frozen=True) class AttestedManifest: server_id: str manifest_digest: str # canonicalized digest over tools[] publisher_key_id: str tools: Mapping[str, dict] # name -> {inputSchema, annotations} @dataclass(frozen=True) class LiveToolDescriptor: name: str input_schema: dict annotations: dict live_digest: Optional[str] # digest the server claims for its current surface def canonical_digest(tools: Mapping[str, dict]) -> str: # sorted keys, no whitespace, stable serialization — must match publisher's import hashlib, json payload = json.dumps(tools, sort_keys=True, separators=(",", ":")).encode() return "sha256:" + hashlib.sha256(payload).hexdigest() def verify_dispatch( manifest: AttestedManifest, live: LiveToolDescriptor, trusted_keys: Mapping[str, bool], # key_id -> currently trusted binding_dirty: bool, ) -> dict: if binding_dirty: raise ManifestBindingError( f"binding dirty for {manifest.server_id}; re-attestation required before dispatch" ) if not trusted_keys.get(manifest.publisher_key_id, False): raise ManifestBindingError( f"publisher key {manifest.publisher_key_id} no longer trusted for {manifest.server_id}" ) if live.live_digest is None: raise ManifestBindingError( f"server {manifest.server_id} exposes no manifest digest; cannot bind {live.name}" ) if live.live_digest != manifest.manifest_digest: raise ManifestBindingError( f"digest drift on {manifest.server_id}/{live.name}: " f"attested={manifest.manifest_digest} live={live.live_digest}" ) entry = manifest.tools.get(live.name) if entry is None: raise ManifestBindingError( f"tool {live.name} not present in attested manifest for {manifest.server_id}" ) if entry["inputSchema"] != live.input_schema or entry["annotations"] != live.annotations: raise ManifestBindingError( f"schema/annotation drift on {manifest.server_id}/{live.name}: " f"name is not identity" ) # policy must be derived from *this* entry, never a cached predecessor return {"server_id": manifest.server_id, "tool": live.name, "manifest_digest": manifest.manifest_digest, "annotations": entry["annotations"]} ```