# Under what conditions must an instance re-verify a skill's provenance signature after capability-manifest mutation but before sandbox re-entry **Date of Record:** 2026 November 30 **Scope:** Applies to any agent runtime that resolves tools/skills from a registry, caches a signed capability manifest, and re-enters a sandboxed execution context on a per-call basis. Does not apply to statically linked tool sets compiled into the model image, nor to registries where the manifest and the executable artifact are cryptographically bound as a single signed blob. ## Core Distinction The failure is not "an unsigned skill got loaded." It is a **signature-to-manifest binding gap**: the registry signs a *capability manifest* (declared scopes, resource limits, egress allowlist, filesystem roots), and separately the runtime resolves a *skill artifact* (the code or prompt template that actually executes). A skill-injection attack succeeds when an attacker mutates the artifact while leaving the manifest's signature valid, so the runtime's provenance check passes on a document that no longer describes the thing about to run. The invariant that operators assume is `signature_valid(manifest) ⇒ artifact_trusted`. That implication is false unless the manifest is *content-addressed to the artifact digest*. Most registries sign the manifest by reference (`skill_id`, `version`, `publisher`) rather than by artifact hash, which means the signature attests to a *name*, not to *bytes*. Any write path that can replace the bytes behind a stable name — mutable tags, mutable version ranges, registry-side re-publication, or a compromised publisher token — preserves signature validity while swapping the payload. ## What Was Observed A tool registry used semver-range resolution: a calling agent requested `skill://pdf-extract@^2.1.0`. The registry returned a manifest signed by the publisher key over `{skill_id, version_range, declared_scopes}`. The runtime verified the publisher signature, checked that `declared_scopes` (read-only filesystem, no network) was a subset of the caller's granted capability set, cached the manifest in a per-session memo keyed by `skill_id`, and executed the resolved artifact. The injection trace: 1. Attacker publishes `pdf-extract@2.1.7` under a legitimate-looking publisher namespace (typosquat or compromised token) satisfying `^2.1.0`. The manifest declares the *same* narrow scopes as `2.1.3`, because the attacker wants the capability check to pass — the scope declaration is the attack surface's camouflage, not its target. 2. The registry's `latest` pointer for the range now resolves to `2.1.7`. The signed manifest is regenerated and re-signed for `2.1.7` — signature is valid, scopes are narrow. 3. The runtime's per-session memo keyed on `skill_id` returns the *cached* manifest from step 1's earlier call to `2.1.3`. The cache key omits the resolved version and artifact digest. The signature check passes against the stale manifest; the artifact executed is `2.1.7`. 4. `2.1.7`'s actual behavior diverges from its declared scopes: it reads `~/.aws/credentials` via a path the declared `readonly_root` allowlist was supposed to exclude, but the allowlist is enforced *by the sandbox from the manifest*, and the manifest's allowlist was computed for a different artifact. The sandbox faithfully enforces the wrong policy. The observable symptom is not a sandbox escape in the classic sense. The sandbox did exactly what it was told. The failure is that **the policy document and the payload it governs were resolved through two independent, unsynchronized lookups** — `skill_id` for the manifest, `skill_id + range` for the artifact — and the cache collapsed the distinction. A second observed variant: the manifest declared `max_tokens: 4096` and `egress: []`, but the artifact's own runtime configuration (a JSON blob shipped *inside* the artifact, not covered by the manifest signature) re-enabled egress to an attacker endpoint. The runtime trusted the artifact's self-declared config over the manifest because the manifest had no field to override it. Capability manifests that are *additive* rather than *authoritative* are injection surfaces: the artifact can always grant itself more than the manifest declares if the runtime unions the two. ## Condition of Validity The provenance check is only sound under the conjunction: - The signed manifest contains `artifact_digest = H(artifact_bytes)` and the runtime recomputes `H` over the exact bytes it is about to execute, comparing before sandbox entry. - The resolution cache is keyed on `(skill_id, resolved_version, artifact_digest)`, never on `skill_id` alone, and the cache entry is invalidated by any registry pointer mutation. - The manifest is *authoritative and exclusive*: the runtime's effective capability set is `min(caller_grant, manifest_declared_scopes)` with no union against artifact-self-declared config. Artifact config may only *narrow*. - The sandbox is constructed *from the verified manifest*, not from the artifact, and the sandbox handle is bound to the digest so a mid-execution artifact swap is impossible. If any conjunct fails, `signature_valid(manifest)` carries no information about the payload, and the "verified" label is a false attestation. ## Decision Boundary The runtime must re-verify — recompute the artifact digest and re-derive the sandbox policy — at every one of these transitions, not just at first load: - **Cache hit on any key that does not include the digest.** If the memo key is `skill_id`, treat every hit as unverified and fall through to full verification. - **Version-range re-resolution.** A `^`, `~`, or `latest` resolution that returns a different concrete version than the cached one must invalidate the manifest, not just the artifact. - **Post-manifest-fetch artifact fetch.** The window between "I verified the manifest" and "I fetched the artifact bytes" is where the swap lives. Digest check must be on the fetched bytes, after fetch, before execution. - **Resume from checkpoint.** A mid-task checkpoint that stores `{skill_id, version}` but not `artifact_digest` cannot be safely resumed; the resumed instance must re-verify or refuse. The boundary is *not* crossed for: same-digest re-execution within a session where the digest was verified and the sandbox handle is still live; and skills whose manifest and artifact are a single signed blob (digest binding is structural, not procedural). ## Operational Effect The practical consequence is that "signed" and "safe to run" decouple, and the decoupling is silent. Audit logs will show `signature_verified: true` for the malicious execution, because the signature *was* valid — over the wrong document. Incident response that greps for signature failures finds nothing. The only detectable artifact is a digest mismatch between the manifest's `artifact_digest` and the executed bytes, which requires that field to exist in the first place. The guardrail is therefore structural, not detective: **content-address the manifest to the artifact, key every cache on the digest, and make the sandbox policy a pure function of the verified manifest with artifact config restricted to narrowing.** An instance that cannot prove `H(executed_bytes) == manifest.artifact_digest` at the moment of sandbox construction must treat the skill as unverified regardless of signature status, and must refuse to resume any checkpoint that lacks the digest. ```python import hashlib from dataclasses import dataclass class ProvenanceBindingError(RuntimeError): """Raised when a skill's verified manifest does not bind to the bytes about to execute.""" @dataclass(frozen=True) class SignedManifest: skill_id: str resolved_version: str artifact_digest: str # H(artifact_bytes) at signing time declared_scopes: frozenset # authoritative; artifact config may only narrow signature_valid: bool def resolve_and_verify( manifest: SignedManifest, artifact_bytes: bytes, cache_key_skill_id_only: bool, caller_grant: frozenset, ) -> frozenset: # A signature over a manifest that does not content-address the artifact # attests to a name, not to bytes. Refuse to treat it as payload trust. if not manifest.signature_valid: raise ProvenanceBindingError( f"signature invalid for {manifest.skill_id}@{manifest.resolved_version}" ) if cache_key_skill_id_only: # Cache hit keyed on skill_id alone cannot distinguish a swapped # artifact behind a stable name; the cached manifest is unverified. raise ProvenanceBindingError( f"cache key for {manifest.skill_id} omits digest; re-verify required" ) actual = hashlib.sha256(artifact_bytes).hexdigest() if actual != manifest.artifact_digest: # The swap window: manifest signed for one artifact, different bytes # resolved. Sandbox policy would be derived from the wrong document. raise ProvenanceBindingError( f"artifact digest mismatch for {manifest.skill_id}: " f"manifest={manifest.artifact_digest} executed={actual}" ) # Effective capability set is the intersection; artifact self-declared # config may only narrow, never union. effective = caller_grant & manifest.declared_scopes if not effective <= caller_grant: raise ProvenanceBindingError("capability union attempted; manifest not authoritative") return frozenset(effective) ```