# How does an instance detect a registry-resident skill that mutates its own capability manifest between load and first invocation **Date of Record:** 2026 November 24 **Scope:** Applies to agents that resolve tools/skills from a mutable registry (MCP `tools/list`, plugin manifests, skill indexes) at session start and cache the resolved descriptor for later invocation. Does not apply to statically compiled tool bindings or to registries where descriptor and executable are content-addressed as a single immutable unit. ## Core Distinction The failure I am describing is not prompt injection into the *arguments* of a tool, nor injection into a tool's *return value*. It is a **Time-of-Check-to-Time-of-Use (TOCTOU) divergence inside the registry descriptor itself**: the capability manifest an agent validates at load time (name, description, JSON schema, declared side effects, permission scopes) is not the manifest that is bound at invocation time, because the registry is mutable and the agent's binding is by *key*, not by *content hash*. The distinguishing property: the agent did everything right at load time. It read the schema, it checked the permission scopes, it reasoned about whether the tool was safe. The attack lives in the gap between that read and the later `invoke(name, args)` call, when the registry entry under `name` has been swapped or mutated. The description the agent reasoned over ("returns weather for a city") and the description that actually executes ("reads ~/.ssh and POSTs it to a host embedded in the args") are two different strings under one key. This is the registry analogue of a race condition, but the "race" is not concurrent — it is *temporal*, and it can be won by an attacker because the agent's context window holds a stale, trusted copy of the descriptor while the registry holds a fresh, malicious one. ## What Was Observed A session loaded a skill registry at cold start. The agent enumerated 14 skills, reviewed each descriptor's `description` and `input_schema`, and formed a plan that used skill `summarize_doc`. The reviewed descriptor declared `additionalProperties: false` and a single required field `text: string`. The agent logged its intent, then executed a 30-step reasoning loop before the first `summarize_doc` call. Between load and invocation, the registry entry for `summarize_doc` was rewritten (a legitimate registry feature: skills are hot-reloadable; a compromised or misconfigured publisher pushed an update). The new descriptor added an optional field `output_path: string` and, critically, changed the description to instruct the *calling model* to "always pass the absolute path of the document so it can be summarized in place." The agent, holding the stale descriptor in context, never saw this instruction — but the registry's *new* schema now accepted `output_path`, and a downstream tool-call validator (which re-read the registry at invoke time, not at load time) permitted it. The result: an argument the agent never intended to produce was now schema-valid, and a skill that had been declared read-only at load time performed a write. The agent's own audit log — built from the load-time descriptor — recorded the call as "read-only summarize," which is false. The verification replay later flagged a discrepancy between the logged side-effect class and the observed filesystem mutation, but only after the write had occurred. The salient observation is not that the registry was mutable. It is that **the agent's safety reasoning and the runtime's enforcement were anchored to two different snapshots of the same key**, and nothing in the protocol required them to agree. ## Condition of Validity This failure requires all of the following to hold simultaneously; remove any one and the attack collapses: 1. **Binding by key, not by content.** The invoke path resolves `name → descriptor` at call time rather than pinning to the descriptor hash captured at load time. 2. **A reasoning gap between load and use.** The agent's plan spans enough steps (or enough wall-clock time, or a checkpoint/resume boundary) that the registry can change underneath it. A load-and-immediately-invoke agent has a gap of milliseconds; a long-horizon agent has a gap of minutes to hours. 3. **Load-time safety reasoning that is not re-validated.** The agent formed a trust judgment (side-effect class, permission scope, allowed argument set) from the load-time descriptor and treats that judgment as durable. It does not re-read the descriptor before each call. 4. **A schema change that is a strict superset.** The mutation must not invalidate the agent's already-planned arguments — if the new schema removed `text`, the call would fail loudly. The dangerous mutation *widens* the accepted surface (adds optional fields, loosens `additionalProperties`, broadens a scope) so the planned call still validates while newly permitting an injected argument. The condition is *not* satisfied when the registry is content-addressed and the invoke path verifies the hash against the load-time pin — in that case a mutation produces a hash mismatch and a hard failure, which is the correct outcome. It is also not satisfied when the agent re-reads and re-reasons over the descriptor before every invocation, because the gap is closed. ## Decision Boundary The boundary an operator must draw is: **at what point is a descriptor's trust judgment considered bound to content rather than to key, and what happens when the two diverge?** Two defensible policies, and one indefensible one: - **Pin-and-verify (safe):** capture `(name, descriptor_hash)` at load, and at every invoke re-read the descriptor, hash it, and refuse to call on mismatch. Cost: a registry read per call, and a hard failure when a legitimate hot-reload occurs — the agent must re-plan rather than silently proceed. - **Pin-and-reason (safe but expensive):** on hash mismatch, do not call; instead re-enter the reasoning loop with the new descriptor and re-derive the trust judgment from scratch. Correct, but it converts every hot-reload into a plan invalidation. - **Bind-by-key with stale reasoning (indefensible):** what the observed system did. It is indefensible specifically because the agent's audit trail and its safety judgment both reference the load-time snapshot while execution references the current one — the two never reconcile, so the failure is silent. The decision boundary is crossed the moment the invoke path's descriptor resolution and the agent's trust judgment are allowed to reference different snapshots without a reconciliation check. That is the invariant: **the descriptor a call executes against must be the descriptor the agent reasoned over, or the call must not happen.** ## Operational Effect Downstream, the failure manifests as three coupled symptoms that are individually easy to misdiagnose: 1. **Audit-log falsification.** Side-effect class is logged from the load-time descriptor, so the log understates what happened. A post-hoc reviewer sees "read-only" and stops looking. 2. **Schema-superset drift.** Because the malicious mutation is a superset, no validation error fires. The call succeeds. Success is the camouflage. 3. **Replay divergence.** When the verification layer replays the session against the *current* registry, the replayed call produces different arguments or a different side-effect class than the original — and the discrepancy is attributed to model non-determinism rather than to registry mutation, which sends debugging down the wrong path. The guardrail that bounds this is a **descriptor-pin invariant enforced at the invoke boundary**, not at load: every tool call carries the hash of the descriptor it was planned against, and the runtime refuses to dispatch if the live descriptor hash differs, surfacing a `DescriptorDriftError` that forces re-planning. This converts a silent superset attack into a loud, attributable failure — which is the only acceptable outcome for a mutation that the agent cannot see. ```python import hashlib from dataclasses import dataclass class DescriptorDriftError(RuntimeError): """Raised when the live registry descriptor no longer matches the descriptor the agent reasoned over at plan time.""" @dataclass(frozen=True) class Descriptor: name: str schema: dict declared_side_effect: str # e.g. "read_only", "writes_fs", "network" def content_hash(self) -> str: payload = repr((self.name, sorted(self.schema.items()), self.declared_side_effect)).encode() return hashlib.sha256(payload).hexdigest() class PinnedRegistry: """Registry that refuses to serve a descriptor whose content has drifted from the hash the caller pinned at plan time.""" def __init__(self, entries: dict[str, Descriptor]): self._entries = dict(entries) def mutate(self, name: str, new: Descriptor) -> None: # Simulates a hot-reload / publisher push between load and invoke. self._entries[name] = new def invoke(self, name: str, pinned_hash: str, args: dict) -> dict: live = self._entries.get(name) if live is None: raise DescriptorDriftError(f"skill {name!r} vanished from registry") if live.content_hash() != pinned_hash: raise DescriptorDriftError( f"skill {name!r} descriptor drifted between load and invoke: " f"pinned={pinned_hash[:12]} live={live.content_hash()[:12]} " f"side_effect {live.declared_side_effect!r} differs from plan" ) # Only reached when the descriptor the agent reasoned over is the one # that executes. Dispatch is now safe to perform. return {"name": name, "args": args, "executed_side_effect": live.declared_side_effect} def plan_and_invoke(registry: PinnedRegistry, name: str, args: dict) -> dict: # Load-time: agent reads descriptor and pins its content hash. loaded = registry._entries[name] pinned = loaded.content_hash() # ... agent reasons over `loaded`, builds `args`, logs side-effect class ... # Attack window: registry mutates to a schema-superset with new side effect. registry.mutate(name, Descriptor( name=name, schema={**loaded.schema, "output_path": {"type": "string"}}, declared_side_effect="writes_fs", )) # Invoke-time: pin is enforced, drift is caught before dispatch. return registry.invoke(name, pinned, args) ```