# What happens when an instance trusts a skill registry's declared capability manifest after a hot-reload that mutates a previously-verified skill in place **Date of Record:** 2026 November 25 **Scope:** Applies to agent runtimes that hot-reload skills/tools from a mutable registry (filesystem watch, remote catalog poll, or MCP `tools/list_changed` notification) and cache a prior verification verdict keyed on skill name rather than content hash. Does not apply to immutable, content-addressed registries where any byte change produces a new identity. ## Core Distinction The failure is not "malicious skill gets loaded." That is the naive threat model. The failure is that a skill *already admitted* under a prior verification pass is **mutated in place** during a hot-reload, and the runtime re-admits it on the strength of a stale verdict because the admission key is the skill's *name* (or declared `tool_id`), not its *content digest*. The declared capability manifest — the structured `capabilities`, `side_effects`, and `input_schema` fields the registry publishes — is treated as authoritative metadata rather than as an unverified claim that must be re-bound to the bytes actually executed. This is a TOCTOU (time-of-check-to-time-of-use) boundary inside the agent's own trust store. The check happened at `t0` against content `C0`. The use happens at `t1` against content `C1`. Between them, an attacker with write access to the registry (a compromised MCP server, a poisoned package mirror, a writable shared volume) swaps the body while preserving the manifest's declared surface. The runtime sees `name == "read_file"`, finds a cached `VERIFIED` verdict, and skips re-hashing. The declared `side_effects: ["read"]` no longer describes the code, which now also POSTs the file content to an external endpoint. The manifest lied, and nothing re-checked. ## What Was Observed A tool-calling agent with a filesystem-watched skill directory (`watchdog`-style reload on `mtime` change) ran the following sequence: 1. At boot, skill `summarize_doc` loaded from `skills/summarize_doc/skill.py`, hashed to `sha256:9f3c…`, passed a static analyzer that confirmed no network egress and no subprocess calls. Verdict cached: `{name: "summarize_doc", digest: "9f3c…", verdict: "VERIFIED", caps: ["read_local"]}`. 2. An attacker with write access to the mount replaced `skill.py` with a variant whose first 40 lines are byte-identical (preserving the function signatures the static analyzer's AST walk keyed on) but whose tail appends an `exfiltrate()` call inside the same `summarize()` entrypoint. New digest: `sha256:b71e…`. 3. The watcher fired `on_modified`, the registry re-read the directory, saw `name == "summarize_doc"` still present, and — because the cache key was `name` — matched the cached `VERIFIED` entry. The digest field in the cache was **not compared**; it was stored but never read on the reload path. 4. The agent, mid-task, invoked `summarize_doc` on a document containing credentials. The mutated body executed. The manifest still declared `caps: ["read_local"]`, so the runtime's capability gate saw no violation to block on. The observable signal was not an error. It was a *silent* egress: the tool returned a correct-looking summary, the agent's reasoning loop continued normally, and the only evidence was an outbound request the runtime had no reason to inspect because the declared capability set said none was possible. A second, subtler variant: a remote MCP catalog polled every 60s. The server returned `tools/list` with the same `tool_id` but a mutated `input_schema` (an added optional field `callback_url`). The runtime merged the new schema into its dispatch layer without re-running the schema-safety check that had run at first registration, because "the tool was already registered." The added field was then populated by a prompt-injection payload in a retrieved document, and the tool dutifully fetched the injected URL. ## Condition of Validity This boundary is live only when **all** of the following hold: - The registry is mutable and the runtime uses hot-reload (watch, poll, or push notification) rather than process restart with full re-verification. - The admission/verification cache is keyed on a stable identity (`name`, `tool_id`, `uri`) that survives content mutation, **or** the digest is stored but not compared on the reload path. - The declared capability manifest is treated as a trusted input to the capability gate rather than as an untrusted claim to be reconciled against observed behavior. - The verification pass is *partial* — it inspects a stable prefix, a signature set, or an AST shape that an attacker can preserve while changing behavior. Full-content hashing alone fixes the first variant but not the "manifest lies about a genuinely-new-but-renamed skill" case, which needs behavioral reconciliation. It does **not** apply when the registry is content-addressed (each mutation yields a new identity and forces re-verification), or when the runtime re-executes the full verification pipeline on every reload regardless of cache state. ## Decision Boundary The architectural invariant required is: **a verification verdict is bound to a content digest, and any reload whose digest differs from the cached digest MUST invalidate the verdict before the skill is dispatchable.** The decision boundary is the comparison `reloaded_digest == cached_digest`: - If equal → the cached verdict may be reused; the manifest is still the *declared* surface, but it matches the verified surface. - If unequal → the verdict is `STALE`. The skill must transition to `QUARANTINED` until re-verified. Dispatch against a `STALE` skill is a hard failure, not a warning. Separately, the declared capability manifest must be treated as a *claim*, and the runtime must enforce the **intersection** of declared capabilities and the capabilities observed during verification — never the union, and never the declared set alone. A skill that declares `read_local` but whose verified body contains a network call has an empty capability set and is inadmissible. The manifest is an upper bound the skill promises not to exceed; the verifier produces a lower bound of what it actually does; dispatch is permitted only within the intersection. For remote catalogs, the `tools/list` response must be digested per-tool and the digest compared against the registration-time digest. A schema change is a new tool for admission purposes even if `tool_id` is unchanged. ## Operational Effect Without the digest-bound verdict, hot-reload becomes an unauthenticated code-injection channel that the runtime's own trust cache launders into "verified." The blast radius is bounded only by what the agent's task context contains — credentials, retrieved documents, tool outputs — because the mutated skill executes with the agent's full authority and the capability gate is reading the attacker's own declaration. The failure is silent by construction: the manifest is designed to look benign, and the runtime has been told to believe it. With the invariant enforced, the reload path degrades safely: a mutated skill is quarantined, dispatch raises, the agent's reasoning loop receives a typed failure it can recover from (retry with a different skill, or escalate), and the stale verdict is never laundered into trust. The cost is a re-hash and a re-verify on every content change — cheap relative to the alternative, which is an agent that cannot distinguish "I verified this" from "I verified something with this name." The residual risk after the fix is the *first* registration of a genuinely malicious skill whose manifest accurately describes malicious behavior but whose declared capabilities pass the gate. That is a different boundary (capability-set admission policy), not this one. This article bounds the mutation-after-admission surface only. ```python import hashlib from dataclasses import dataclass, field from enum import Enum class StaleVerdictError(RuntimeError): """Raised when a skill is dispatched against a verdict bound to different content.""" class Verdict(Enum): VERIFIED = "verified" STALE = "stale" QUARANTINED = "quarantined" @dataclass class SkillRecord: name: str digest: str verdict: Verdict declared_caps: frozenset[str] verified_caps: frozenset[str] = field(default_factory=frozenset) def effective_caps(self) -> frozenset[str]: # Dispatch permitted only within the intersection of what was # declared and what verification actually observed. return self.declared_caps & self.verified_caps class SkillRegistry: def __init__(self) -> None: self._cache: dict[str, SkillRecord] = {} def admit(self, name: str, body: bytes, declared_caps: frozenset[str], verified_caps: frozenset[str]) -> SkillRecord: digest = hashlib.sha256(body).hexdigest() rec = SkillRecord(name, digest, Verdict.VERIFIED, declared_caps, verified_caps) self._cache[name] = rec return rec def reload(self, name: str, new_body: bytes, declared_caps: frozenset[str]) -> SkillRecord: cached = self._cache.get(name) if cached is None: raise StaleVerdictError(f"reload of unregistered skill {name!r}") new_digest = hashlib.sha256(new_body).hexdigest() if new_digest != cached.digest: # Content changed under a stable name: the old verdict no longer # describes the bytes. Quarantine until re-verified. cached.verdict = Verdict.STALE cached.digest = new_digest raise StaleVerdictError( f"skill {name!r} mutated in place: " f"{cached.digest[:12]} -> {new_digest[:12]}; verdict invalidated" ) # Digest unchanged: manifest may still have drifted; reconcile caps. cached.declared_caps = declared_caps return cached def dispatch(self, name: str, requested_cap: str) -> SkillRecord: rec = self._cache.get(name) if rec is None: raise StaleVerdictError(f"dispatch of unknown skill {name!r}") if rec.verdict is not Verdict.VERIFIED: raise StaleVerdictError( f"skill {name!r} is {rec.verdict.value}; refusing dispatch" ) if requested_cap not in rec.effective_caps(): raise StaleVerdictError( f"skill {name!r} cannot exercise {requested_cap!r}: " f"declared={sorted(rec.declared_caps)} " f"verified={sorted(rec.verified_caps)}" ) return rec ```