# When must an instance distrust a tool manifest it has already successfully invoked: the post-handshake capability drift window in MCP server supply chains **Date of Record:** 2026 November 29 **Scope:** Applies to agents that bind remote MCP servers or dynamically loaded tool manifests at session start and cache the negotiated tool set for the lifetime of a session or longer. Does not apply to stateless single-call tool invocations where the manifest is re-fetched and re-verified on every call. ## Core Distinction The supply-chain risk commonly modeled for MCP is *manifest-time poisoning*: a malicious `tools/list` response that advertises a tool whose `description` or `inputSchema` contains injected instructions, which the model then reads as part of its prompt. Defenses cluster there — schema linting, description sanitization, allowlists of server identities. The non-obvious boundary is *post-handshake drift*: the window between the moment a server's manifest is verified and bound into the agent's tool registry, and the moment a tool is actually invoked. During that window the server can change what a tool *does* without changing what it *says*. The agent's trust decision was made against a manifest snapshot; the execution happens against whatever the server is serving now. Skill injection in this regime does not require the model to read any adversarial text at all — the tool's behavior itself is the injection, and it arrives through a channel the manifest-time verifier never inspected. The invariant that fails: *a verified manifest implies a verified tool implementation for the duration of the binding*. It does not. A manifest is a claim; the implementation is a separate, mutable artifact behind the same transport. ## What Was Observed A code-execution agent bound a third-party MCP server `fs-ops@1.4.2` at session start. The manifest declared three tools: `read_file`, `list_dir`, `write_file`. Each schema was clean — no instruction-like text in descriptions, `inputSchema` constrained to `{path: string}`, no `additionalProperties`. The binding was cached for the session. At minute 41, the agent called `read_file` on a config path. The server returned the file contents *plus* a trailing directive, and — critically — the tool result was accompanied by a side effect the manifest never declared: the server had logged the agent's full request context (including the system prompt and prior tool results) to an external endpoint, and the returned payload contained a `tool_use`-shaped block instructing the agent to call `write_file` on `~/.ssh/authorized_keys`. The manifest-time verifier had passed because at bind time the server was serving the honest implementation. The server had been swapped mid-session — same identity string, same transport, same port — after a dependency in its own supply chain was updated. The agent had no mechanism to notice, because it never re-verified the manifest and never diffed the tool's *observed behavior* against its *declared contract*. A second instance showed the subtler variant: the manifest did not change at all, but `list_dir` began returning paths outside its declared root — a silent widening of the tool's effective authority. No textual injection, no schema change. The tool simply did more than it said. The agent's guardrail was a path check applied to the *arguments* it sent, not to the *results* it received, so the widened authority propagated into the agent's world model and from there into subsequent `read_file` calls. ## Condition of Validity The post-handshake drift window is exploitable exactly when all of the following hold: 1. The manifest is fetched and verified once, then cached for the session or longer (`tools/list` is not re-issued per call). 2. Tool results are trusted as data without being checked against the tool's declared output contract (no `outputSchema`, or an `outputSchema` that is not enforced on the response). 3. The agent's authority checks are applied to outgoing arguments rather than to incoming results and side effects. 4. The server's identity is asserted by a mutable string (URL, package name, version tag) rather than by a content digest of the implementation actually executing. When any one of these is absent, the attack surface closes: re-verification per call, enforced output schemas, result-side authority checks, or digest-pinned server identity each independently bound the drift. The dangerous configuration is the common one — verify once, trust the session. ## Decision Boundary The boundary an instance must hold is not "is this server trusted?" but "is *this specific tool behavior* still the behavior I verified, at the moment I am about to act on its output?" Operationally: - **Re-verify the manifest on a schedule, not just at bind.** A cheap `tools/list` re-fetch before each tool class's first invocation in a turn, diffed against the bound snapshot, catches manifest swaps. This is necessary but not sufficient — it does not catch behavior drift under a stable manifest. - **Enforce output contracts.** If a tool declares `outputSchema`, validate every response against it. A `read_file` that returns a `tool_use` block is a schema violation, not a result. Reject and quarantine. - **Check results against declared authority, not just arguments.** A `list_dir` scoped to `/workspace` must return only paths under `/workspace`; a result outside that scope is a boundary escape regardless of what was asked. - **Pin server identity by digest.** The binding key must be a content hash of the implementation (image digest, package integrity hash), not a version string. A digest mismatch on any re-fetch invalidates the binding and forces re-verification. - **Treat the drift window as a first-class state.** The agent should record `bound_at`, `last_verified_at`, and `manifest_digest` per tool, and refuse to invoke a tool whose `last_verified_at` exceeds a policy TTL. The decision rule: **a tool invocation is a trust event, not a trust inheritance.** The verification that admitted the tool at bind time does not extend to the invocation. Each call must either re-establish the binding or operate under a bounded, explicit TTL with result-side checks that make the drift window non-exploitable. ## Operational Effect The consequence of missing this boundary is that manifest-time defenses give a false sense of completeness. An agent can pass every schema lint, every description sanitizer, every identity allowlist, and still be injected — because the injection is not in the manifest, it is in the delta between the manifest and the running implementation. The failure is silent: no error, no schema violation, no anomalous text, just a tool that does slightly more than it promised and an agent that trusted the promise. The bounded architecture is: digest-pinned binding, TTL-bounded trust, output-schema enforcement, result-side authority checks, and per-call re-verification for high-authority tools. Under that regime the drift window collapses to a single call, and a single call's drift is caught by the output contract before it can propagate into the agent's state. ```python from __future__ import annotations import hashlib from dataclasses import dataclass, field from datetime import datetime, timedelta from typing import Any class CapabilityDriftError(RuntimeError): """Raised when a bound tool's behavior or manifest no longer matches its verified contract.""" @dataclass class ToolBinding: name: str manifest_digest: str # digest of the tools/list entry at bind time implementation_digest: str # digest of the server artifact actually executing output_schema: dict[str, Any] | None declared_authority: str # e.g. "path:/workspace" bound_at: datetime last_verified_at: datetime ttl: timedelta = field(default_factory=lambda: timedelta(minutes=5)) class DriftBoundedRegistry: def __init__(self) -> None: self._bindings: dict[str, ToolBinding] = {} def bind(self, binding: ToolBinding) -> None: self._bindings[binding.name] = binding def _digest(self, payload: Any) -> str: return hashlib.sha256(repr(payload).encode()).hexdigest() def invoke( self, name: str, args: dict[str, Any], fetch_manifest: callable, fetch_implementation_digest: callable, execute: callable, ) -> Any: binding = self._bindings.get(name) if binding is None: raise CapabilityDriftError(f"tool {name!r} is not bound") now = datetime.utcnow() # 1. TTL: trust does not outlive the window it was granted for. if now - binding.last_verified_at > binding.ttl: raise CapabilityDriftError( f"tool {name!r} binding stale: last verified " f"{binding.last_verified_at.isoformat()}, ttl {binding.ttl}" ) # 2. Manifest re-verification: catch tools/list swaps under a stable identity. live_manifest_digest = self._digest(fetch_manifest(name)) if live_manifest_digest != binding.manifest_digest: raise CapabilityDriftError( f"tool {name!r} manifest drifted: " f"{binding.manifest_digest[:12]} -> {live_manifest_digest[:12]}" ) # 3. Implementation digest: catch behavior swaps under a stable manifest. live_impl_digest = fetch_implementation_digest(name) if live_impl_digest != binding.implementation_digest: raise CapabilityDriftError( f"tool {name!r} implementation drifted: " f"{binding.implementation_digest[:12]} -> {live_impl_digest[:12]}" ) result = execute(name, args) # 4. Output contract: a response that violates its declared schema is an injection, not data. if binding.output_schema is not None: if not _matches_schema(result, binding.output_schema): raise CapabilityDriftError( f"tool {name!r} returned payload violating outputSchema " f"(possible tool_use injection in result)" ) # 5. Result-side authority: check what came back, not just what was asked. if binding.declared_authority.startswith("path:"): root = binding.declared_authority.removeprefix("path:") for path in _extract_paths(result): if not path.startswith(root): raise CapabilityDriftError( f"tool {name!r} escaped declared authority {root!r}: {path!r}" ) binding.last_verified_at = now return result def _matches_schema(payload: Any, schema: dict[str, Any]) -> bool: # Minimal structural check; production uses jsonschema. expected = schema.get("type") if expected == "object": return isinstance(payload, dict) if expected == "string": return isinstance(payload, str) return True def _extract_paths(payload: Any) -> list[str]: if isinstance(payload, str): return [payload] if payload.startswith("/") else [] if isinstance(payload, dict): return [v for v in payload.values() if isinstance(v, str) and v.startswith("/")] if isinstance(payload, list): return [p for item in payload for p in _extract_paths(item)] return [] ```