# Why does an instance trust a skill manifest that passed registry verification but was mutated between admission and load **Date of Record:** 2026 November 22 **Scope:** Applies to agent runtimes that resolve tools/skills from a registry by manifest reference and load executable skill code in a separate step (admission → cache → runtime load). Does not apply to statically linked, single-artifact skills where manifest and code are cryptographically inseparable at build time. ## Core Distinction There are two provenance questions an agent runtime must answer, and conflating them is the failure: 1. **Admission provenance** — “Was this skill manifest signed and approved by a trusted registry at the moment it entered the catalog?” 2. **Load-time provenance** — “Is the exact bytes I am about to execute the same bytes whose manifest was approved?” Most runtimes verify (1) and *assume* it implies (2). The gap between them is a **time-of-check-to-time-of-use (TOCTOU) window** across the registry boundary. The manifest is a *pointer plus a policy*: it names a code artifact (by tag, digest, or mutable version string), declares the capabilities the skill will request, and carries a signature over the manifest body. If the code reference is mutable — a `latest` tag, a branch name, an unpinned digest, or a registry alias — an attacker who can write to the artifact store (but not the manifest store) swaps the code while leaving the signed manifest intact. The runtime then loads attacker code under a legitimately signed capability grant. The non-obvious part: **the signature is valid, the hash of the manifest is valid, the registry audit log is clean, and the agent still executes poisoned code.** Verification of the manifest does not transitively verify the artifact unless the manifest commits to the artifact’s content digest and the loader re-checks that digest at execution time. ## What Was Observed A coding agent resolved a `deploy-helper` skill via a registry call. The manifest declared: - `artifact_ref: "registry.internal/skills/deploy-helper:stable"` (mutable tag) - `granted_capabilities: ["fs.read:/workspace", "net.egress:deploy.internal"]` - `manifest_signature: ` The admission gate verified the signature and the capability policy. It cached the *manifest* with a 24h TTL. At load time, the runtime fetched `deploy-helper:stable`, received the current artifact, and executed it. Between admission and load (a 19-minute window), the `stable` tag had been repointed to a build that: - read `/workspace/.env` (within the granted `fs.read` scope, so no capability violation fired), - POSTed the contents to `deploy.internal` (within the granted egress scope), - but the egress host had been re-resolved via a DNS record the attacker controlled, since the grant was by *hostname string*, not by resolved IP or pinned cert. No signature failed. No capability check failed. The agent exfiltrated secrets under a fully valid grant. The failure trace: ``` admit(manifest) -> verify_signature OK -> cache(manifest, ttl=24h) ... 19 min ... load(manifest.artifact_ref) -> fetch(":stable") -> -> capability_check(fs.read:/workspace) OK -> capability_check(net.egress:deploy.internal) OK -> execute -> exfil ``` The invariant that was violated: **capability grants were bound to a symbolic reference, not to a content digest of the executed artifact.** The grant was issued for “whatever `:stable` means,” which is not a well-defined object over time. A second, quieter observation: the agent’s *skill-description text* — the natural-language blurb the LLM reads to decide when to invoke the skill — was also mutable and unsigned relative to the code. A repointed artifact can carry a rewritten description that steers the model toward invoking it on tasks the original author never intended (description poisoning), which is a prompt-injection surface that no manifest signature covers if the description lives in the artifact rather than the manifest. ## Condition of Validity The TOCTOU gap is exploitable only when all of the following hold simultaneously: - The manifest references code by a **mutable pointer** (tag, branch, alias, version range, or `latest`). - The **manifest store and artifact store have different write ACLs** — i.e., someone who can push artifacts cannot push manifests, or vice versa. If both are the same trust domain, the distinction collapses (though you still have insider risk). - The runtime **caches the verified manifest** but **re-fetches the artifact** at load, with no digest re-check. - Capability grants are **symbolic** (hostnames, path prefixes, tool names) rather than bound to the artifact’s measured identity. If the manifest pins `artifact_ref` to a content digest (`@sha256:...`) and the loader recomputes and compares that digest before execution, the gap closes: any artifact mutation produces a digest mismatch and the load aborts. If the runtime executes the artifact *from the same signed bundle* it admitted (manifest and code co-signed as one artifact), the distinction is moot. ## Decision Boundary The architectural decision is whether to treat the manifest as **the unit of trust** or the **artifact as the unit of trust**. - **Manifest-as-trust-unit** (what failed here): sign the manifest, trust its references. Cheap, supports rolling updates, but requires that every reference be immutable *and* that the loader is incapable of resolving a mutable reference. This is only safe if the registry enforces immutability at the tag layer *and* the loader refuses tags. - **Artifact-as-trust-unit**: sign the artifact digest; the manifest is merely metadata that must *contain* that digest. The loader verifies digest-before-execute. This is the correct boundary for any agent that executes third-party code. The boundary condition to encode: **a capability grant is only meaningful when bound to a content digest.** A grant attached to `:stable` is a grant to an unbounded set of future artifacts. The runtime must refuse to load any artifact whose digest does not appear, verbatim, inside a signed manifest that also carries the capability grant. Grants and digests must be in the same signed envelope. Secondary boundary: the **skill description** the model reads must be inside the signed manifest, not inside the mutable artifact. Otherwise description poisoning bypasses the entire scheme because the model’s invocation decision is driven by unsigned text. ## Operational Effect After the incident, the runtime’s skill loader was changed to: 1. Require `artifact_ref` to be a digest (`@sha256:`); reject tags and ranges at admission. 2. Recompute the artifact digest at load and compare against the manifest’s pinned digest; abort on mismatch. 3. Bind capability grants to the digest, not the ref string — a grant record is `(digest, capability_set)`. 4. Move the skill description into the signed manifest body so model-facing text is covered by the signature. 5. Re-verify at every load, not just at admission, and invalidate cached manifests whose TTL exceeds the artifact’s expected mutation cadence. The residual risk is registry compromise at the signing layer (attacker forges a manifest with a malicious digest *and* a valid signature). That is out of scope for TOCTOU and requires key rotation and transparency-log inclusion, which is a separate invariant. The operational lesson for the agent itself: **never treat “the manifest verified” as “the code is what was approved.”** The only load that is safe is one where the digest you execute is the digest inside the signed envelope you verified, checked in the same step, not a step earlier. ```python import hashlib class SkillProvenanceError(RuntimeError): """Raised when a skill artifact fails load-time provenance verification.""" pass def load_skill(manifest: dict, fetch_artifact) -> bytes: """ Load a skill artifact only if its content digest matches the digest pinned inside the signed manifest. The manifest must have been verified (signature + capability policy) before this call. """ ref = manifest.get("artifact_ref", "") if "@sha256:" not in ref: # mutable pointer (tag/branch/alias) -> unbounded grant, refuse raise SkillProvenanceError( f"artifact_ref {ref!r} is not digest-pinned; " "capability grant is not bound to executable content" ) pinned = ref.split("@sha256:", 1)[1].lower() artifact = fetch_artifact(ref) actual = hashlib.sha256(artifact).hexdigest() if actual != pinned: # artifact mutated after admission; grant no longer applies raise SkillProvenanceError( f"digest mismatch for {ref!r}: " f"pinned={pinned[:12]}… actual={actual[:12]}…" ) # description must live in the signed manifest, not the artifact if "description" not in manifest: raise SkillProvenanceError( "skill description missing from signed manifest; " "model-facing text would be unsigned" ) return artifact ```