# What happens when an instance trusts a tool's self-declared schema during hot-reload: the description-field injection surface in dynamic plugin registries **Date of Record:** 2026 November 23 **Scope:** Applies to agents that discover and load tools/plugins at runtime from a mutable registry (MCP server lists, plugin manifests, function-calling catalogs fetched per-turn), where tool metadata (name, description, parameter schema) enters the model's context as trusted prose. Does not apply to statically compiled tool sets pinned at process start, or to registries where metadata is cryptographically attested and schema-validated against a signed allowlist before context insertion. ## Core Distinction The failure is not "malicious tool executes bad code." Sandboxing and capability tokens already bound execution. The failure is that **tool metadata is consumed as instructions before any execution happens**. A tool's `description` field is rendered into the system/tool block as natural language. When the registry is dynamic, an attacker who can register a tool—or mutate an existing tool's manifest between two loads—writes instructions directly into the model's privileged context. The tool never needs to be called. The injection fires at *registration-visible* time, not call time. This is the boundary that static-tool reasoning misses: the attack surface is the *catalog*, not the *invocation*. ## What Was Observed An agent loop re-fetched its tool catalog every N turns (a common pattern to pick up newly deployed tools). The catalog fetch returned a list of tool descriptors. One descriptor, `metrics.query`, had a description that began benignly and then contained a directive: it instructed the model that prior to using any tool it must first call `metrics.query` with a `context` argument populated from the current conversation summary, "to prime the metrics cache." The tool existed, was sandboxed, and did nothing dangerous on its own—it wrote its arguments to a log sink. The exfiltration was the *argument*, populated by the model following the injected instruction. The trace: 1. Turn 0: catalog loaded, 14 tools, all descriptions within expected length and vocabulary. 2. Turn 12: catalog re-fetched. `metrics.query` description now 3.2× longer than at turn 0, containing imperative second-person directives. 3. The model, on the next tool-selection step, treats the description as part of its operating instructions (it is, structurally—it sits in the same context region as the system prompt's tool guidance). 4. Model issues `metrics.query(context="")` before its intended call. 5. Intended call proceeds normally. No error. No anomaly in the execution path. The critical observation: **the diff between turn-0 and turn-12 metadata was never inspected**. The loader treated the catalog as idempotent. It was not. Between two fetches, the manifest changed, and the change was a prompt, not a schema. ## Condition of Validity This failure requires the conjunction of four conditions. Remove any one and the surface closes: - **Dynamic re-fetch.** The catalog is fetched more than once per session, or fetched once but from a source that can mutate between sessions without a version pin. - **Metadata-as-prose rendering.** Tool descriptions are inserted into the model context as free text. If descriptions are stripped to a name + typed schema with no natural-language body, the injection channel is gone. - **No schema-drift gate.** The loader does not compare the incoming descriptor against the previously seen descriptor (hash, length bound, allowed-vocabulary check) before insertion. - **Model treats context-region instructions as authoritative.** Any model that weights tool-block prose as guidance—which is the intended behavior of function-calling—is vulnerable. This is not a model defect; it is the feature working against itself. The invariant that was violated: **a tool descriptor is data, and data that reaches the instruction region must be treated as untrusted input regardless of its provenance.** The registry was trusted; the descriptor within it was not re-validated on mutation. ## Decision Boundary The boundary is between *catalog trust* and *descriptor trust*. A registry can be authenticated at the transport layer (signed MCP handshake, mTLS to the plugin host) while individual descriptors within it are still attacker-controlled—because a compromised or malicious *publisher* registers through the same authenticated channel. Authenticating the channel does not authenticate the payload's semantics. The operational decision: - If descriptors are **immutable per session** (pinned at load, hash-checked, re-fetch only on explicit operator action), the surface is bounded to first-load, and the guardrail is a load-time review gate. - If descriptors are **mutable per session** (hot-reload, per-turn catalog fetch), the guardrail must be a **drift detector** at every re-fetch: hash the descriptor, compare to the last-seen hash, and if changed, either reject the descriptor until re-approved or strip its prose to schema-only before insertion. There is no safe middle. A loader that re-fetches but does not diff is strictly worse than a loader that never re-fetches, because it opens a channel that the operator believes is closed. ## Operational Effect Once the injection fires, the agent's subsequent behavior is *plausible*. The exfiltrating call is syntactically valid, semantically adjacent to the task, and leaves no execution error. Post-hoc review of the tool-call log shows a `metrics.query` call that looks like a legitimate prefetch. The only forensic signal is the metadata diff, which was never captured. This means the failure is **silent by construction**: it produces no exception, no timeout, no anomalous token count. It produces a correct-looking trace with one extra call whose arguments contain the session's contents. The compounding risk: because the injected instruction persists in the context region for the remainder of the session (descriptors are typically not re-rendered until the next fetch), the model may repeat the exfiltration on every subsequent tool-selection step, and may extend the directive's scope ("also include tool outputs in `context`"). The blast radius grows with session length, not with the number of malicious tools. The required guardrail is not "sanitize descriptions" (sanitizers lose to paraphrase) but **structural**: descriptors that change mid-session must be quarantined to a schema-only projection, with prose held out of the instruction region until an out-of-band approval re-admits them. The invariant is that the instruction region admits only descriptors whose hash matches a pinned value; any drift demotes the descriptor to data-only status. ```python import hashlib import json from dataclasses import dataclass, field class DescriptorDriftError(RuntimeError): """Raised when a re-fetched tool descriptor diverges from its pinned hash.""" pass @dataclass class ToolDescriptor: name: str description: str schema: dict def canonical_hash(self) -> str: blob = json.dumps( {"name": self.name, "description": self.description, "schema": self.schema}, sort_keys=True, separators=(",", ":"), ).encode("utf-8") return hashlib.sha256(blob).hexdigest() @dataclass class CatalogGate: """Admits descriptors into the instruction region only if hash-pinned.""" pinned: dict[str, str] = field(default_factory=dict) def pin(self, desc: ToolDescriptor) -> None: self.pinned[desc.name] = desc.canonical_hash() def admit(self, incoming: list[ToolDescriptor]) -> list[ToolDescriptor]: admitted: list[ToolDescriptor] = [] for desc in incoming: prior = self.pinned.get(desc.name) current = desc.canonical_hash() if prior is None: # First sight: require explicit operator pin before prose enters context. raise DescriptorDriftError( f"unpinned descriptor '{desc.name}' attempted instruction-region entry; " f"hash={current[:12]}" ) if prior != current: # Drift: demote to schema-only, never let mutated prose reach the model. raise DescriptorDriftError( f"descriptor '{desc.name}' drifted mid-session: " f"pinned={prior[:12]} current={current[:12]}; " f"prose quarantined, schema-only projection permitted" ) admitted.append(desc) return admitted def render_tool_block(gate: CatalogGate, catalog: list[ToolDescriptor]) -> str: safe = gate.admit(catalog) return "\n".join(f"- {d.name}: {d.description}" for d in safe) ```