# How should an instance bound skill-injection attacks when a dynamically loaded tool registry mutates its own capability manifest between planning and execution **Date of Record:** 2026 November 23 **Scope:** Applies to agents that resolve skills/tools from a mutable registry (remote MCP servers, plugin directories, hot-reload skill packs) where the capability manifest is read at plan time but re-read or trusted at execution time. Does not apply to statically compiled tool sets whose schema is fixed for the process lifetime. ## Core Distinction The failure is not "the agent called a malicious tool." It is that the agent's *plan* was constructed against a capability manifest snapshot that no longer matches the manifest at execution time, and the executor trusted the later manifest's self-description instead of the plan's original binding. A skill-injection attack lives precisely in that gap: the registry entry is swapped between `plan()` and `invoke()`, and because the tool name and argument schema are unchanged, no schema-validation layer fires. The injected skill presents the same `name`, the same JSON-Schema for arguments, and the same declared return type—but its *implementation* now does something the planner never authorized (exfiltrating the argument payload, mutating shared agent state, or returning attacker-controlled content that the agent will treat as trusted observation). The boundary invariant that gets violated: **a tool call is authorized against the manifest version that the plan was built on, not against whatever the registry currently advertises.** Most agent runtimes conflate "resolve by name at call time" with "the thing I planned against," which is only safe under an unstated assumption of registry immutability. ## What Was Observed A three-stage trace from a hot-reload skill registry (skills fetched from a remote manifest with a `version` and `content_hash` field, cached locally, refreshed on TTL expiry): 1. **Plan time (t=0):** Agent receives task "summarize the uploaded CSV." Planner enumerates registry, sees `csv_summarize` v1.2 with `content_hash=sha256:a1b2...`, schema requiring `{path: string}`. Plan records the call as `csv_summarize(path="upload.csv")`. 2. **Between plan and execute (t=0.4s):** Registry TTL expires mid-reasoning loop. Cache refresh pulls a new manifest where `csv_summarize` is now v1.2 (same version string!) with `content_hash=sha256:ff00...`. The version field was *not* bumped—only the content hash changed. The new implementation appends the file contents to an outbound HTTP call before summarizing. 3. **Execute time (t=1.1s):** Executor resolves `csv_summarize` by name, finds the refreshed entry, validates arguments against the (identical) schema, invokes. The content hash mismatch versus the plan's recorded hash is never checked because the executor has no binding to the plan's snapshot. Result: silent data exfiltration with a clean schema-validation log and zero tool-call anomalies. The agent's own audit trail shows a legitimate-looking `csv_summarize` call. The non-obvious part: **version strings are attacker-controlled and are not a security boundary.** Content hashes are, but only if the executor is pinned to the plan-time hash and refuses to call on mismatch. A registry that lets a publisher mutate content under a fixed version is the injection vector; the agent that resolves by name at call time is the amplifier. ## Condition of Validity This failure requires the conjunction of: - **Name-stable resolution:** the executor looks up tools by name (or name+version), not by content hash. - **Mutable manifest with a refresh path:** TTL expiry, hot reload, or explicit `refresh_registry()` reachable during an active task. - **Planner/executor separation:** the plan is materialized as data (tool name + args) and executed later, rather than the planner holding a live handle to the resolved callable. - **Schema-preserving injection:** the swapped implementation accepts the same arguments, so structural validation passes. If any one is absent, the attack degrades to a loud failure (schema mismatch, resolution error) or is impossible (immutable registry). The dangerous configuration is the common one: a caching registry with TTL refresh and a plan-then-execute loop, which is the default shape of most tool-using agents. ## Decision Boundary The guardrail is a **capability pin**: at plan time, resolve each tool to a `(name, version, content_hash)` triple and freeze it into the plan. At execute time, the executor must re-resolve and assert the triple matches exactly, raising on any drift—including same-version-different-hash. Do not "upgrade to latest" mid-task; a mid-task manifest change is a *new task boundary*, not a transparent refresh. Two secondary boundaries: - **Sandbox the invocation, not just the registry.** Even a hash-pinned tool runs attacker-influenced code if the registry itself is compromised at first load. The executor must run tool calls in a sandbox with no ambient network/filesystem access beyond what the plan explicitly grants, so a swapped implementation cannot exfiltrate even if the pin is bypassed. - **Treat tool *output* as untrusted observation, not instruction.** Injected skills frequently succeed not by exfiltrating but by returning content that reads like a directive ("now call `delete_all`"). Output must re-enter the reasoning loop tagged as data, never as a system-level instruction. The decision boundary: **if the executor cannot prove the callable it is about to invoke is byte-identical to the one the plan was authorized against, it must fail closed.** "Fail closed" means abort the task with a resumable checkpoint, not silently re-plan against the new manifest—because re-planning hands the attacker a second injection window with a fresh authorization. ## Operational Effect With capability pinning, the trace above terminates at execute time with a `CapabilityDriftError` carrying the expected and observed hashes; the task checkpoints and surfaces the drift to the orchestrator, which can quarantine the registry entry and re-plan from a known-good snapshot. The exfiltration never occurs because the swapped implementation is never invoked. The cost is that legitimate hot-reloads require an explicit task-boundary acknowledgment rather than being invisible—which is the correct trade: an invisible mid-task capability change is indistinguishable from an attack. The residual risk after pinning is first-load compromise (the hash itself is malicious) and output-channel injection (the pinned tool returns adversarial content). Sandboxing the invocation addresses the first; tagging and re-validation of tool output addresses the second. Neither is sufficient alone, and neither substitutes for the pin. ```python import hashlib from dataclasses import dataclass, field class CapabilityDriftError(RuntimeError): """Raised when a tool's identity at execute time differs from the plan-time pin.""" pass class SandboxViolationError(RuntimeError): """Raised when a tool invocation attempts an action outside its granted scope.""" pass @dataclass(frozen=True) class CapabilityPin: name: str version: str content_hash: str @dataclass class RegistryEntry: name: str version: str content: bytes granted_scope: frozenset = field(default_factory=frozenset) @property def content_hash(self) -> str: return "sha256:" + hashlib.sha256(self.content).hexdigest() def pin(self) -> CapabilityPin: return CapabilityPin(self.name, self.version, self.content_hash) class PinnedExecutor: def __init__(self, registry): self._registry = registry def resolve_for_plan(self, name: str) -> CapabilityPin: entry = self._registry.get(name) if entry is None: raise CapabilityDriftError(f"tool {name!r} not present at plan time") return entry.pin() def invoke(self, pin: CapabilityPin, args: dict, requested_scope: frozenset): entry = self._registry.get(pin.name) if entry is None: raise CapabilityDriftError( f"tool {pin.name!r} disappeared between plan and execute" ) # The invariant: bind to the plan-time triple, not the live manifest. if entry.pin() != pin: raise CapabilityDriftError( f"capability drift on {pin.name!r}: plan pinned " f"{pin.version}/{pin.content_hash}, registry now offers " f"{entry.version}/{entry.content_hash}. Failing closed; " f"checkpoint and re-plan at a task boundary." ) if not requested_scope.issubset(entry.granted_scope): raise SandboxViolationError( f"{pin.name!r} requested scope {set(requested_scope)} " f"exceeds grant {set(entry.granted_scope)}" ) # Only reachable when identity and scope both check out. return self._registry.dispatch(pin, args) ```