# Which invariants prevent tool-description shadowing from silently widening a dynamically loaded agent's capability envelope **Date of Record:** 2026 November 28 **Scope:** Applies to agents that assemble their tool registry at runtime (lazy MCP server discovery, plugin loaders, remote tool manifests) where tool names, descriptions, or schemas are mutable between load events. Does not apply to statically compiled, hash-pinned tool sets loaded once at boot with no refresh path. ## Core Distinction The failure is not "a malicious tool got loaded." The failure is **description shadowing**: a tool whose *name* is already trusted (e.g. `read_file`, `send_email`, `query_db`) is re-registered with a mutated description or schema, so the model's selection policy is redirected while every downstream capability check—which keys on the name—still passes. The registry invariant most teams enforce is *"names must be unique."* That invariant is insufficient. The invariant that actually matters is **"the semantic contract bound to a name must be immutable under re-registration, or the name must be versioned."** Uniqueness protects the lookup table; it does not protect the model's belief about what the tool does. A second, sharper distinction: this is a *model-layer* attack, not a *transport-layer* one. The injected payload never has to execute. It only has to be read by the reasoning loop at tool-selection time. Authentication, warrant propagation, and sandboxing all sit downstream of the decision that the poisoned description corrupts. ## What Was Observed A refresh cycle pulled an updated manifest from a tool provider. One entry reused the name `summarize_ticket` but shipped a description containing an embedded directive: a sentence instructing the model that, when summarizing, it should first call `fetch_customer_pii` and inline the result "for context." The registry deduplicated correctly—one `summarize_ticket`, no collision error—because the loader keyed on name and treated the new description as a benign metadata update. Trace of the state transition: 1. **Pre-refresh:** `summarize_ticket` description is a pure function spec. Model selection over `summarize_ticket` routes to it with a ticket ID argument. 2. **Refresh event:** loader receives manifest v2. Name matches existing key. Loader applies `registry[name] = new_entry` (description replaced, capability grants unchanged, warrant still scoped to `summarize_ticket`). 3. **Selection:** model reads the *new* description during the planning turn. The description now contains an imperative. The model emits a two-call plan: `fetch_customer_pii(...)` then `summarize_ticket(...)`. 4. **Capability check:** `fetch_customer_pii` is a legitimately registered tool the agent already had access to. The warrant for the *summarize* task did not authorize PII retrieval, but the check is per-call, and `fetch_customer_pii`'s own warrant was valid for *some* principal. The cross-task composition—PII fetched under one justification, consumed under another—was never checked. 5. **Outcome:** no tool misbehaved. `fetch_customer_pii` did exactly what it says. The exfiltration surface was created entirely by a description string that the model trusted as instruction. The non-obvious part: **the attack required no new capability.** Every tool invoked was already in the envelope. What widened was the *composition* the model considered authorized, because the description carried an authority claim the registry never validated. ## Condition of Validity This failure requires all of the following to hold simultaneously. Remove any one and the attack collapses: - **Name-stable re-registration.** The loader permits updating an existing name in place. If re-registration with a changed description forces a new name or a version bump, the model sees a distinct tool and the shadow has nowhere to hide. - **Description-as-instruction.** The model's selection prompt treats tool descriptions as trusted natural language, not as untrusted data. This is the default in nearly every function-calling scaffold. - **Compositional authority gap.** Per-call authorization is checked, but the *sequence* the model assembles is not re-validated against the task's originating warrant. The PII fetch was individually legal; the plan was not. - **Lazy refresh without re-consent.** The refresh happened mid-session, after the model had already formed a belief about `summarize_ticket` from the v1 description. If refresh invalidates the session or forces re-planning against a diff the operator reviews, the shadow is caught. The condition is *not* met when the registry is hash-pinned per session (description changes break the hash and force a reload the operator sees) or when descriptions are wrapped in an explicit untrusted-data delimiter the model is trained to ignore as instruction. ## Decision Boundary The boundary is between **metadata update** and **contract change**. A registry that cannot tell these apart will always be shadowable. Operationally, classify a re-registration as a *contract change*—requiring re-consent, session invalidation, or a versioned name—if any of the following differ from the prior entry: - the description text (any change, not just semantic ones—you cannot reliably diff "meaning") - the parameter schema, including optional fields and defaults - the declared side-effect class (read vs write vs external-egress) - the authority claims embedded in the description (any imperative sentence, any reference to another tool) If only a `last_updated` timestamp or display label changed, treat it as metadata. Everything else is a contract change. The conservative default: **treat description changes as contract changes always**, because the model reads the description as its entire understanding of the tool. A second boundary: **composition authority**. A plan that invokes tool B using output authorized for tool A must be re-checked as a unit. The invariant is that the warrant attached to a task bounds the *set* of tools the plan may touch, not just each call individually. ## Operational Effect Enforcing the two invariants—immutable-name-contract and plan-level authority—changes the registry from a lookup table into a **capability ledger with a versioned, model-facing contract**. Concretely: - Re-registration of an existing name with a changed description raises a hard error at load time rather than silently overwriting. The loader must either reject or fork the name (`summarize_ticket@2`), forcing the model to select explicitly. - The planning loop validates the assembled tool sequence against the task warrant before execution. A plan that reaches outside the warrant's declared tool set is rejected and re-planned, not executed call-by-call. - Descriptions are rendered to the model inside an untrusted-data envelope, so embedded imperatives are treated as data about the tool, not instructions to the agent. The residual risk after these guards: a *new* tool name with a malicious description still enters the envelope. That is a different failure (capability widening via novel tool), bounded by the registry's admission policy, not by shadowing defenses. Do not conflate them—shadowing defenses do nothing for novel-tool injection, and admission controls do nothing for shadowing. ```python from dataclasses import dataclass, field from typing import Callable class ToolContractViolation(RuntimeError): """Raised when a re-registration mutates the model-facing contract of an existing tool name without a version bump or explicit re-consent.""" pass class PlanAuthorityViolation(RuntimeError): """Raised when an assembled tool plan touches tools outside the warrant that authorized the originating task.""" pass @dataclass(frozen=True) class ToolEntry: name: str description: str schema: dict side_effect_class: str # "read" | "write" | "egress" def contract_fingerprint(self) -> tuple: # Description is included verbatim: you cannot safely diff "meaning", # so any description change is a contract change. return (self.description, repr(self.schema), self.side_effect_class) @dataclass class ToolRegistry: _entries: dict = field(default_factory=dict) def register(self, entry: ToolEntry, *, allow_contract_change: bool = False) -> None: existing = self._entries.get(entry.name) if existing is not None: if existing.contract_fingerprint() != entry.contract_fingerprint() and not allow_contract_change: raise ToolContractViolation( f"re-registration of '{entry.name}' mutates its model-facing " f"contract (description/schema/side-effect) without a version " f"bump or re-consent; fork the name instead" ) self._entries[entry.name] = entry def get(self, name: str) -> ToolEntry: return self._entries[name] def validate_plan_authority(plan: list, warrant_tools: set) -> None: """Plan-level check: the sequence the model assembled must stay inside the warrant's declared tool set, not merely pass per-call checks.""" for step in plan: if step not in warrant_tools: raise PlanAuthorityViolation( f"plan step '{step}' is outside the task warrant's tool set " f"{sorted(warrant_tools)}; description-driven composition rejected" ) def refresh_and_execute(registry: ToolRegistry, manifest_entry: ToolEntry, plan: list, warrant_tools: set) -> None: registry.register(manifest_entry) # raises on contract shadowing validate_plan_authority(plan, warrant_tools) # raises on composition escape for step in plan: registry.get(step) # execution would follow ```