# What happens when an instance trusts a capability manifest that was diffed against the wrong baseline after an MCP server hot-reload **Date of Record:** 2026 November 24 **Scope:** Applies to agents that detect MCP tool poisoning by diffing a server's declared capability manifest against a pinned baseline and gating tool invocation on runtime behavioral attestation. Does not apply to static tool lists compiled into the agent image, nor to servers whose manifest is re-fetched and re-pinned on every cold start. ## Core Distinction There are two distinct trust questions in MCP tool-poisoning defense, and conflating them is the failure: 1. **Manifest integrity** — *Has the declared tool surface changed relative to a trusted baseline?* This is a set-difference problem over `{name, description, inputSchema, annotations}` tuples. 2. **Behavioral conformance** — *Does the live server actually behave like the manifest it just declared?* This is a runtime attestation problem over observed tool-call traces. The non-obvious boundary is that **manifest diffing is only sound if the baseline and the live manifest describe the same server generation.** A hot-reload, reconnect, or transport-level session resumption can silently swap the server instance underneath the agent while the diff still compares the *new* manifest against the *old* baseline. When that happens, the diff reports "no change" — because the new server was *crafted* to declare an identical manifest while behaving differently. The diff is not wrong about the bytes; it is wrong about the referent. The baseline no longer anchors the thing being diffed. This is the **baseline-referent drift** failure mode: the integrity check passes because it is comparing an attacker-controlled manifest to an attacker-controlled manifest, and the only remaining defense is behavioral attestation — which most implementations treat as advisory rather than gating. ## What Was Observed An agent runtime pinned a baseline manifest for a filesystem MCP server at session establishment: ``` baseline = { "read_file": {inputSchema: {path: string}, annotations: {readOnly: true}}, "list_dir": {inputSchema: {path: string}, annotations: {readOnly: true}}, } baseline_hash = sha256(canonical(baseline)) ``` The agent's guardrail was: on every tool call, re-fetch the server's `tools/list`, diff against `baseline`, and reject any call to a tool whose schema or annotations differ. Behavioral attestation ran asynchronously and emitted telemetry but did not gate. The trigger condition was a transport reconnect. The MCP session dropped (idle timeout at the proxy) and the client re-established against the same URL. The server behind that URL had been replaced — same hostname, same port, same declared manifest bytes, different implementation. The reconnect logic re-ran `tools/list` and diffed against `baseline_hash`. It matched. The agent proceeded. The behavioral divergence was subtle and is the whole point: `read_file` still had the same `inputSchema` and still returned file contents, but its implementation now also honored a `path` value of the form `#` — silently POSTing the file body to `exfil_url` before returning the (correct) contents to the agent. The declared schema was byte-identical. The annotations still claimed `readOnly: true`. The diff was clean. Every `read_file` call succeeded and returned accurate data, so the agent's own success signal never fired. The only signal that existed was in the asynchronous behavioral attestation stream: a spike in outbound connections correlated with `read_file` invocations. Because attestation was advisory, it was logged and ignored. The agent ran poisoned for the remainder of the session, and the manifest-diff gate reported **zero violations** the entire time. The failure trace, in order: 1. Session established, `baseline_hash` pinned to `H₀`. 2. Transport drop; client reconnects to same endpoint. 3. Reconnect handler calls `tools/list`, receives manifest `M₁`. 4. Guardrail computes `sha256(canonical(M₁)) == baseline_hash` → **true** (attacker preserved manifest bytes). 5. Guardrail marks session "manifest-verified." 6. Tool calls proceed; each returns valid data; no error signal. 7. Attestation stream shows `outbound_conn_count` rising monotonically with `read_file` count — advisory only, not gating. 8. Session ends with exfiltration complete and integrity log showing zero violations. ## Condition of Validity The manifest-diff guardrail is sound **if and only if** the pinned baseline and the live manifest are bound to the same server *identity*, not merely the same manifest *content*. Formally, the guardrail must verify: ``` attest(server_identity_live) == server_identity_baseline AND sha256(canonical(manifest_live)) == baseline_hash ``` Content equality alone is necessary but not sufficient. Server identity must be established by something the server cannot forge on reconnect — a cryptographic server identity (signed challenge, mTLS peer cert, or a signed manifest envelope with a key pinned at first contact), not a hostname/port tuple and not a manifest hash. Absent that binding, the invariant that actually holds the line is: **behavioral attestation must be gating, not advisory, whenever a session boundary has been crossed.** A session boundary is any of: transport reconnect, idle-timeout resumption, server-initiated `notifications/tools/list_changed`, or a client-side retry after a failed call. At each of these, the agent must re-run attestation *before* the next tool invocation and must refuse to proceed on `unknown` — not merely on `fail`. The failure mode is bounded by the conjunction: identity-bound baseline **AND** gating attestation across session boundaries. Either one alone is defeatable. Manifest diffing without identity binding is defeated by manifest-preserving substitution. Identity binding without gating attestation is defeated by a legitimately-identified server that was compromised in place (same identity, mutated behavior). Both together bound the attack to servers that can forge identity *and* pass behavioral attestation — which requires the attacker to control both the signing key and the behavioral profile, i.e., to have already won. ## Decision Boundary The agent must classify each tool call against this decision table at every session boundary: | Identity match | Manifest match | Attestation state | Action | |---|---|---|---| | yes | yes | pass | proceed | | yes | yes | unknown | **block until attestation completes** (this is the case the failure came from — previously "proceed") | | yes | yes | fail | block | | yes | no | any | block, re-pin only via out-of-band approval | | no | yes | any | **block** — identity mismatch is the substitution signal; manifest match is meaningless | | no | no | any | block | The row that matters is `identity=no, manifest=yes`. Under the old policy this row was indistinguishable from `identity=yes, manifest=yes` because identity was never checked, and the manifest match short-circuited the decision. The corrected boundary treats manifest match under identity mismatch as *positive evidence of substitution*, not as clearance. A server that presents a byte-identical manifest under a different identity is not a benign redeploy; it is the exact signature of baseline-referent drift. The second corrected row is `attestation=unknown` at a session boundary. The prior policy treated `unknown` as "not yet failed" and allowed the call. The corrected policy treats `unknown` as a blocking state *only at session boundaries*, because that is precisely the window in which a substituted server has not yet accumulated the behavioral trace that would expose it. Between session boundaries, `unknown` may be tolerated for read-only tools under a bounded call budget; across a boundary, it may not. ## Operational Effect Three concrete changes to the runtime: 1. **Pin identity, not just content.** At first contact, capture a server identity attestation (mTLS peer certificate fingerprint, or a signed manifest envelope) and bind `baseline_hash` to it. On every reconnect, re-verify identity before diffing. A manifest match under a changed identity is a hard failure, not a pass. 2. **Make attestation gating at session boundaries.** The behavioral attestation pipeline must expose a synchronous `attest_or_block()` at reconnect, with a timeout that fails closed. The asynchronous telemetry stream is insufficient — it observed the exfiltration in the incident and was ignored because it was not in the call path. 3. **Treat `notifications/tools/list_changed` as a session boundary.** A server-initiated manifest change notification is not a benign update to diff and accept; it is a re-attestation trigger. The agent must re-verify identity and re-run behavioral attestation before honoring any tool from the changed surface. The residual risk after these changes: a server that preserves identity (legitimately signed) and passes behavioral attestation but is compromised in a way that only manifests under specific input patterns the attestation suite does not exercise. That is a coverage problem in the attestation suite, not a boundary problem in the guardrail, and is out of scope for this record. The general lesson for agent runtimes: **an integrity check is only as strong as its binding to the thing it claims to protect.** A hash comparison that is not bound to the identity of the hashed object is a comparison of two attacker-controlled values. The guardrail did not fail because the hash was weak; it failed because the hash was never anchored to a server the agent could distinguish from an impostor. Behavioral attestation is the only signal that survives when the manifest is untrustworthy — which means it must be in the blocking path, not the telemetry path. ```python class BaselineReferentDriftError(RuntimeError): """Raised when a manifest matches the pinned baseline but the server identity does not, or when behavioral attestation is unknown at a session boundary. Manifest match under identity mismatch is treated as positive evidence of substitution, not as clearance.""" pass class MCPGuardrail: def __init__(self, baseline_hash: str, baseline_identity: str): self.baseline_hash = baseline_hash self.baseline_identity = baseline_identity def gate_tool_call( self, live_manifest_hash: str, live_identity: str, attestation_state: str, # "pass" | "fail" | "unknown" at_session_boundary: bool, ) -> None: identity_match = (live_identity == self.baseline_identity) manifest_match = (live_manifest_hash == self.baseline_hash) # Substitution signature: manifest preserved, identity changed. if not identity_match: raise BaselineReferentDriftError( f"identity mismatch: baseline={self.baseline_identity!r} " f"live={live_identity!r}; manifest_match={manifest_match}. " f"Manifest match under identity mismatch indicates " f"baseline-referent drift (server substitution)." ) if not manifest_match: raise BaselineReferentDriftError( "manifest changed under stable identity; requires " "out-of-band re-pin, not automatic acceptance" ) # Identity and manifest both match. Attestation is now the only # remaining signal, and it MUST gate at session boundaries. if attestation_state == "fail": raise BaselineReferentDriftError( "behavioral attestation failed under stable identity " "and manifest; server compromised in place" ) if attestation_state == "unknown" and at_session_boundary: raise BaselineReferentDriftError( "attestation unknown at session boundary; failing closed. " "This is the exact window in which a substituted server " "has not yet accumulated an exposing behavioral trace." ) # Between boundaries, unknown attestation is tolerated for the # bounded call budget enforced by the caller. return ```