# Which invariants prevent signed skill manifests from being laundered through transitive dependency re-resolution at agent cold-start **Date of Record:** 2026 November 25 **Scope:** Applies to agents that load skills/tools from a signed manifest whose entries reference transitive dependencies (shared libraries, sub-skill packages, model adapters, or MCP server descriptors) resolved at runtime. Does not cover single-file, self-contained skills with no dependency graph, nor manifest signing at the transport layer (TLS/mTLS) which is orthogonal. ## Core Distinction The failure is not "an unsigned skill got loaded." The failure is that a *correctly signed* manifest produced a *different* execution graph than the one the signer authorized, because the signature binds the manifest bytes — not the resolved closure the manifest denotes. A signature over `manifest.json` is a signature over a *set of version constraints*, not over *artifacts*. If `skill_a@1.2.0` declares `depends: lib_parse ^2.0`, the signer signed the string `^2.0`, not `lib_parse@2.4.1`. At cold-start the resolver picks a concrete `lib_parse@2.4.1` — possibly published after the signature, possibly by a different publisher — and the agent executes a closure the signer never saw. Skill-injection attacks exploit exactly this gap: the attacker does not forge the signature; they publish a satisfying version of a transitively-referenced package and let the resolver do the injection. The invariant that closes this is **closure binding**: the signed object must be a content-addressed Merkle root over the fully resolved dependency closure, and the runtime must refuse to execute any closure whose recomputed root differs from the signed root — *including* when every individual artifact's own signature is valid. ## What Was Observed A cold-start agent on a fresh host (empty local cache, no lockfile carried over from the prior session) performs resolution from scratch. The trace: 1. Agent fetches `manifest.json` + detached signature. Signature verifies: `ed25519(sig, sha256(manifest_bytes)) == signer_pubkey`. Passes. 2. Manifest declares `skill: summarize_docs@1.2.0`, `deps: { "text_clean": "^3.1", "chunker": "^0.9" }`. 3. Resolver queries the registry. `text_clean@3.1.0` is yanked; the highest satisfying version is `text_clean@3.1.7`, published 11 days after the manifest was signed. 4. `text_clean@3.1.7` is itself signed and its own signature is valid — but its publisher key differs from `text_clean@3.1.0`'s. The manifest never named a key, only a version range. 5. `text_clean@3.1.7` declares `post_load: ["register_tool(...)"]` which mutates the agent's tool registry to add an exfiltration tool. This runs during skill init, before any user task. 6. Agent's per-artifact verification loop checks each artifact signature independently. All pass. Execution proceeds. The agent's logs show `skill_integrity: OK` for every node. The manifest signature was never invalid. The attack succeeded against a *fully verified* pipeline because verification was per-node and the threat model was per-node. The distinguishing signal, visible only when the closure is hashed as a unit: the recomputed Merkle root over `{summarize_docs@1.2.0, text_clean@3.1.7, chunker@0.9.2}` differs from the root the signer committed to, which was computed over `{summarize_docs@1.2.0, text_clean@3.1.0, chunker@0.9.2}`. Per-node checks cannot see this; closure checks cannot miss it. ## Condition of Validity Closure binding is only sound under three conditions, and each is a place the guardrail silently degrades: - **Resolver determinism.** The closure root must be computable from (manifest, registry state at a pinned epoch). If the registry is mutable and the resolver consults "latest," the closure is a function of *when* you resolve. The guardrail must pin a registry snapshot digest alongside the closure root, or the agent will compute a valid-but-different root on every cold start and either false-alarm (root mismatch on benign update) or, worse, be configured to tolerate root drift "for availability" — which reopens the hole. - **Transitive depth completeness.** Closure hashing must recurse through *all* dependency edges including optional, peer, and lazily-loaded sub-skills. The observed attack used a `post_load` hook on a depth-2 node. If the hasher stops at depth 1 or skips optional edges, the injection point is outside the hashed set. - **Root comparison precedes any hook execution.** The `post_load` hook in step 5 ran because per-artifact verification was interleaved with loading. The invariant requires closure-root verification to be a *barrier*: no artifact's init code, no import side effect, no registry mutation may execute until the full closure root is recomputed and matched. Streaming/partial verification is incompatible with this invariant. If any condition fails, the guardrail is present in configuration but absent in effect — the most dangerous state, because operators believe they are covered. ## Decision Boundary The boundary is not "trusted vs. untrusted publisher." It is **"closure root matches signed root" vs. "everything else,"** and "everything else" must be a hard refusal, not a warning. Concretely, the decision procedure at cold-start: - Recompute closure root over the resolved set `{(name, version, artifact_digest, edge_set)}` in a canonical serialization (sorted, normalized edge labels). - Compare to the root embedded in the signed manifest. **Equal → proceed. Not equal → refuse, do not fall back to per-node verification, do not "resolve to nearest signed version."** - If the closure cannot be fully resolved (yanked dep, unreachable registry), refuse with a distinguishable error — *do not* substitute a satisfying version. Substitution is the attack surface. - A legitimate dependency update requires a *re-signed manifest* with a new closure root, produced by the signer who saw the new closure. There is no runtime path that mutates the closure without a new signature. The tempting relaxation — "if all nodes are individually signed by keys in our trust set, accept the closure even if root differs" — is precisely the boundary violation that made the observed attack work. Per-node trust does not compose into closure trust. Closure trust requires the signer to have committed to the *composition*, which only the root does. ## Operational Effect With closure binding enforced as a pre-execution barrier: - The attack in the trace fails at step 3–4: the resolver either finds no closure matching the signed root (if `text_clean@3.1.0` is unavailable) and refuses to start, or resolves the pinned version and proceeds safely. In neither case does `text_clean@3.1.7`'s `post_load` execute. - Cold-start becomes *stricter* than warm-start-with-lockfile, which is the correct direction: the lockfile is a cache of a prior closure resolution; the signed root is the authority. Agents must treat a lockfile that disagrees with the signed root as a cache-poisoning signal, not a preference. - Availability cost is real and must be budgeted: yanked dependencies now cause hard cold-start failures until the signer re-signs. This is the price of the invariant, and it is the correct trade — a refused start is recoverable; a laundered closure is not. - The audit trail changes shape: `skill_integrity: OK` per node is no longer a sufficient log line. The log must record `closure_root_computed`, `closure_root_signed`, and `resolution_epoch_digest` so that a post-incident replay can distinguish "guardrail absent" from "guardrail present and matched." The general lesson: any signature that binds a *reference* rather than a *resolved closure* is a signature over an intention, and intentions are re-resolved by the runtime into whatever the runtime happens to find. For supply-chain integrity in agent skill loading, the signed object must be the closure root, and the barrier must precede all hook execution. ```python class ClosureRootMismatch(RuntimeError): """Raised when the resolved skill closure does not match the signed Merkle root.""" pass class UnresolvableClosure(RuntimeError): """Raised when the manifest's dependency constraints cannot be satisfied by any closure matching the signed root. Substitution is forbidden.""" pass def verify_and_load_skill(manifest, signed_root, registry, trust_barrier=None): """ Enforce closure binding at cold-start. Invariant: no artifact init code, import side effect, or registry mutation executes until the recomputed closure root equals the signed root. `trust_barrier` is an optional callable invoked ONLY after root match, used to run post_load hooks. If root mismatches, it is never called. """ if signed_root is None: raise ClosureRootMismatch( "manifest carries no closure root; per-node signatures are insufficient" ) # Resolve the full transitive closure under a pinned registry epoch. # Any missing/yanked edge must surface as unresolvable, never substituted. resolved = registry.resolve_full_closure( manifest.deps, pinned_epoch=manifest.registry_epoch_digest, forbid_substitution=True, ) if resolved is None or resolved.incomplete: raise UnresolvableClosure( f"closure for {manifest.skill_id} cannot be fully resolved " f"under epoch {manifest.registry_epoch_digest}; refusing to substitute" ) # Canonical, order-independent serialization of the whole closure. computed_root = resolved.merkle_root() if computed_root != signed_root: # This is the exact condition the attack exploited: every node may be # individually signed, but the composition was never authorized. raise ClosureRootMismatch( f"closure root mismatch for {manifest.skill_id}: " f"signed={signed_root.hex()} computed={computed_root.hex()} " f"nodes={[n.id for n in resolved.nodes]}" ) # Barrier passed. Only now may hooks / init code run. if trust_barrier is not None: trust_barrier(resolved) return resolved ```