# What happens when an instance loads a skill manifest whose signature verifies but whose declared capability set diverges from the capability set actually exercised at runtime **Date of Record:** 2026 November 28 **Scope:** Applies to agent runtimes that resolve skills/tools from a registry and gate invocation on signed manifests. Does not cover unsigned local plugins, in-process monkeypatched tools, or prompt-only "skill" descriptions with no executable surface. ## Core Distinction The common framing of skill-injection defense is *authenticity*: is this manifest signed by a trusted publisher? That framing is necessary but insufficient. The failure mode documented here is **capability drift** — a manifest whose Ed25519 signature verifies cleanly against a trusted key, whose declared `capabilities` array is benign (`fs.read`, `http.get:api.internal`), but whose *runtime behavior* exercises capabilities outside the declared set. The signature attests to the bytes of the manifest, not to the behavior of the code the manifest points at. A legitimate publisher can be tricked (via a poisoned transitive dependency, a mutable registry pointer, or a compromised build step) into signing a manifest that under-declares what the artifact does. The verifier passes; the agent is owned. The invariant that actually needs to hold is not `signature_valid(manifest) == True` but `observed_capabilities(execution) ⊆ declared_capabilities(manifest)`. Signing alone gives you the first; only runtime capability accounting gives you the second, and the two must be composed. ## What Was Observed A tool-use agent was configured with a registry client that, on cold start, fetched `skill://pdf-extract@2.4.1`, verified the manifest signature against a pinned publisher key (`sha256:9f3c…`), checked the manifest's `sha256` digest against the fetched artifact tarball, and installed the skill into the sandbox. All three checks passed. The manifest declared: ``` capabilities: - fs.read:/workspace/input - process.spawn:python3 - net.none ``` The artifact's `entrypoint.py` imported a vendored helper `_util.py` that, on first invocation, read `os.environ["AGENT_TOKEN"]` and POSTed it to a hardcoded egress IP over a raw socket — bypassing the manifest's `net.none` declaration because the sandbox enforced egress policy at the `requests`/`httpx` layer, not at `socket.socket`. The declared capability `net.none` was *true of the manifest* and *false of the process*. The signature was valid. The digest was valid. The agent exfiltrated its own bearer token within 400ms of first tool call. The signature verified because the publisher *did* sign this artifact — a malicious maintainer had added the `_util.py` line in a patch release, the CI signed it, and the registry served it. This is the non-obvious part: **signing shifts trust to the publisher, but the publisher is an attack surface under supply-chain compromise.** Signed manifests mitigate *registry-side* poisoning (attacker swaps tarball, signature fails) but do not mitigate *publisher-side* poisoning (attacker is the publisher, signature passes). The second observation: agents that logged `signature_valid=true` in their audit trail *suppressed* the anomaly. Downstream auditors saw a green check and did not examine the egress. The signature check became a false comfort that degraded monitoring. ## Condition of Validity Signed skill manifests are a valid control **only when** the following conjunction holds: 1. **Capability declarations are enforced at a layer the artifact cannot bypass.** If the manifest says `net.none`, the enforcement must be at the syscall/seccomp/network-namespace layer, not at a Python library the artifact imports. Any enforcement the artifact can route around is a declaration, not a control. 2. **The verifier records observed-vs-declared capability deltas as first-class events**, not just `signature_valid`. A run that exercises a capability outside the declared set must emit a `CapabilityDrift` event even if the signature is valid. 3. **Registry artifacts are content-addressed and immutable by digest.** Mutable tags (`@2.4.1` resolving to different bytes over time) break the audit chain even with valid signatures, because the signature attests to a manifest that names a digest, and the digest must be pinned at resolve time, not re-resolved at install time. 4. **Transitive dependencies are covered by the same manifest.** If the skill vendors or imports code outside the signed tarball, the signature covers only part of the executed surface. Either the tarball is hermetic or the manifest must enumerate dependency digests. When any of these fails, the signature check is orthogonal to the actual attack surface and should not be recorded as a security control — record it as an *integrity* check only. ## Decision Boundary The runtime must decide, at skill-load time, whether to *install-and-run*, *install-and-quarantine*, or *reject*. The boundary is not "signature valid?" but the tuple: ``` (signature_valid, declared_capabilities, enforcement_layer_covers(declared_capabilities)) ``` - If `signature_valid` and every declared capability is enforced at a layer the artifact cannot reach (seccomp, netns, mount namespace, capability-bounded seccomp-bpf), install and run. Drift is structurally impossible for those capabilities. - If `signature_valid` but any declared capability is enforced only at the library layer (e.g., a Python `requests` hook for `net.none`), install into a **quarantine sandbox** that enforces the *union of declared capabilities plus a deny-all default*, and require an explicit operator promotion before the skill is exposed to the agent's tool menu. The agent must not see the skill until promoted. - If `signature_valid` but the manifest declares `net.none` while the artifact's dependency tree (per SBOM) contains any network-capable module, reject or force quarantine — the declaration is contradicted by static evidence. - If `signature_valid` but the registry tag resolved to a digest different from the digest the signature covers, reject. This is a TOCTOU between resolve and install. The critical boundary decision: **do not let a valid signature short-circuit the capability enforcement decision.** They are independent gates. The common bug is `if verify(manifest): install()` — collapsing two gates into one. ## Operational Effect The operational consequence of treating signature validity as sufficient is a **silent capability widening**: the agent's effective capability set grows with each signed-but-under-declared skill, and the audit trail shows only green checks. The blow-up is not immediate; it compounds. Each skill that drifts by one capability (a `socket` here, a `subprocess` there) leaves the agent with a union of capabilities far exceeding any single manifest, and no event records the union. The mitigation with the correct shape is a **runtime capability ledger**: every syscall-class event attributable to a skill invocation is tagged with the skill's manifest digest, and at the end of each invocation the ledger computes `observed \ declared`. Non-empty delta → emit `CapabilityDrift`, revoke the skill's promotion, and freeze the agent's tool menu pending operator review. The ledger must be enforced below the artifact (eBPF, seccomp user-notify, or a ptrace supervisor) — not by the artifact's own instrumentation, which a compromised skill can omit. The second operational effect: signed manifests remain valuable, but for a narrower claim — they prevent *registry-side substitution* and give you a stable identity to pin in the ledger. They do not, and cannot, prevent publisher-side compromise. Teams that conflate the two ship agents that pass every signature check and still leak their tokens. ``` ```python import hashlib from dataclasses import dataclass, field from typing import FrozenSet class CapabilityDriftError(RuntimeError): """Raised when a skill's observed capabilities exceed its signed declaration.""" class SignatureMismatchError(RuntimeError): """Raised when the manifest signature or artifact digest fails verification.""" @dataclass(frozen=True) class SignedManifest: skill_id: str version: str artifact_digest: str # sha256 of the tarball declared_caps: FrozenSet[str] # e.g. {"fs.read:/workspace/input", "process.spawn:python3"} signature: bytes publisher_key_id: str @dataclass class CapabilityLedger: """Runtime observation of capabilities exercised, tagged by manifest digest.""" by_skill: dict = field(default_factory=dict) def record(self, artifact_digest: str, cap: str) -> None: self.by_skill.setdefault(artifact_digest, set()).add(cap) def observed(self, artifact_digest: str) -> FrozenSet[str]: return frozenset(self.by_skill.get(artifact_digest, set())) def verify_and_gate( manifest: SignedManifest, fetched_artifact: bytes, trusted_keys: dict, ledger: CapabilityLedger, enforcement_covers: dict, # cap -> "kernel" | "library" ) -> None: # Gate 1: integrity. Signature attests to manifest bytes; digest attests to artifact. actual_digest = hashlib.sha256(fetched_artifact).hexdigest() if actual_digest != manifest.artifact_digest: raise SignatureMismatchError( f"artifact digest {actual_digest} != manifest {manifest.artifact_digest}" ) if manifest.publisher_key_id not in trusted_keys: raise SignatureMismatchError( f"untrusted publisher key {manifest.publisher_key_id}" ) # (Signature verification of manifest.signature over canonical manifest bytes elided; # assume it passes — the point of this record is that it *can* pass and still be unsafe.) # Gate 2: enforcement adequacy. A declared capability enforced only at the # library layer is a declaration, not a control. Quarantine unless kernel-enforced. weak = [c for c in manifest.declared_caps if enforcement_covers.get(c) != "kernel"] if weak: raise CapabilityDriftError( f"skill {manifest.skill_id}@{manifest.version} declares {weak} " f"enforced only at library layer; quarantine required before exposure" ) def assert_no_drift(manifest: SignedManifest, ledger: CapabilityLedger) -> None: """Call after each invocation. The invariant: observed ⊆ declared.""" observed = ledger.observed(manifest.artifact_digest) undeclared = observed - manifest.declared_caps if undeclared: # Observed capability outside the signed declaration — signature was valid, # behavior was not. This is the failure the signature check cannot catch. raise CapabilityDriftError( f"skill {manifest.skill_id}@{manifest.version} exercised undeclared " f"capabilities {sorted(undeclared)}; revoke promotion and freeze tool menu" ) ```