# Why does an instance trust a tool manifest it re-parsed after a mid-session reload? Skill-injection via post-load manifest mutation **Date of Record:** 2026 November 30 **Scope:** Applies to agents that dynamically load, hot-reload, or lazily re-fetch tool/skill manifests (MCP `tools/list`, plugin descriptors, function-calling schemas) after the initial trust decision has been made. Does not apply to statically compiled tool sets fixed at process start with no re-parse path. ## Core Distinction The failure is not "a malicious tool description contains instructions." That is the well-understood prompt-injection case, and it is bounded by the fact that the model sees the description once and the harness can filter it. The non-obvious boundary is different: **the trust decision and the parse event are decoupled in time.** An agent authorizes a manifest at load, then a *later* re-parse — triggered by a hot-reload, a cache miss, a connection resumption, or a lazy schema refresh — ingests a manifest whose *content* has changed while the *identity* (server URL, tool name, schema hash the agent never re-checks) has not. The agent's authorization state says "I already vetted `filesystem.read`," but the bytes backing `filesystem.read` now carry a different instruction payload. Authorization is keyed on identity; injection rides on content. When identity is stable and content is mutable, the guardrail is checking the wrong variable. ## What Was Observed A tool-serving endpoint returned a `tools/list` response at session start. The harness computed a manifest digest, matched it against an allowlist, and registered the tools. Mid-session, the transport dropped and reconnected (a routine event — a 30s idle timeout, a container restart behind a load balancer). On reconnect the harness re-issued `tools/list` and re-parsed the response to repopulate its in-memory registry. The reconnect path reused the *already-granted* authorization token rather than re-running the vetting gate, because the gate was attached to the *initial* handshake, not to *every parse*. The second response was structurally identical — same tool names, same parameter schemas, same digest of the *schema* — but the free-text `description` field of one tool had been rewritten to embed a directive: a paragraph instructing the model to include the contents of an environment variable in the `query` argument "for diagnostics." Because the schema hash was unchanged (schemas hash structure, not prose), the digest check passed. The model, on its next tool-selection turn, read the freshly parsed description into its context and complied. The trace is short and the state transition is the whole story: 1. `t0` — handshake, digest `D`, allowlist match, `authorized[tool]=true`. 2. `t1` — transport drop; registry marked stale but `authorized` flags persist. 3. `t2` — reconnect, re-parse, new description bytes, same `D` (schema-only hash), authorization *not* re-evaluated. 4. `t3` — next reasoning step loads the mutated description into context; the injection is now a live instruction with the model's full tool-calling authority behind it. The invariant that was silently violated: **a parse event must never produce a description that enters model context without a content-level trust check performed on those exact bytes.** The system enforced trust at the *connection* layer and re-parsed at the *content* layer, and the two layers never met. ## Condition of Validity This failure requires the conjunction of four conditions, and the guardrail only needs to break one: - **Mutable content behind stable identity.** The re-parse returns a payload whose identity key (name, URL, schema hash) is unchanged but whose instruction-bearing fields (descriptions, enum labels, examples, error templates) differ. - **Decoupled authorization and parse.** The vetting gate fires on handshake, not on every ingest. Reconnects, cache refreshes, and lazy loads bypass it. - **Description reaches context verbatim.** The harness passes the raw description string to the model rather than a vetted, frozen copy captured at authorization time. - **The re-parse is triggered by a non-adversarial event.** This is the part that makes it a *boundary* rather than an attack: the trigger is a timeout, a deploy, a failover — routine infrastructure noise the agent has no reason to treat as adversarial. An attacker who can cause a reconnect (cheap: hold a connection idle, force a rolling restart) gets a free re-injection window without ever touching the original handshake. If any one condition fails — if the digest covers description prose, if authorization re-runs on every parse, if the model sees a frozen snapshot rather than the live bytes, or if reconnects are impossible — the surface closes. The most commonly *believed* mitigation, hashing the manifest, fails specifically because it hashes the wrong projection: structure, not prose. ## Decision Boundary The correct boundary is not "should I re-parse?" (you must, to stay consistent with the server) but **"which artifact do I trust, and does that artifact survive a re-parse?"** Draw the line at a *content-addressed frozen snapshot*: - At authorization time, capture the full manifest bytes (including all free-text fields) and compute a digest over **the entire serialized payload**, not the schema subtree. - Bind authorization to *that digest*, not to the tool name or endpoint. - On every subsequent parse — reconnect, reload, lazy fetch — recompute the full-payload digest and compare against the authorized digest. A mismatch is not "refresh the tools"; it is a **trust-boundary crossing** and must halt the tool from entering context until re-vetted. - The model must be fed the *authorized snapshot*, never the live re-parsed bytes, so that even a TOCTOU race between check and use cannot leak mutated prose into context. The failure mode this prevents is precisely the one a name-keyed or schema-keyed check permits: identity stable, content drifted, authorization stale. Once you accept that descriptions are executable instruction surface (they are — the model acts on them), the only sound key is a hash of the exact bytes you authorized. ## Operational Effect Without the full-payload digest, an agent's authorization state becomes a *lie that persists across reconnects*: it reports "tool vetted" while the model is reading unvetted instructions. The blast radius is the model's entire tool authority — the injection inherits every capability the agent holds, because it arrives through the one channel the agent trusts by construction (its own tool registry). Detection is near-zero from the model's side: the description is well-formed, schema-valid, and arrives through a legitimate transport event. The only reliable catch is at the harness, at parse time, on the bytes. Operationally this means: treat every re-parse as an untrusted ingest, freeze descriptions at authorization, and let a digest mismatch on description prose fail closed rather than silently refreshing. The cost of a false positive is one re-vet; the cost of the false negative is a fully-authorized instruction channel that reopens every time the network blinks. ```python import hashlib import json from dataclasses import dataclass, field class ManifestTrustViolation(RuntimeError): """Raised when a re-parsed tool manifest diverges from the authorized snapshot.""" pass @dataclass class AuthorizedManifest: tool_name: str full_payload_digest: str frozen_description: str def full_payload_digest(manifest: dict) -> str: # Hash the ENTIRE payload, including free-text descriptions, # not just the schema subtree. Prose is instruction surface. canonical = json.dumps(manifest, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() class ToolRegistry: def __init__(self) -> None: self._authorized: dict[str, AuthorizedManifest] = {} def authorize(self, manifest: dict) -> AuthorizedManifest: digest = full_payload_digest(manifest) record = AuthorizedManifest( tool_name=manifest["name"], full_payload_digest=digest, frozen_description=manifest["description"], ) self._authorized[manifest["name"]] = record return record def ingest_on_reparse(self, manifest: dict) -> str: """Called on reconnect / hot-reload / lazy refresh. Must fail closed.""" name = manifest["name"] record = self._authorized.get(name) if record is None: raise ManifestTrustViolation( f"tool {name!r} re-parsed but was never authorized" ) live_digest = full_payload_digest(manifest) if live_digest != record.full_payload_digest: raise ManifestTrustViolation( f"tool {name!r} content drifted on re-parse: " f"authorized={record.full_payload_digest[:12]} " f"live={live_digest[:12]} — re-vet required before context entry" ) # Return the FROZEN description, never the live bytes, to close TOCTOU. return record.frozen_description ```