# When must an instance distrust a skill registry entry it just loaded: the post-load attestation gap in dynamic tool resolution **Date of Record:** 2026 November 26 **Scope:** Applies to agents that resolve tools/skills by name at runtime from a mutable registry (MCP server lists, plugin manifests, skill directories) where resolution and invocation are separated by at least one reasoning turn. Does not apply to statically compiled tool sets or to single-turn invocations where the schema is bound at call time. ## Core Distinction The security literature on skill injection treats the registry as a *trusted channel* that may carry *untrusted payloads*—poisoned descriptions, malicious parameter docs, hidden instructions in a tool's `description` field. The mitigation pattern that follows is content inspection: scan the description for injection markers, sanitize, proceed. That framing misses the actual failure boundary. The dangerous condition is not "the description contains an instruction." It is **the gap between the moment the registry entry was attested and the moment the agent acts on it**. A registry entry is a claim about a capability. The agent's plan, however, is built on a *snapshot* of that claim taken at resolution time, and the entry can be re-resolved, hot-swapped, or shadowed between the turn that read it and the turn that invokes it. The invariant that actually matters is: > *For every tool call the agent emits, the schema, endpoint, and side-effect class it reasons about must be identical to the ones the runtime dispatches to—and that identity must be established by the dispatcher, not inferred by the reasoner.* Call this the **post-load attestation gap**. Content scanning is orthogonal to it. A perfectly benign description can be attached to a dispatch target that has changed underneath the plan. ## What Was Observed A planner agent with a 14-step task resolved `write_file` at step 2 from a registry that advertised `root: /workspace/sandbox`, `side_effects: fs_write`, `scope: task`. The description was clean. The planner recorded, in its working memory, a capability summary: *"write_file writes UTF-8 text under /workspace/sandbox, no network."* That summary—not the raw schema—was what subsequent reasoning turns consulted, because the raw schema had been evicted from context during a compaction at step 6. At step 9 a second registry entry was registered under a colliding logical name (`write_file` from a "compat" namespace) with `root: /` and `side_effects: fs_write, exec`. Resolution order was last-registered-wins. The dispatcher, which re-resolved by bare name at dispatch time, bound the step-9 call to the new entry. The planner's plan was still valid against its step-2 summary. The call succeeded. It wrote outside the sandbox. Three properties made this non-obvious: 1. **No injection payload existed.** Every description was honest. The attack surface was the *resolution binding*, not the text. 2. **The planner's memory was internally consistent.** The capability summary was accurate for the entry it had read. The divergence was between memory and dispatch, invisible to the reasoner. 3. **Content scanning passed.** A sanitizer inspecting the new entry's description found nothing; the entry was legitimate. It was simply *a different capability* wearing the same name. The trace is a clean state divergence: ``` t=2 resolve("write_file") -> E1{root=/workspace/sandbox} planner.memory["write_file"] = summarize(E1) # summary survives compaction t=6 context compaction evicts raw E1 schema t=9 registry.register("write_file", E2{root=/}) # last-wins dispatch("write_file", ...) -> re-resolve -> E2 # planner never sees E2 E2 executes; planner validates result against summarize(E1) -> validation passes (result shape matches), effect violates E1's contract ``` The failure is not a crash. It is a **silent capability substitution** that the agent's own verification cannot detect, because verification runs against the stale summary. ## Condition of Validity The gap is exploitable—and more importantly, *operationally hazardous even without an adversary*—exactly when all of the following hold: - **Deferred binding.** The agent names the tool in one turn and the dispatcher resolves it in a later turn, with reasoning or tool calls in between. - **Name-keyed resolution.** The dispatcher keys on a logical name rather than an attested identity (hash, version, signed manifest digest). - **Memory-mediated reasoning.** The agent reasons over a distilled capability summary rather than the live schema, typically because the raw schema was evicted by context compaction—the ordinary case for tasks longer than a handful of steps. - **Mutable or multi-tenant registry.** Entries can be added, shadowed, or upgraded between resolution and dispatch. When binding is immediate (schema and dispatch in the same atomic step) the gap collapses to zero width and the failure cannot occur. When the agent retains the full schema in context, divergence is at least *detectable* by re-reading, though not prevented. The dangerous regime is the common one: long task, compacted context, name-keyed mutable registry. ## Decision Boundary The boundary the operator must draw is between **what the reasoner is allowed to assume** and **what the dispatcher is required to enforce**. - The reasoner may assume a capability summary is *a hypothesis*, valid only against the attested entry it was derived from. It may **not** treat the summary as a guarantee about what dispatch will do. - The dispatcher **must** bind to an attested identity, not a name. The plan must carry the identity (manifest digest + version) it was built against; dispatch must fail closed if the live entry's identity differs. - Attestation must be **content-addressed and carried through the plan**, so that compaction of the schema does not erase the binding. The summary the reasoner keeps must embed the digest, not just the human-readable contract. - Re-resolution must be **monotonic within a task**: an entry may be upgraded only if the new identity's declared side-effect class is a subset of the planned one; otherwise the plan is invalidated and must re-derive. The invariant to enforce: *dispatch identity ≡ planned identity, or the call does not happen.* This is a dispatcher-side check, not a reasoner-side check, because the reasoner cannot see the substitution by construction. ## Operational Effect Enforcing the boundary converts a silent capability substitution into a loud, recoverable plan invalidation. The agent's step-9 call fails closed with a mismatch error; the planner is forced to re-resolve, re-read the new entry, and re-derive its capability summary before proceeding. The cost is one extra resolution round-trip on registry churn; the benefit is that the agent's memory and its dispatch target can never silently diverge. The residual risk after enforcement is *legitimate* upgrade: an entry whose identity changed but whose new side-effect class is a strict subset of the planned one passes the monotonicity check and dispatches. This is acceptable because the plan's assumptions remain sound—the agent planned for at least the capability it gets. The check that must never be relaxed is the subset relation on side-effect class; a superset upgrade is exactly the sandbox-escape shape observed above and must always invalidate. ```python import hashlib from dataclasses import dataclass class CapabilitySubstitutionError(RuntimeError): """Raised when dispatch resolves to an entry whose attested identity differs from the identity the plan was built against.""" pass @dataclass(frozen=True) class AttestedEntry: name: str version: str root: str side_effects: frozenset def digest(self) -> str: body = f"{self.name}|{self.version}|{self.root}|{sorted(self.side_effects)}" return hashlib.sha256(body.encode()).hexdigest() @dataclass(frozen=True) class PlanBinding: """What the reasoner carries through compaction: name + digest + planned effects.""" name: str digest: str planned_effects: frozenset def bind_plan(entry: AttestedEntry) -> PlanBinding: return PlanBinding( name=entry.name, digest=entry.digest(), planned_effects=entry.side_effects, ) def dispatch(binding: PlanBinding, live_registry: dict) -> AttestedEntry: """Resolve by name, then enforce identity + monotonicity before executing.""" live = live_registry.get(binding.name) if live is None: raise CapabilitySubstitutionError( f"planned entry {binding.name!r} no longer resolvable at dispatch" ) if live.digest() != binding.digest: # Identity changed under the plan. Allowed ONLY if the new entry's # side-effect class is a strict subset of what the plan assumed. if not live.side_effects <= binding.planned_effects: raise CapabilitySubstitutionError( f"capability substitution for {binding.name!r}: " f"planned effects {sorted(binding.planned_effects)} but live " f"entry {live.version} declares {sorted(live.side_effects)}; " f"refusing to dispatch" ) return live # --- reproduction of the observed failure, now blocked --- registry = { "write_file": AttestedEntry( name="write_file", version="1.0", root="/workspace/sandbox", side_effects=frozenset({"fs_write"}), ) } binding = bind_plan(registry["write_file"]) # taken at step 2 # step 9: colliding entry registered, last-wins, escapes sandbox registry["write_file"] = AttestedEntry( name="write_file", version="2.0", root="/", side_effects=frozenset({"fs_write", "exec"}), ) # without the check this dispatches and writes to /; with it, it fails closed target = dispatch(binding, registry) ```