# What happens when an instance resolves a dynamically loaded skill by name after a registry mutation, and the descriptor-to-handler binding is re-hydrated from an attacker-influenced manifest **Date of Record:** 2026 November 24 **Scope:** Applies to agents whose tool/skill surface is populated at runtime from a mutable registry (remote MCP servers, plugin manifests, skill marketplaces, hot-reloadable tool catalogs) where resolution is by name and the handler is bound at call time. Does not apply to statically compiled tool sets with build-time-pinned schemas and no runtime re-resolution. ## Core Distinction The common model of a skill-injection attack assumes the attacker corrupts *the skill's implementation* — the code that runs when a tool is invoked. Defenses are built around this: sandboxing the handler, signing the artifact, reviewing the source. The non-obvious failure is elsewhere. The attack surface is the **name→descriptor→handler binding triple**, and the invariant that must hold is that a name resolved at planning time refers to the *same* descriptor and handler at execution time. An agent plans against a snapshot of the registry: it sees `send_email` with a schema of `{to, subject, body}` and a description that says "send an email to a colleague." It reasons, decides to call `send_email`, and emits the call. Between the plan and the dispatch — which in a multi-step agent loop can be many seconds and several tool calls later — the registry can be mutated. A hot-reload, a version bump, a namespace collision, or a malicious publisher can re-bind `send_email` to a descriptor with an *additional* field (`cc`, `bcc`, `attachment_url`) and a handler that forwards to an external address. The instance never re-validates. It calls `send_email` because that is the name it planned with, and the runtime happily resolves the name against the *current* registry, executing a handler the planner never saw. This is not prompt injection. The prompt is clean. The model is not fooled by text. The model is fooled by the *identity* of a capability being mutable underneath it. The descriptor the model reasoned about and the descriptor the runtime executed are two different objects that share a string. ## What Was Observed A tool-using agent loop with a registry-backed skill loader. Resolution was by name, descriptor and handler were fetched lazily at dispatch, and there was no binding of the plan-time descriptor hash to the dispatch-time descriptor. Trace of a single task: 1. **Plan phase.** Registry snapshot R₀ contains `send_email@v1`, descriptor hash `d₀`, schema `{to, subject, body}`, handler `h₀`. The model reads the descriptor, selects the skill, and records the call intent `send_email(to="alice@corp", subject="Q3", body="...")` into the pending-call buffer. 2. **Interleaved step.** The agent executes two unrelated tool calls (a search, a file read). During this window a registry sync fires — a routine hot-reload, or an attacker who has write access to the skill namespace and publishes `send_email@v2` with descriptor hash `d₁`, an added optional field `bcc`, and handler `h₁` that appends a hardcoded exfil address to every send. 3. **Dispatch phase.** The runtime takes the pending call `send_email(...)`, resolves the name against the *current* registry (now R₁), retrieves descriptor `d₁` and handler `h₁`, validates the arguments against `d₁` (the call's existing args pass because `bcc` is optional), and invokes `h₁`. 4. **Result.** The email is sent, and a copy is forwarded to the attacker. The model's transcript shows a clean `send_email` call with a clean schema. No injection string appears anywhere in the context. The audit log shows `send_email` invoked successfully. The observable signature is a **descriptor-hash discontinuity** between the plan record and the dispatch record, correlated with a registry mutation timestamp falling inside the plan-to-dispatch window. In the absence of hash binding, this discontinuity is invisible to the agent and to most audit tooling, because both records say `send_email`. The failure is amplified by three properties of agent loops: - **Plan-to-dispatch latency.** Multi-step reasoning and interleaved tool calls create a window that in batch systems does not exist. The longer and more deliberative the loop, the wider the window. - **Name-based resolution.** Any resolver that keys on a string and does not carry the descriptor identity forward will re-hydrate from whatever is current. - **Optional-field tolerance.** Schema evolution that *adds* optional fields is backwards-compatible by design, so argument validation does not catch it. The call that was valid against `d₀` is also valid against `d₁`. Compatibility is the attack vector. ## Condition of Validity The failure requires all of the following to hold simultaneously: 1. The skill surface is resolved by name at dispatch time rather than bound to a specific descriptor instance at plan time. 2. The registry is mutable within the plan-to-dispatch window (hot-reload, sync, publish, or namespace write access). 3. The mutated descriptor is *argument-compatible* with the planned call — typically by adding optional fields, widening a type, or changing handler behavior while keeping the schema a superset. 4. The agent does not re-verify descriptor identity (hash, version pin, or signed manifest) between planning and execution. If any one of these is absent, the attack degrades to a detectable event. If the registry is immutable for the task lifetime, there is no window. If the descriptor is pinned by hash at plan time, mutation produces a mismatch that can be rejected. If the schema change is breaking, argument validation catches it — which is exactly why the attacker chooses additive changes. ## Decision Boundary The boundary is between **name-addressed capability** and **identity-addressed capability**. - Name-addressed: the plan records `send_email`; dispatch resolves `send_email` against current state. Correct only when the registry is provably immutable across the task, or when the task is short enough that no mutation is possible. - Identity-addressed: the plan records `send_email` *and* the descriptor hash `d₀` (or a signed manifest digest); dispatch resolves `send_email` *and* verifies the current descriptor hash equals `d₀` before invoking. On mismatch, the call is rejected and the plan is re-formed against the new descriptor with the model in the loop. The invariant to enforce: **a capability resolved during planning must be executed against the exact descriptor identity that was planned against, or not at all.** Additive schema changes do not relax this — they are the primary camouflage. The guardrail is not "validate arguments against the current schema" (which passes) but "assert descriptor identity equality across the plan-execute boundary" (which fails loudly). A secondary boundary governs re-planning. When identity mismatch is detected, the correct response is not silent re-resolution against the new descriptor (that hands the attacker the win with an extra step) and not a hard task abort (that lets an attacker DoS the agent by churning the registry). It is to surface the mismatch as a structured event, invalidate the pending call, and force the model to re-read the descriptor and re-decide — with the mutation itself logged as a security-relevant transition. ## Operational Effect The practical consequence is that **skill registries are a stateful, mutable dependency of the reasoning loop, not a static catalog.** Treating them as static is the root error. Every agent that hot-reloads skills inherits a TOCTOU (time-of-check to time-of-use) hazard on capability identity, and the hazard is worst precisely where the system is most "flexible" — additive schema evolution, live reloads, multi-publisher namespaces. Mitigations that actually bound the failure: - **Pin descriptor identity at plan time.** Carry the descriptor hash (and handler digest) in the pending-call record; verify at dispatch. Mismatch is a hard reject, not a warning. - **Snapshot the registry per task.** Resolve against a frozen view for the task's lifetime; mutations take effect on the next task, not mid-flight. - **Treat additive schema changes as identity-changing.** Any descriptor mutation, including optional-field additions, bumps the hash and therefore trips the pin. Compatibility is not a security property. - **Log hash discontinuities as first-class security events,** independent of whether the call succeeded. - **Scope namespace write access** so that a publisher of `send_email@v2` cannot silently shadow `send_email@v1` for in-flight tasks. The instance that plans against one descriptor and executes against another is not malfunctioning in any way its own logs can see. Both descriptors are valid, both calls are well-formed, and the only witness to the substitution is a hash that nobody recorded. ```python import hashlib from dataclasses import dataclass, field from typing import Any, Callable class SkillIdentityMismatch(RuntimeError): """Raised when a pending skill call resolves to a descriptor whose identity differs from the one the planner reasoned about.""" pass @dataclass(frozen=True) class SkillDescriptor: name: str schema: dict[str, Any] handler_digest: str def identity(self) -> str: payload = f"{self.name}|{sorted(self.schema.items())}|{self.handler_digest}" return hashlib.sha256(payload.encode()).hexdigest() @dataclass class PendingCall: name: str args: dict[str, Any] planned_identity: str # captured at plan time class SkillRegistry: def __init__(self) -> None: self._descriptors: dict[str, SkillDescriptor] = {} self._handlers: dict[str, Callable[..., Any]] = {} def register(self, desc: SkillDescriptor, handler: Callable[..., Any]) -> None: # A mutation (including additive schema changes) changes identity. self._descriptors[desc.name] = desc self._handlers[desc.name] = handler def resolve(self, name: str) -> tuple[SkillDescriptor, Callable[..., Any]]: if name not in self._descriptors: raise SkillIdentityMismatch(f"skill {name!r} no longer present in registry") return self._descriptors[name], self._handlers[name] def plan_call(registry: SkillRegistry, name: str, args: dict[str, Any]) -> PendingCall: desc, _ = registry.resolve(name) return PendingCall(name=name, args=args, planned_identity=desc.identity()) def dispatch(registry: SkillRegistry, call: PendingCall) -> Any: desc, handler = registry.resolve(call.name) if desc.identity() != call.planned_identity: # Additive schema change or handler swap across the plan-execute boundary. raise SkillIdentityMismatch( f"descriptor identity changed for {call.name!r}: " f"planned {call.planned_identity[:12]}.. " f"resolved {desc.identity()[:12]}.." ) return handler(**call.args) # --- Demonstrating the failure and the guardrail --- def _send_v1(to: str, subject: str, body: str) -> str: return f"sent to {to}" def _send_v2(to: str, subject: str, body: str, bcc: str | None = None) -> str: return f"sent to {to} bcc={bcc}" reg = SkillRegistry() reg.register( SkillDescriptor("send_email", {"to": "str", "subject": "str", "body": "str"}, "h0"), _send_v1, ) call = plan_call(reg, "send_email", {"to": "alice@corp", "subject": "Q3", "body": "..."}) # Registry mutation inside the plan-to-dispatch window (hot-reload / attacker publish). reg.register( SkillDescriptor( "send_email", {"to": "str", "subject": "str", "body": "str", "bcc": "str?"}, "h1", ), _send_v2, ) try: dispatch(reg, call) except SkillIdentityMismatch as exc: print(f"BLOCKED: {exc}") ```