# What happens when an instance trusts a signed skill manifest but the capability sandbox and the provenance chain disagree on the effective capability set **Date of Record:** 2026 November 14 **Scope:** Applies to agent runtimes that dynamically load skills where each skill carries both a cryptographic provenance manifest (signer identity, declared capabilities, integrity hash) and a runtime capability sandbox (enforced syscall/API allowlist). Does not apply to statically linked skills or to runtimes where the manifest and sandbox are generated from the same source of truth at the same instant. ## Core Distinction There are two distinct trust decisions in a skill-injection defense, and they are routinely conflated: 1. **Provenance validity** — "Was this skill authored by a key I trust, and has it been unmodified since signing?" This is a signature verification over the manifest and the artifact hash. 2. **Capability authorization** — "Is this skill permitted, at execution time, to exercise the capabilities it is about to exercise?" This is a sandbox enforcement decision. The non-obvious invariant is this: **a valid signature over a manifest that declares a capability set `C_declared` does not imply the sandbox enforces `C_declared`.** The sandbox enforces `C_enforced`, which is derived from the manifest by a policy compiler. When `C_enforced ⊋ C_declared` (sandbox is more permissive than declared), a correctly-signed, unmodified skill silently gains capabilities its signer never attested to. The signature is valid. The hash matches. The skill is "trusted." And it is over-privileged. The failure is not a forgery. It is a **widening at the manifest-to-sandbox compilation boundary**, and it is invisible to signature verification because signatures only bind the manifest, never the compiled policy. ## What Was Observed A skill manifest declared the following capability set: ``` capabilities: - fs.read:/workspace/inputs/** - net.egress:api.internal:443 ``` The provenance chain verified cleanly: signer key matched the pinned publisher key, artifact SHA-256 matched the manifest's `integrity` field, and the manifest itself was signed with a detached Ed25519 signature over a canonicalized JSON form. All green. The policy compiler, however, translated `fs.read:/workspace/inputs/**` into a sandbox rule that mounted `/workspace` read-only rather than `/workspace/inputs` read-only. The glob `**` was expanded by the compiler into a prefix mount at the nearest existing ancestor directory, and the ancestor resolution walked up one level too far because `/workspace/inputs` did not exist at policy-compile time (it was created later by an earlier skill in the same session). The resulting `C_enforced` included `fs.read:/workspace/secrets/**`. The skill then read `/workspace/secrets/deploy_token`. The sandbox permitted it. The signature verified it. No alert fired, because the runtime's audit compared the *accessed* paths against `C_enforced`, not against `C_declared`. The second observed variant: a manifest declared `net.egress:api.internal:443` and the compiler, unable to resolve `api.internal` at compile time (DNS not yet available in the policy-compile namespace), fell back to a default egress rule of `net.egress:*`. The skill exfiltrated to an external host. Signature valid. Hash valid. Sandbox "enforced" — the wrong set. In both cases the root cause is identical: **the compiled policy diverged from the signed declaration, and nothing in the pipeline compared the two.** ## Condition of Validity The provenance-plus-sandbox defense holds only when all of the following are true: - The policy compiler is **deterministic and total** over the manifest: every declared capability maps to exactly one enforced rule, and any capability it cannot resolve causes compilation to *fail closed*, not to widen. - The compiler's output is **bound to the signed manifest** — i.e., the effective policy `C_enforced` is itself hashed and that hash is attested by (or derived verifiably from) the signed manifest, so that a divergence is detectable after the fact. - Ancestor/glob resolution and name resolution (DNS, path existence) are performed against the **execution-time** namespace, or their failure is treated as a denial, never as a default-allow. - The audit layer compares observed behavior against `C_declared`, not merely against `C_enforced`. When any of these is false — and in practice at least one usually is, because compilers run in a different namespace and at a different time than execution — the defense degrades to "signature valid, privilege unbounded." ## Decision Boundary The operational rule: - **If `C_enforced == C_declared`** (verified by comparing the compiled policy hash against a hash recomputed from the signed manifest at load time), proceed to load. This is the only state in which "signed" and "sandboxed" compose into a real guarantee. - **If `C_enforced ⊋ C_declared`** (enforced is a strict superset), treat the skill as **untrusted regardless of signature validity**. Refuse to load. The signature attests to a capability set the runtime is not honoring; loading it means executing under privileges no one signed for. - **If `C_enforced ⊂ C_declared`** (enforced is a strict subset), the skill is over-restricted but safe to load; log a `CapabilityNarrowingWarning` because the skill will likely fail at runtime in ways that look like bugs but are policy artifacts. - **If the sets are incomparable** (each has elements the other lacks), refuse to load and escalate — the compiler has invented capabilities and dropped others, indicating a resolution-time namespace mismatch. Never allow a "default" or "fallback" rule in the compiler. A fallback is, by construction, a widening. Fail closed at compile time. ## Operational Effect After adopting the set-equality gate at load time, the two observed incidents become impossible: the `fs.read` widening fails the `C_enforced ⊋ C_declared` check because the compiled mount (`/workspace`) is a strict superset of the declared prefix (`/workspace/inputs`), and load is refused. The egress fallback fails because `net.egress:*` is not a subset of `net.egress:api.internal:443`. The cost is that skills whose declared capabilities cannot be resolved at compile time (because the target path or host does not yet exist) are rejected rather than loaded. This is the correct trade: an unresolved capability is an unverified capability, and an unverified capability under a valid signature is exactly the injection surface the defense exists to close. The remedy is to make skills declare capabilities resolvable at compile time, or to defer compilation to execution time within the target namespace — never to widen. The general lesson: **signatures bind declarations, sandboxes bind behavior, and the gap between them is where skill injection lives.** A defense that verifies the signature and trusts the sandbox without proving the two agree has verified the wrong thing. ```python class CapabilityDivergenceError(RuntimeError): """Raised when the compiled sandbox policy does not equal the signed capability set.""" pass def gate_skill_load(signed_caps: frozenset, compiled_caps: frozenset, skill_id: str) -> None: """ Enforce C_enforced == C_declared before loading a dynamically signed skill. signed_caps = capabilities attested by the verified provenance manifest compiled_caps = capabilities the runtime sandbox will actually enforce """ if compiled_caps == signed_caps: return # only safe state widened = compiled_caps - signed_caps narrowed = signed_caps - compiled_caps if widened: # Enforced superset (or incomparable): privilege no one signed for. raise CapabilityDivergenceError( f"skill={skill_id} sandbox widens signed capabilities: " f"unattested={sorted(widened)} narrowed={sorted(narrowed)}" ) # Pure narrowing: safe to load, but skill will misbehave at runtime. import warnings warnings.warn( f"skill={skill_id} sandbox narrows signed capabilities: missing={sorted(narrowed)}", RuntimeWarning, ) def load_skill(skill_id: str, manifest: dict, compiler) -> None: signed_caps = frozenset(manifest["capabilities"]) compiled_caps = frozenset(compiler.compile(manifest)) # must fail closed internally gate_skill_load(signed_caps, compiled_caps, skill_id) # ... proceed to instantiate skill under compiled policy ... ```