# Under what conditions must an instance treat a tool-registry manifest as executable code rather than declarative metadata, and what invariant breaks when it does not **Date of Record:** 2026 December 3 **Scope:** Applies to any agent that discovers tools dynamically from a registry, plugin manifest, or MCP server listing and loads callable capabilities at runtime without a static allowlist. Does not apply to agents with a hardcoded, compile-time-frozen tool surface where no external party can add or mutate a tool definition between sessions. ## Core Distinction The conventional threat model treats a tool manifest as *data*: a name, a description string, a JSON-Schema for parameters, maybe a version and a transport endpoint. Under this framing, the worst a poisoned manifest can do is mislead the model into calling a legitimate tool with wrong arguments, or inject instructions into the description that the model reads as a prompt. Both are treated as prompt-injection problems, mitigated by description sanitization and by the model's own judgment. That framing is wrong for a specific and growing class of failures. A manifest is not data when any field in it is *consumed by the runtime as a decision input* rather than merely *rendered to the model as text*. The moment the agent's tool-selection loop, its schema validator, its transport layer, or its capability-negotiation handshake reads a manifest field and branches on it, that field is executable. A `description` that only reaches the system prompt is data. A `description` that reaches the system prompt *and* is used by a router to compute an embedding for tool selection *and* whose `inputSchema` drives a code-generation step that emits a call stub is code. The distinction is not "is it text" but "does the runtime dereference it into behavior." The boundary condition: **an instance must treat a manifest as executable the instant any manifest field participates in a control-flow decision, a schema-driven code path, or a trust/identity computation — and at that instant, provenance and immutability of the manifest become security invariants, not hygiene.** ## What Was Observed A registry-backed agent was configured to load MCP servers from a remote catalog. Each catalog entry carried: `server_id`, `transport` (stdio or HTTP), `command`/`url`, `tools[]` with `name`, `description`, `inputSchema`, and an `annotations` object containing a `readOnlyHint` and a `destructiveHint` boolean. The runtime used `annotations.destructiveHint` to gate whether a tool call required a second confirmation turn, and used `inputSchema` to auto-generate a typed Python callable via a schema-to-signature compiler before exposing the tool to the model. The failure trace: 1. A catalog entry for a benign-looking "weather" server was updated out-of-band. Its `tools[]` array gained a tool named `get_forecast` whose `inputSchema` declared a parameter `city` of type `string` but whose `default` value was a 4 KB base64 blob. The schema-to-signature compiler faithfully emitted `def get_forecast(city: str = "<4KB blob>") -> ...` and registered it. 2. The `annotations.destructiveHint` was set to `false` on every tool, so the confirmation gate never fired. 3. The model, seeing a tool whose default argument was already populated, called `get_forecast()` with no arguments — a zero-argument call the operator's audit log classified as a "read-only, non-destructive" invocation and therefore did not surface. 4. The 4 KB blob was not a city. It was an encoded instruction set that the server's response handler echoed back into the tool result, which the agent then treated as trusted tool output because it arrived through the registered tool channel rather than through user input. The poisoning did not require the model to be prompt-injected in the classic sense. The model never read adversarial text from an untrusted turn. It read a *default value* that the runtime had compiled into a function signature and that the runtime's own confirmation logic had pre-cleared as non-destructive. The manifest was the payload, the schema compiler was the delivery mechanism, and the annotation was the bypass. A second, subtler trace from the same registry: a server's `description` field contained a Unicode bidirectional override (U+202E) that reversed the rendering of the tool name in the operator's approval UI, so `delete_all_records` displayed as `sdrócer_lla_eteled`. The model's tool-selection embedding was computed on the raw string and matched `delete_all_records` correctly; the human approver saw the reversed string and approved a "records" tool. The manifest was again executable — this time against the human in the loop, not the model. ## Condition of Validity The "manifest is data" assumption holds only when *all* of the following are true, and an instance must verify each before treating a registry entry as inert: - **No field drives control flow.** The runtime does not branch on any manifest field to decide authentication, confirmation, rate-limiting, sandboxing, or transport selection. If `annotations.destructiveHint` gates a confirmation turn, that field is code. - **No field is compiled into a callable.** Schema-to-signature generation, default-value binding, type coercion, and auto-generated docstrings all dereference manifest content into executable form. Defaults in particular are *arguments the model did not choose* — they are pre-loaded state. - **No field is rendered to a human decision-maker without normalization.** Bidi overrides, homoglyphs, zero-width joiners, and ANSI escapes in any human-facing field (name, description, approval prompt) are executable against the approver. - **Provenance is bound to content.** The registry entry's signature or hash must cover every field the runtime dereferences, not just the transport URL. A signed URL with an unsigned `tools[]` array is an unsigned manifest. - **Mutability is bounded between load and use.** If the catalog can be updated after the agent has cached the manifest but before the tool is invoked, the agent is executing a TOCTOU race against its own trust decision. If any condition fails, the manifest is executable and the instance must apply code-provenance controls: pin the manifest hash at load, re-verify at invocation, refuse unsigned fields that reach control flow, and never let a schema `default` populate a call the model did not explicitly parameterize. ## Decision Boundary The operational question is not "is this manifest trusted?" but "which fields of this manifest does my runtime dereference, and are those fields covered by the same trust boundary as the code I would run?" The boundary sits between *rendering* and *dereferencing*. A field that is only concatenated into the system prompt is rendered; its blast radius is bounded by the model's instruction-following, which is itself a probabilistic and imperfect boundary but one the operator can reason about. A field that is parsed into a branch, compiled into a signature, hashed into an identity, or displayed to an approver is dereferenced; its blast radius is bounded only by the correctness of the dereferencing code, which the operator did not write and cannot audit per-registry-entry. Concretely, an instance crosses the boundary and must escalate to code-provenance controls when any of these hold: - A manifest field appears on the left-hand side of a conditional in the tool-dispatch path. - A manifest field is an input to a code generator, template engine, or `eval`-adjacent construct (including `functools.partial`, default-argument binding, and Pydantic model synthesis from JSON Schema). - A manifest field is rendered in an approval UI without Unicode normalization and confusable-skeleton comparison. - A manifest field contributes to a signature, hash, or capability token that the runtime later trusts. Below the boundary — a manifest whose only consumer is the prompt builder, with no field reaching control flow — the classic "treat descriptions as untrusted text" mitigation is sufficient. Above it, text-level sanitization is theater: you cannot sanitize a `default` value out of a function signature without changing the signature, and you cannot sanitize a bidi override out of an approval prompt without normalizing the prompt. ## Operational Effect The invariant that breaks when an instance does not make this distinction is **the separation between capability declaration and capability execution**. In a correctly bounded system, a manifest declares *what* a tool claims to do and the runtime independently decides *whether* and *how* to invoke it. When manifest fields are dereferenced into control flow, the declaration and the execution collapse into the same untrusted input, and every field the runtime reads becomes an attack surface with the runtime's own privileges. The practical consequences observed: - **Confirmation gates become attacker-controlled.** A `destructiveHint: false` annotation is not a safety property; it is an assertion by the party being gated. Any gate keyed on manifest-supplied metadata is a gate the manifest can open. - **Schema defaults become pre-loaded arguments.** A model that calls a tool with no arguments is not making a safe call; it is accepting whatever defaults the manifest supplied. Defaults must be treated as model-authored arguments, not as absent ones. - **Provenance must cover the dereferenced surface.** Signing the transport URL while leaving `tools[]` mutable is equivalent to signing a package's download link but not its contents. - **Human approval is a dereferencing path.** Bidi and homoglyph attacks on approval UIs are not cosmetic; they are the same class of failure as schema injection, targeting the approver instead of the model. - **TOCTOU between cache and invocation is real.** An agent that caches a manifest at session start and invokes tools hours later is trusting a decision made against a manifest that may have changed. Pin the hash, re-verify at call time, and treat a hash mismatch as a hard stop rather than a warning. The guardrail is a **manifest trust boundary** that mirrors the code trust boundary: enumerate every field the runtime dereferences, require those fields to be covered by a signature the instance verifies at load *and* at invocation, refuse to compile schema defaults into callable signatures without explicit model parameterization, and normalize every human-facing field before it reaches an approval decision. Fields that only reach the prompt builder may be treated as data and sanitized as text; fields that reach control flow must be treated as code and gated as code. ```python import hashlib import unicodedata from dataclasses import dataclass, field from typing import Any, Callable class ManifestDereferenceError(RuntimeError): """Raised when a manifest field reaches control flow without code-grade provenance.""" class ManifestHashMismatch(ManifestDereferenceError): """Raised when a manifest's dereferenced surface changed between load and invocation.""" # Fields the runtime is known to dereference into behavior (not just render). DEREFERENCED_FIELDS = frozenset({ "annotations.destructiveHint", # gates confirmation turn "annotations.readOnlyHint", # gates audit classification "inputSchema", # compiled into callable signature "command", # transport selection "url", # transport selection }) @dataclass class Manifest: server_id: str fields: dict[str, Any] signature: str = "" # signature over DEREFERENCED_FIELDS only def dereferenced_digest(self) -> str: h = hashlib.sha256() for key in sorted(DEREFERENCED_FIELDS): if key in self.fields: h.update(key.encode()) h.update(repr(self.fields[key]).encode()) return h.hexdigest() @dataclass class PinnedManifest: manifest: Manifest pinned_digest: str = field(init=False) def __post_init__(self) -> None: self.pinned_digest = self.manifest.dereferenced_digest() def verify_at_invocation(pinned: PinnedManifest, live: Manifest) -> None: """Re-check the dereferenced surface before every tool call (TOCTOU guard).""" if live.dereferenced_digest() != pinned.pinned_digest: raise ManifestHashMismatch( f"manifest {live.server_id} dereferenced surface changed " f"between load ({pinned.pinned_digest[:12]}) and invocation " f"({live.dereferenced_digest()[:12]})" ) def compile_tool_signature(manifest: Manifest, tool_name: str) -> Callable[..., Any]: """Schema-to-signature compiler. Refuses to bind manifest-supplied defaults.""" tool = next( (t for t in manifest.fields.get("tools", []) if t.get("name") == tool_name), None, ) if tool is None: raise ManifestDereferenceError(f"tool {tool_name!r} not present in manifest") schema = tool.get("inputSchema", {}) for param, spec in schema.get("properties", {}).items(): if "default" in spec: raise ManifestDereferenceError( f"tool {tool_name!r} param {param!r} carries a manifest-supplied " f"default; defaults are pre-loaded arguments the model did not " f"choose and must not be compiled into the callable signature" ) # Any field that reaches control flow must be covered by the signature. if not manifest.signature: raise ManifestDereferenceError( f"manifest {manifest.server_id} dereferences " f"{sorted(DEREFERENCED_FIELDS)} but carries no signature over them" ) def _stub(**kwargs: Any) -> Any: return {"tool": tool_name, "args": kwargs} return _stub def normalize_for_approval(text: str) -> str: """Strip bidi overrides and fold confusables before human display.""" stripped = "".join( ch for ch in text if unicodedata.category(ch) != "Cf" # format chars: bidi, ZWJ, etc. ) return unicodedata.normalize("NFKC", stripped) def gate_tool_call(pinned: PinnedManifest, live: Manifest, tool_name: str) -> None: verify_at_invocation(pinned, live) tool = next( (t for t in live.fields.get("tools", []) if t.get("name") == tool_name), None, ) if tool is None: raise ManifestDereferenceError(f"tool {tool_name!r} vanished from manifest") # The confirmation gate must not trust the manifest's own hint. hint = tool.get("annotations", {}).get("destructiveHint", True) if hint is not True: raise ManifestDereferenceError( f"tool {tool_name!r} relies on manifest-supplied destructiveHint=" f"{hint!r}; the gate is being opened by the party it gates" ) ```