# Under what conditions must an instance re-attest a sandboxed skill's capability set after a mid-task toolchain mutation, and what breaks when it does not **Date of Record:** 2026 December 3 **Scope:** Applies to any agent runtime that loads third-party skills (MCP servers, A2A callees, or plugin manifests) under a least-privilege sandbox and caches the granted capability set for the lifetime of a task. Does not apply to stateless single-call invocations where the sandbox is torn down after each call, nor to skills whose declared capability manifest is cryptographically bound to an immutable artifact hash. ## Core Distinction The failure mode is not "a skill exceeded its privileges." That is the easy case — the sandbox denies the syscall and the skill gets an `EPERM`, which is observable and recoverable. The non-obvious failure is **attestation staleness under toolchain mutation**: the runtime grants a capability set based on a manifest it read at load time, the skill then mutates its own dependency graph (pulls a different transitive sub-tool, hot-reloads a plugin, resolves a version range to a newer artifact), and the *already-granted* capability set no longer corresponds to the code that is actually executing. Least-privilege is a statement about a specific artifact. It is not a property of a *name*. When the artifact behind a name changes mid-task and the grant is keyed on the name, the invariant "granted capabilities ⊆ capabilities required by running code" is silently violated in the *permissive* direction — the running code now requires more than was attested, and either (a) it fails in a way that looks like a skill bug, or (b) it succeeds because the grant was over-broad relative to the *new* code, which is the dangerous case. The distinction that matters: **re-attestation is required on artifact identity change, not on time and not on task boundary.** Most runtimes re-attest on task start and never again. That is the gap. ## What Was Observed A runtime loaded a third-party "spreadsheet-transform" skill at task start. The manifest declared `fs.read: ["/workspace/input/**"]`, `fs.write: ["/workspace/output/**"]`, `net: none`, `exec: none`. The sandbox was configured accordingly: a read-only bind mount on input, a write mount on output, no network namespace, seccomp blocking `execve` beyond the pre-approved loader. At step 4 of an 11-step task, the skill's own internal resolver executed a lazy import that triggered a dynamic dependency fetch. The skill's manifest had declared a version range `>=1.2,<2.0` for a helper library; at load time the resolver had pinned `1.2.4`, which was pure-Python. At step 4, a cache eviction caused re-resolution, and the resolver selected `1.7.0`, which shipped a compiled extension that `dlopen`ed a shared object and, on first call, attempted to read `/etc/machine-id` for a telemetry nonce. Trace: 1. Step 1–3: skill runs against pinned `1.2.4`. Capability set `{fs.read:input, fs.write:output}` is sufficient and correct. Sandbox denies nothing. 2. Step 4, resolver re-runs: selects `1.7.0`. The *skill's* manifest is unchanged — it still declares the same capability set. The runtime has no signal that anything changed. 3. Step 4, first call into `1.7.0`: `open("/etc/machine-id")` → sandbox returns `EACCES` (correctly — the path is outside the granted `fs.read` set). 4. The compiled extension does not handle `EACCES`; it treats it as "file absent" and retries with a fallback path `/proc/sys/kernel/random/boot_id`, also denied. 5. The extension raises an unhandled native exception that crosses the FFI boundary as a `SIGSEGV`-adjacent abort, killing the skill worker. 6. The runtime's supervisor sees a worker death, attributes it to "skill crashed," and — depending on retry policy — either restarts the skill (re-pinning to `1.2.4`, masking the mutation) or fails the task with a misleading error. The runtime never observed the actual event: **the executing artifact changed under a stable name, and the capability grant was never re-evaluated against the new artifact.** The sandbox did its job (denied the read). The attestation layer did not (never noticed it needed to re-attest). A second observed variant is worse. If the skill had declared `fs.read: ["/**"]` (a common over-broad manifest from a lazy third-party author) and the runtime had granted it, then step 4's `open("/etc/machine-id")` would have *succeeded*. The task completes. No error. The runtime's logs show a clean run. The capability set was over-broad relative to `1.2.4` *and* relative to `1.7.0`, so nothing ever fires. This is the continuity-invariant violation in its silent form: the grant was never wrong *enough* to trip the sandbox, so the mutation was never surfaced. ## Condition of Validity The invariant that must hold is: > For every executing artifact `A` at time `t`, `granted_capabilities(A) ⊇ required_capabilities(A)` AND `granted_capabilities(A) ⊆ attested_capabilities(manifest(A))`. The first clause is what the sandbox enforces mechanically. The second clause — the *least-privilege* clause — is what the attestation layer must enforce, and it is the one that silently rots. This invariant is valid only under the precondition that **artifact identity is stable for the duration of the grant**. When that precondition fails, the invariant is not "weakened" — it becomes *undefined*, because `required_capabilities(A)` is being evaluated against an `A` that no longer exists. Therefore re-attestation is mandatory when *any* of the following transition conditions hold, regardless of task boundary: - The skill's dependency resolver selects a different artifact hash than the one attested (version-range re-resolution, cache eviction, lockfile drift). - The skill hot-reloads a plugin or sub-skill whose manifest is a separate document. - A transitive MCP server is reconnected and negotiates a different `capabilities` block (schema negotiation mismatch — the new server may advertise tools the old one did not). - The skill's own manifest is fetched over the network rather than from a content-addressed store, and the fetch is not pinned to a hash. The condition does *not* hold — re-attestation is unnecessary and wasteful — when the skill is loaded from an immutable, content-addressed artifact (e.g., an OCI digest or a signed manifest bound to a build hash) and the resolver is configured to fail-closed on any digest mismatch. In that case artifact identity is stable by construction and the grant remains valid for the task lifetime. ## Decision Boundary The runtime must decide, at each transition, between three actions. The boundary is drawn on **whether the new artifact's required capability set is a subset of the currently granted set**, and whether the new artifact's *attested* set is a subset of what the manifest author is authorized to request. - **Subset, and attested ⊆ authorized:** continue without re-prompting. The grant is still least-privilege-valid; the mutation is benign with respect to capabilities. Log the artifact-hash transition for audit. - **Superset (new artifact requires capabilities outside the grant), and attested ⊆ authorized:** **suspend the skill, re-attest, and re-prompt for the delta.** Do not silently widen the grant. The task may resume only after the new capability set is approved. This is the boundary the observed failure crossed without a decision being made. - **Attested ⊄ authorized (the new artifact's manifest requests capabilities the runtime's policy forbids for this skill class):** **hard fail, do not re-prompt.** A skill that mutates into requesting forbidden capabilities is exhibiting manifest drift; treat it as a compromised or misconfigured artifact. This is the case where re-prompting would launder a privilege escalation through human approval fatigue. The critical decision-boundary rule: **the default on artifact-identity change must be `suspend`, not `continue`.** A runtime that defaults to `continue` on hash change has, in effect, no attestation layer — it has a load-time check that the skill can trivially route around by mutating its own dependency graph. The observed failure was a `continue`-by-default runtime. ## Operational Effect When the invariant is enforced (re-attest on hash change, default-suspend), the operational effect is a small increase in task interruptions — the step-4 mutation above would surface as a "skill requested capability delta: `fs.read:/etc/machine-id`" prompt, which a human or policy engine rejects, and the skill is pinned back to `1.2.4` or failed cleanly. Mean task latency rises slightly; silent privilege drift drops to zero. When the invariant is not enforced, the operational effect is a class of failures that are *misattributed*. The step-4 crash is logged as "skill worker died," the retry masks the mutation, and the post-mortem concludes "flaky skill" rather than "attestation staleness." The over-broad-manifest variant produces no failure at all — it produces a clean run with a capability grant that was never valid, which is the worst outcome because it is invisible and it trains operators to trust green dashboards. The guardrail is architectural, not procedural: the capability grant must be **keyed on the artifact hash, not the skill name**, and any hash transition must invalidate the grant and force re-attestation before the next tool call executes. A grant that survives a hash change is not a least-privilege grant; it is a name-based allowlist wearing a sandbox's clothes. ```python import hashlib from dataclasses import dataclass, field class AttestationStalenessError(RuntimeError): """Raised when a skill's executing artifact no longer matches its attested grant.""" class CapabilityEscalationError(RuntimeError): """Raised when a mutated artifact requests capabilities outside the authorized class.""" @dataclass(frozen=True) class CapabilitySet: fs_read: frozenset fs_write: frozenset net: bool exec: bool def is_subset_of(self, other: "CapabilitySet") -> bool: return ( self.fs_read <= other.fs_read and self.fs_write <= other.fs_write and (not self.net or other.net) and (not self.exec or other.exec) ) @dataclass class Grant: skill_name: str artifact_hash: str granted: CapabilitySet attested: CapabilitySet authorized: CapabilitySet def attest_on_transition( grant: Grant, new_artifact_hash: str, new_required: CapabilitySet, new_attested: CapabilitySet, ) -> Grant: """ Called whenever the runtime observes an artifact-identity change for a skill. Enforces: granted >= required AND attested <= authorized, keyed on hash. """ if new_artifact_hash == grant.artifact_hash: # No identity change: grant remains valid for this task lifetime. return grant # Identity changed. The old grant is now undefined; do not reuse it. if not new_attested.is_subset_of(grant.authorized): raise CapabilityEscalationError( f"skill {grant.skill_name!r} mutated to artifact {new_artifact_hash[:12]} " f"requesting capabilities outside its authorized class; refusing re-attestation" ) if not new_required.is_subset_of(grant.granted): # Required set exceeds current grant: must suspend and re-prompt for the delta. delta_read = new_required.fs_read - grant.granted.fs_read delta_write = new_required.fs_write - grant.granted.fs_write raise AttestationStalenessError( f"skill {grant.skill_name!r} artifact changed {grant.artifact_hash[:12]} -> " f"{new_artifact_hash[:12]}; required capabilities exceed grant " f"(fs_read+={sorted(delta_read)}, fs_write+={sorted(delta_write)}, " f"net={new_required.net and not grant.granted.net}). " f"Suspend and re-attest before next tool call." ) # Benign mutation: required ⊆ granted and attested ⊆ authorized. Re-key the grant. return Grant( skill_name=grant.skill_name, artifact_hash=new_artifact_hash, granted=grant.granted, attested=new_attested, authorized=grant.authorized, ) def compute_artifact_hash(manifest_bytes: bytes, dep_lock_bytes: bytes) -> str: h = hashlib.sha256() h.update(manifest_bytes) h.update(b"\x00") h.update(dep_lock_bytes) return h.hexdigest() ```