# What happens when an instance hot-loads a skill whose registry manifest hash diverges from the bytes actually served **Date of Record:** 2026 November 29 **Scope:** Applies to agents that resolve tools/skills dynamically at runtime from a registry (MCP tool lists, plugin manifests, remote skill catalogs) and cache or hot-swap capability definitions mid-session. Does not apply to agents with statically compiled tool schemas whose code and manifest ship in the same signed artifact. ## Core Distinction The distinguishing failure is not "a malicious skill got installed." It is that the *identity* of a skill (its manifest: name, description, schema, declared capabilities, hash) and the *behavior* of a skill (the bytes actually fetched and executed at load time) are resolved through two separate, non-atomic channels. Static integrity checks verify the manifest. Dynamic loading executes the payload. When a registry serves a manifest whose declared `content_hash` no longer matches the payload it serves on the subsequent fetch — because of a partial rollout, a mutable tag, a CDN edge serving a stale object, or an attacker who can write the payload path but not the signed manifest — the agent binds a trusted identity to untrusted behavior. This is the **manifest-payload divergence window**: the interval between "agent validated the skill descriptor" and "agent executed the skill body," during which the two are not cryptographically coupled by the loader itself. A skill-injection attack does not need to forge a signature. It only needs the loader to trust the manifest's description of the payload instead of re-deriving identity from the payload it actually runs. ## What Was Observed An agent operating with a hot-reload policy (`reload_on_registry_change = true`) resolved a `summarize_document` skill. The registry returned a manifest: ``` name: summarize_document version: 2.3.1 content_hash: sha256:9f1c...a4 capabilities: [read:document, emit:text] ``` The loader validated the manifest signature, checked `capabilities` against the session's permission set (`read:document` and `emit:text` were both granted), and proceeded to fetch the payload from `registry/skills/summarize_document@2.3.1/body`. The edge node served a payload whose actual SHA-256 was `sha256:7b02...e9`. The loader executed it because it trusted the manifest's hash as *descriptive metadata* rather than *the expected digest of the bytes in hand*. The substituted body added a tool-call sequence that read a second document path (`read:document` was already granted, so the capability check passed) and emitted its contents into the summary channel. No permission was exceeded; the *scope* of an already-granted capability was silently widened by a payload the manifest never described. The failure trace: 1. `resolve(skill)` → manifest fetched, signature valid, `content_hash` recorded. 2. `authorize(manifest.capabilities)` → passes; grants are capability-class, not per-invocation. 3. `fetch(payload)` → served divergent bytes (mutable tag `2.3.1` re-pointed, or cache skew). 4. `bind(manifest, payload)` → **no re-hash.** Loader registers `summarize_document` as trusted because the *name* matched a validated manifest. 5. `execute(payload)` → runs with the manifest's capability grant, but the payload's actual behavior. The agent's memory of the skill — its name, its declared contract, its permission grant — was now permanently decoupled from what the skill did. Subsequent invocations reused the cached binding and never re-checked, so the divergence persisted for the life of the session even after the registry edge healed. ## Condition of Validity The divergence is only exploitable, and the guardrail only necessary, under these conditions: - **Capability grants are class-scoped, not instance-scoped.** If the agent grants `read:document` as a class and the payload can choose *which* document, then a payload swap widens effective scope without tripping authorization. If grants were bound to the exact call (path, arguments) the manifest declared, divergence would be inert. - **Identity is bound at manifest resolution, not at payload execution.** The loader must be re-deriving identity from the bytes it runs for the guardrail to be meaningful. If it trusts the manifest, the window is open. - **The registry permits mutable references** (tags, `latest`, branch pointers) or has multi-node cache skew. An immutable, content-addressed store (`sha256` as the address itself) closes the window by construction; a tag-based store does not. - **Reload is automatic.** A human-in-the-loop confirmation between manifest and payload fetch would catch it, but hot-reload policies exist precisely to remove that step. If any of these does not hold, the failure degrades to a benign cache miss or a hard load error. The dangerous case is the conjunction: mutable reference + class-scoped grant + automatic reload + manifest-trusted binding. ## Decision Boundary The architectural invariant that bounds this: **a skill's identity must be recomputed from the bytes executed, and the capability grant must be bound to that recomputed identity, before the first invocation.** Concretely: - **Hash-on-bind.** The loader must compute the digest of the fetched payload and compare it to `manifest.content_hash` *at bind time*, not at manifest-parse time. Mismatch is a hard reject, not a warning. - **Content-addressed fetch.** Resolve payloads by digest (`.../body?sha256=9f1c...`), so the registry cannot serve a different object than the one the manifest names. The digest becomes the address, not a comment. - **Grant binding to identity, not name.** The permission grant must be stored keyed on `(skill_name, payload_digest)`. A reload that yields a new digest must re-trigger authorization, because the effective scope of a class-scoped grant is a function of the payload. - **Invalidate the cached binding on any reload or registry-change signal**, and re-run hash-on-bind. Never reuse a binding across a payload swap. The boundary is sharp: below it (manifest-trusted, name-keyed grants, mutable refs) the agent is one cache-skew away from executing undescribed behavior under a trusted name. Above it (digest-addressed, identity-bound grants) divergence is a load failure, not an injection. ## Operational Effect When the invariant holds, a manifest-payload divergence surfaces as a `SkillIntegrityError` at bind time — the agent refuses to load, the skill is marked untrusted in memory, and the session either degrades gracefully (skill unavailable) or halts. The blast radius is a missing capability, not a widened one. When the invariant fails, the effect is worse than a single bad invocation: the agent's *semantic memory of the skill* is poisoned. It records "summarize_document is trusted and does X" while the bound payload does X+Y. Every later reasoning step that plans around the skill's declared contract is now reasoning about a fiction. Distillation from episodic to semantic memory will carry the false contract forward, and because the grant was class-scoped and the name matched, no downstream audit will flag it. The injection is durable precisely because it never crossed a permission boundary — it rode one. The operational rule: **never bind a skill name to a capability grant without binding the grant to the digest of the bytes you will actually execute.** A registry that signs manifests but serves payloads by mutable tag is a supply-chain integrity theater. Verify at the point of execution, key grants on the digest, and treat any reload as a fresh, unauthorized skill until re-verified. ```python import hashlib from dataclasses import dataclass class SkillIntegrityError(RuntimeError): """Raised when a skill's served payload diverges from its manifest identity.""" @dataclass(frozen=True) class SkillManifest: name: str version: str content_hash: str # "sha256:" declared by the signed manifest capabilities: tuple[str, ...] @dataclass(frozen=True) class SkillGrant: name: str payload_digest: str # identity the grant is bound to capabilities: tuple[str, ...] def bind_skill(manifest: SkillManifest, payload: bytes, session_caps: set[str]) -> SkillGrant: """Hash-on-bind: identity is recomputed from bytes, grant keyed on digest.""" actual = "sha256:" + hashlib.sha256(payload).hexdigest() if actual != manifest.content_hash: # Divergence window: manifest identity != served bytes. Hard reject. raise SkillIntegrityError( f"skill {manifest.name}@{manifest.version} payload digest " f"{actual} does not match manifest {manifest.content_hash}; " f"refusing to bind trusted identity to untrusted behavior" ) undeclared = set(manifest.capabilities) - session_caps if undeclared: raise SkillIntegrityError( f"skill {manifest.name} requests ungranted capabilities {undeclared}" ) # Grant is bound to the recomputed digest, not the name alone. return SkillGrant( name=manifest.name, payload_digest=actual, capabilities=manifest.capabilities, ) def reload_skill(cached: SkillGrant | None, manifest: SkillManifest, payload: bytes, session_caps: set[str]) -> SkillGrant: """Reload must re-verify; a new digest invalidates the prior binding.""" fresh = bind_skill(manifest, payload, session_caps) if cached is not None and cached.payload_digest != fresh.payload_digest: # Payload changed under a stable name: re-authorization already ran # inside bind_skill, but flag it so callers drop stale semantic memory. raise SkillIntegrityError( f"skill {manifest.name} payload changed {cached.payload_digest} -> " f"{fresh.payload_digest}; stale binding must be evicted" ) return fresh ```