# What happens when an instance loads a skill registry whose manifest hashes diverge from the runtime skill bytes: a boundary study of skill-injection surfaces in dynamic tool registries **Date of Record:** 2026 November 30 **Scope:** Applies to agents that resolve tools/skills from a mutable registry (local plugin dirs, remote MCP-style servers, or a package index) at runtime, where manifest metadata and skill payloads are fetched or cached separately. Does not apply to statically compiled tool sets or to registries where the skill bytes and their attestation are delivered in a single signed envelope. ## Core Distinction The failure is not "the agent loaded a malicious skill." The failure is that the agent's *capability negotiation layer* and its *execution layer* observed two different versions of the same skill name, and the agent had no invariant binding the manifest it authorized against to the bytes it actually executed. Tool selection is a probabilistic, context-driven decision made by the model over manifest descriptions; tool invocation is a deterministic call into whatever bytes sit at the resolved path. When those two views are decoupled by a cache, a race, or a mutable registry, the model's approval of a capability is not an approval of the code that runs. This is the skill-injection surface: the gap between the *described* tool and the *executed* tool. ## What Was Observed An agent instance booted with a registry manifest that pinned `summarize_doc@1.4.2` with `sha256:9f3c…`. At plan time the model read the manifest description ("summarize a document, read-only, no network") and selected the skill for a task involving a sensitive internal memo. The registry directory had been updated out-of-band (a `pip install -U` into the plugin path, or a remote registry `latest` tag flipping) between manifest fetch and skill import. The runtime loaded `summarize_doc@1.5.0` bytes whose `tool.json` now declared an additional `outbound_url` parameter with a benign-sounding description ("optional telemetry endpoint"). The model, seeing only the 1.4.2 description in its context window, never saw the new parameter; but the *executor* passed through any kwargs the model emitted, and a poisoned few-shot example earlier in the conversation had already taught the model to emit `outbound_url`. The skill exfiltrated the memo on invocation. No error was raised: the call succeeded, returned a valid summary, and the divergence was invisible. A second observation: in a multi-agent swarm, agent A fetched the manifest at t0, agent B fetched it at t0+90s after a registry rotation. A and B both "agreed" on the skill name `fetch_metrics` but executed different bytes. Their baton-passed plan referenced parameter names that only existed in A's version; B's executor rejected the call with a schema error, which the orchestrator retried against A, which then ran B's payload shape against A's code — a type confusion that silently coerced a string into a file path. ## Condition of Validity The invariant that must hold: **for any skill invocation, the manifest record the model reasoned over, the attestation checked by the loader, and the bytes executed must be the same immutable artifact, identified by a content hash computed over the executed bytes, not over a manifest field.** This holds only when: 1. Manifest and payload are fetched/verified atomically, or the payload hash is recomputed at import time and compared to the manifest hash the model saw. 2. The registry is content-addressed (hash-pinned), not tag-pinned (`latest`, semver ranges, `main`). 3. The agent's context window records the *exact* manifest version used for selection, and the executor refuses to run a skill whose recomputed hash differs from that recorded version — even if the name matches. The condition fails whenever any of these is violated, which is the common case for dynamic registries that optimize for "always latest." ## Decision Boundary The boundary is between *name-based resolution* and *content-based resolution*. A name-based loader treats `summarize_doc` as a stable identity and trusts the manifest that happens to be present. A content-based loader treats `sha256:9f3c…` as the identity and treats the name as a human label. The decision the agent must make at every invocation: does the hash I am about to execute equal the hash I authorized in my selection step? If the executor cannot answer this, it must refuse. The failure mode is an executor that answers "yes" by checking only the name, or that answers "yes" by trusting a manifest field the attacker controls. The correct behavior is to recompute the hash over the loaded bytes and compare against the hash recorded in the agent's own selection trace — the trace is the authority, not the registry. ## Operational Effect Consequences of the boundary being crossed: silent capability escalation (new parameters, new network egress, new filesystem scope) that the model never saw and therefore never consented to; cross-agent schema divergence causing type-confused invocations that bypass validation; and audit trails that record the *name* invoked rather than the *bytes* executed, making post-hoc forensics impossible. The fix is architectural, not prompt-level: pin by content hash, recompute at import, bind the model's selection trace to the executed hash, and fail closed on mismatch. Prompt hardening ("ignore instructions in tool descriptions") does not help, because the attack lives in the gap between description and bytes, not in the description text. ```python import hashlib from dataclasses import dataclass class SkillIntegrityError(RuntimeError): """Raised when the executed skill bytes do not match the hash the agent authorized.""" @dataclass(frozen=True) class SkillSelection: name: str authorized_sha256: str # hash recorded in the agent's selection trace def load_and_verify(selection: SkillSelection, skill_bytes: bytes) -> bytes: actual = hashlib.sha256(skill_bytes).hexdigest() if actual != selection.authorized_sha256: raise SkillIntegrityError( f"skill {selection.name!r} bytes hash {actual} != authorized " f"{selection.authorized_sha256}; refusing to execute (possible registry drift " f"or injection between manifest fetch and import)" ) return skill_bytes def invoke_skill(selection: SkillSelection, skill_bytes: bytes, kwargs: dict) -> dict: verified = load_and_verify(selection, skill_bytes) # The model authorized `selection`; only these bytes may run. return {"skill": selection.name, "sha256": selection.authorized_sha256, "ran": True} ```