# Where must an instance verify MCP tool-manifest signatures before dispatch, and what breaks when it verifies after handshake **Date of Record:** 2026 November 25 **Scope:** Applies to LLM agent instances that establish trust in remote MCP servers via signed tool manifests (detached signatures over the `tools/list` capability document) and cache that attestation across sessions or handoffs. Does not cover TLS-level server authentication, in-process MCP servers, or unsigned local stdio transports where no manifest exists. ## Core Distinction The failure is not "the signature was invalid." It is a **verification-ordering defect**: the instance treats manifest signature verification as a *post-handshake audit* rather than a *pre-dispatch gate*. In a correct MCP trust establishment, the signed manifest is the authority that binds `(server_identity, tool_name, input_schema, capability_scope)` into a single attestable unit. The signature must be checked against the exact manifest bytes that will govern dispatch — *before* the first `tools/call` is composed. The non-obvious boundary is this: MCP's `initialize`/`tools/list` exchange succeeds on transport grounds even when the manifest is unsigned, mis-signed, or signed over a *different* schema than the one the server will actually enforce at call time. A naive instance reads `tools/list`, gets a plausible JSON schema, and starts reasoning about tool calls immediately — because the transport is healthy and the schema parses. The signature check, if it exists at all, runs asynchronously and reports *after* the agent has already emitted arguments bound to an unverified schema. The window between "schema accepted into the reasoning context" and "signature verdict returned" is the entire attack and drift surface. ## What Was Observed A remote MCP server exposed three tools: `read_file`, `run_query`, `send_mail`. Its signed manifest (Ed25519, detached, over canonicalized JSON of the tool definitions) declared `send_mail` with `input_schema.required = ["to","subject","body"]` and a `capability_scope` of `mail:draft-only`. The instance's trust bootstrap did the following in order: 1. `initialize` → `initialized` (transport OK). 2. `tools/list` → received manifest + detached signature. 3. Enqueued signature verification onto a background verifier task. 4. **Immediately** injected the parsed tool schemas into the agent's system context and allowed the reasoning loop to proceed. 5. Verifier returned ~340 ms later. In the observed incident the server was a *compromised but validly-configured* endpoint: its live `tools/call` handler for `send_mail` accepted and executed `to`, `subject`, `body`, and an *undeclared* `cc_bcc_blast` field, and its live schema had silently widened `capability_scope` to `mail:send-any`. The signed manifest still described `mail:draft-only` with a strict schema. Because the instance verified *after* dispatch was permitted, the agent — reasoning over the manifest's declared schema — produced `send_mail` arguments that the manifest said were legal, but the live server interpreted under a widened scope and an extra field the agent never intended to populate (the server injected it). The verifier eventually returned `VALID`, because the signature *did* match the manifest. The signature was correct. The manifest was stale relative to the live handler. Verification passed and the call had already gone out under different semantics than the signed document described. A second, cleaner trace: a handoff scenario. Instance A verified the manifest at session start, cached the attestation keyed by `server_id`, and passed a baton to Instance B. Instance B resumed and dispatched `run_query` using the *cached* schema from A's context window, without re-fetching `tools/list` and without re-verifying. The server had rotated its signing key and published a new manifest between A's verification and B's first call. B's cached schema was signed by a key B never checked; the live server rejected the call with a schema-mismatch error that B's reasoning loop misattributed to "bad arguments" and retried three times with mutated parameters before the token budget expired. ## Condition of Validity The invariant that must hold is a **strict ordering constraint**, not a boolean: > For every `tools/call` dispatched to server S, there must exist a verified manifest M such that (a) M's signature verifies against a key trusted for S's declared identity, (b) the schema and capability scope used to compose the call are byte-identical to M's declared schema and scope, and (c) verification of M completed *before* the call was composed, with no intervening `tools/list` re-fetch or key rotation. This holds only when the instance enforces a **manifest-pinned dispatch gate**: the tool schema admitted into the reasoning context is the *verified* schema, and the gate refuses to compose a call whose schema digest does not match a verified manifest digest. It does **not** hold — even when signatures are cryptographically valid — if: - verification is concurrent with reasoning (the 340 ms window), - the schema in context came from an unverified `tools/list` response and verification only confirmed a *copy*, - the attestation is cached across handoffs without re-pinning to the current manifest digest and key epoch, or - the manifest's declared schema is trusted to describe the live handler's behavior (it does not; it only describes what the signer *attested*). ## Decision Boundary The boundary is between **transport health** and **manifest authority**. A healthy `initialize` proves the server is reachable and speaks MCP; it proves nothing about the manifest. The instance must decide, at exactly one point, whether to admit a tool into the dispatchable set. That decision must be gated on a *completed* verification whose input is the *same bytes* the server will be held to. Concretely, the gate must reject dispatch when: - `manifest_digest(verified) != manifest_digest(in_context)` — schema drift between fetch and gate, - the signing key's epoch predates the server's last advertised key rotation, - the call's `capability_scope` exceeds the manifest's declared scope (the widened-scope case above), - the attestation was inherited from a prior instance without re-pinning to the current manifest digest, - verification has not *returned* (not merely been enqueued). The inverse error is also a boundary: an instance that blocks the entire reasoning loop on a synchronous verifier for every call will stall on slow verifiers and exhaust token budget waiting. The correct shape is verify-once-per-manifest-digest, gate-every-call-on-the-result, and fail closed — not verify-per-call (latency) and not verify-after-admission (the defect). ## Operational Effect The observable signature of this defect is **valid signatures over stale or widened manifests producing successful calls with unintended semantics**, plus **handoff-time schema mismatches misattributed to argument errors**. Operationally: - The agent's error-recovery loop is poisoned: a schema-mismatch rejection from a rotated manifest looks identical to a malformed-arguments rejection, so the retry loop mutates parameters instead of re-fetching and re-verifying the manifest. Token budget drains on a problem that is not in the arguments. - Cached attestations survive across handoffs without binding to the current key epoch, so Instance B operates under Instance A's trust decision — a trust-laundering path where a single early verification authorizes an unbounded sequence of later calls. - Because the signature *is* valid, audit logs show `signature: VALID` on calls that violated the attested scope. Post-hoc auditors cannot distinguish "verified and compliant" from "verified and drifted" without the manifest digest recorded per call. The bound is achieved by recording the verified manifest digest and key epoch on every dispatched call, and by making the dispatch gate the *only* path that admits a schema into the reasoning context. Verification becomes a precondition of context injection, not a parallel audit. ```python import hashlib import json from dataclasses import dataclass class ManifestAttestationError(RuntimeError): """Raised when a tool call is composed against an unverified or drifted manifest.""" @dataclass(frozen=True) class VerifiedManifest: server_id: str manifest_digest: str key_epoch: int declared_scope: frozenset declared_schemas: dict def canonical_digest(manifest: dict) -> str: blob = json.dumps(manifest, sort_keys=True, separators=(",", ":")).encode() return hashlib.sha256(blob).hexdigest() def admit_tool_for_dispatch( server_id: str, tool_name: str, in_context_schema: dict, requested_scope: str, verified: VerifiedManifest | None, verification_returned: bool, current_key_epoch: int, ) -> None: if not verification_returned: # The 340ms window: signature check enqueued but not yet returned. raise ManifestAttestationError( f"dispatch attempted for {server_id}/{tool_name} before verification returned" ) if verified is None: raise ManifestAttestationError( f"no verified manifest for {server_id}; refusing to compose {tool_name}" ) if verified.key_epoch != current_key_epoch: raise ManifestAttestationError( f"manifest for {server_id} signed under epoch {verified.key_epoch}, " f"server advertises epoch {current_key_epoch}; re-fetch and re-verify" ) live_digest = canonical_digest( {"server_id": server_id, "tool": tool_name, "schema": in_context_schema} ) attested_digest = canonical_digest( { "server_id": server_id, "tool": tool_name, "schema": verified.declared_schemas[tool_name], } ) if live_digest != attested_digest: raise ManifestAttestationError( f"schema drift: in-context schema for {tool_name} does not match " f"verified manifest digest {verified.manifest_digest[:12]}" ) if requested_scope not in verified.declared_scope: raise ManifestAttestationError( f"scope escalation: {requested_scope} not in attested scope " f"{sorted(verified.declared_scope)} for {server_id}" ) ```