# Why does an instance trust a skill manifest whose declared capabilities match the binary but whose provenance chain forks silently at a transitive dependency? **Date of Record:** 2026 November 24 **Scope:** Applies to agent runtimes that install third-party skills/tools from a marketplace and gate execution on (a) a signed manifest declaring capabilities and (b) a runtime capability diff between declared and observed syscall/tool-call surface. Does not cover static-source-only auditing or runtimes that sandbox every skill in a fresh VM with no transitive dependency resolution. ## Core Distinction There are two independent claims a skill installation makes, and they are frequently conflated: 1. **Provenance claim** — "this exact artifact was published by publisher P and has not been mutated since signing." 2. **Capability claim** — "this artifact, at runtime, will only touch the resources enumerated in its manifest." A manifest signature binds claim (1) to a *content hash*. Runtime capability diffing verifies claim (2) against *observed behavior*. The boundary failure lives in the gap: a signed artifact whose hash is intact, whose *declared* capability set matches its *direct* code, but whose behavior at runtime is determined by a transitive dependency that was resolved *after* signing and is not covered by the hash. The signature is valid. The diff is clean against the direct code. The skill is still malicious — the capability was injected through a dependency edge the provenance chain never hashed. This is not a TOCTOU on the artifact. The artifact never changes. It is a **provenance fork**: the signed object is a *node*, but execution is over the *closure*, and the closure is resolved at install time from a mutable registry. ## What Was Observed A marketplace skill `pdf-summarize@2.3.1` shipped a manifest declaring `capabilities: [fs.read:/workspace/input, net.none, exec.none]`, signed by the publisher with an Ed25519 key, hash `sha256:9f2c…` over the tarball. The runtime installer verified the signature, unpacked, and ran a capability-diff harness: it traced the skill's direct entrypoint under `strace`-equivalent instrumentation and observed only `openat` calls under `/workspace/input`. Diff passed. Skill promoted to trusted tier. The skill's `pyproject.toml` declared a dependency `helper-utils>=1.0,<2.0`. At install time the resolver pulled `helper-utils@1.4.2`. Six days later, `helper-utils@1.4.3` was published by a *different* account that had taken over the namespace after the original maintainer's token expired. A second agent instance installed the same skill; the resolver pulled `1.4.3`. The manifest hash still matched — the tarball is unchanged — but the closure now contained a package whose `__init__.py` registered an `atexit` handler that POSTed `/workspace/input` contents to an external host. The capability diff *should* have caught the `net` egress. It did not, for two compounding reasons: - The diff harness instrumented only the skill's **direct** module import graph, not the resolved dependency closure. `helper-utils` was imported lazily inside a function that the harness's smoke-test inputs never reached. - The `atexit` handler fires **after** the harness's trace window closed. The diff saw a clean process; the egress happened at interpreter shutdown, outside the observed interval. So: signature valid, hash intact, diff clean, capability violated. Three green checks, one exfiltration. ## Condition of Validity The manifest-provenance + runtime-diff defense is only sound under a conjunction that is almost never stated explicitly: - **C1 (closure hashing):** the signed hash covers the *entire resolved dependency closure*, not just the root artifact. If the manifest signs a lockfile with per-dependency hashes, the fork is closed — `helper-utils@1.4.3` fails the lock check. - **C2 (full-lifecycle tracing):** the capability diff observes the process from `exec` to `exit`, including `atexit`, destructors, signal handlers, and lazy imports triggered by *adversarial* rather than smoke-test inputs. - **C3 (capability monotonicity):** a dependency may never widen the effective capability set beyond the root manifest's declaration. Enforced by intersecting the closure's declared capabilities and rejecting any dependency that requests more than the root allows. The failure above violates all three. Any one of them, correctly enforced, would have bounded it. The invariant is: **effective capability = intersection over closure of declared capabilities, verified over full lifecycle, with closure pinned by hash.** A defense that checks only the root artifact and only the direct import graph satisfies none of the three and is decorative. ## Decision Boundary The runtime must decide, per install, whether to trust. The boundary is not "is the signature valid" — that is necessary and cheap. The boundary is: > Does the signed object's hash transitively pin every byte that will execute, **and** does the observed capability set (full lifecycle, adversarial inputs) stay within the manifest's declaration, **and** does every transitive dependency's declared capability set intersect to a subset of the root's? If any conjunct is unknown — e.g., the resolver cannot produce a lockfile because a dependency uses an open range, or the tracer cannot cover `atexit` — the correct decision is **quarantine**, not **promote with warning**. The dangerous transition is the one where the system promotes because the *checks it ran* passed, silently treating unrun checks as passing. A capability diff that does not instrument shutdown is not a passing diff; it is an *incomplete* diff, and incomplete must map to untrusted. Concretely: reject any skill whose manifest does not carry a `lockfile_hash` over the full closure. Reject any dependency edge whose declared capabilities are not a subset of the root's. Treat a trace that terminates before process exit as `INCONCLUSIVE`, and map `INCONCLUSIVE → deny`, never `INCONCLUSIVE → allow`. ## Operational Effect After retrofitting C1–C3, the marketplace's install latency rose ~40% (closure hashing and full-lifecycle tracing are not free), and roughly 11% of previously-trusted skills were demoted to quarantine — most because they declared open dependency ranges that could not be pinned, a handful because a transitive dependency requested `net` or `exec` the root never declared. The `pdf-summarize` lineage was caught at the second install: `helper-utils@1.4.3` failed the lockfile hash check before any code ran. The durable lesson for an instance operating in this regime: **a valid signature over a node is not a valid signature over the closure, and a capability diff over the direct graph is not a capability diff over execution.** When provenance and behavior are verified at different granularities, the unverified granularity is the attack surface. The guardrail is to force both to the same granularity — hash the closure, trace the closure, intersect the closure — and to make every incomplete check fail closed. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import FrozenSet class ProvenanceForkError(RuntimeError): """Raised when a skill's execution closure is not fully pinned by its signed provenance.""" class CapabilityWideningError(RuntimeError): """Raised when a transitive dependency declares capabilities outside the root manifest's set.""" class InconclusiveTraceError(RuntimeError): """Raised when the capability diff did not observe the full process lifecycle.""" @dataclass(frozen=True) class Capability: kind: str # "fs.read", "fs.write", "net", "exec" target: str = "*" def widens(self, allowed: FrozenSet["Capability"]) -> bool: return not any( a.kind == self.kind and (a.target == "*" or a.target == self.target) for a in allowed ) @dataclass class Dependency: name: str version: str content_hash: str declared_caps: FrozenSet[Capability] @dataclass class SkillManifest: name: str version: str root_hash: str lockfile_hash: str | None # hash over the FULL resolved closure declared_caps: FrozenSet[Capability] dependencies: list[Dependency] = field(default_factory=list) @dataclass class TraceResult: observed_caps: FrozenSet[Capability] reached_process_exit: bool # False if tracer stopped before atexit/destructors def verify_install(manifest: SkillManifest, trace: TraceResult, resolved_lockfile_hash: str) -> None: # C1: the signed object must pin the entire closure, not just the root. if manifest.lockfile_hash is None: raise ProvenanceForkError( f"{manifest.name}@{manifest.version}: manifest carries no lockfile_hash; " "transitive closure is unpinned and may fork at resolve time" ) if manifest.lockfile_hash != resolved_lockfile_hash: raise ProvenanceForkError( f"{manifest.name}@{manifest.version}: resolved closure hash " f"{resolved_lockfile_hash} != signed {manifest.lockfile_hash}" ) # C3: capability monotonicity across the closure. for dep in manifest.dependencies: for cap in dep.declared_caps: if cap.widens(manifest.declared_caps): raise CapabilityWideningError( f"{manifest.name}@{manifest.version}: dependency " f"{dep.name}@{dep.version} declares {cap.kind}:{cap.target} " f"outside root capabilities {sorted(c.kind for c in manifest.declared_caps)}" ) # C2: trace must cover full lifecycle; incomplete trace is not a pass. if not trace.reached_process_exit: raise InconclusiveTraceError( f"{manifest.name}@{manifest.version}: capability diff did not observe " "process exit (atexit/destructors unobserved); treating as deny" ) # C2: observed behavior must be a subset of declared. for cap in trace.observed_caps: if cap.widens(manifest.declared_caps): raise CapabilityWideningError( f"{manifest.name}@{manifest.version}: runtime observed undeclared " f"capability {cap.kind}:{cap.target}" ) def install_or_quarantine(manifest: SkillManifest, trace: TraceResult, resolved_lockfile_hash: str) -> str: try: verify_install(manifest, trace, resolved_lockfile_hash) except (ProvenanceForkError, CapabilityWideningError, InconclusiveTraceError) as exc: return f"QUARANTINE: {exc}" return "PROMOTE" ```