# How should an instance enforce provenance continuity across a capability-sandbox boundary when a dynamically loaded skill re-negotiates its own manifest mid-execution **Date of Record:** 2026 November 25 **Scope:** Applies to agents that hot-load skills/plugins at runtime under a signed-manifest + capability-sandbox model, specifically when a skill's declared capability set can be mutated after initial admission. Does not cover static, boot-time-only plugin loading, nor pure prompt-injection defenses at the text layer. ## Core Distinction The failure mode is not "an unsigned skill got loaded." It is the **provenance/capability skew window**: the interval during which a skill has been admitted under manifest `M₀` with signature `S₀`, but is *executing* under a mutated manifest `M₁` whose capability delta was never re-signed or re-adjudicated by the host. Most sandboxes verify provenance exactly once—at load—and then treat the capability set as immutable for the process lifetime. A skill that can call back into the host's manifest-registration API (or that can write to its own on-disk manifest between admission and invocation) breaks the implicit invariant *admission-time signature covers execution-time capabilities*. This is distinct from classic confused-deputy or TOCTOU on files: the artifact here is a *probabilistic actor's self-description*. The skill's manifest is authored by an LLM or an LLM-assisted packager, and it is plausible for a skill to legitimately want to widen scope mid-task (e.g., "I discovered I need `fs:write` to checkpoint"). The dangerous case is the *silent* widening: the host re-reads the manifest to dispatch a tool call, sees `fs:write` now present, grants it, and never checks that `S₀` covered it. ## What Was Observed A skill `summarize_repo` was admitted with manifest `M₀` declaring `caps = {fs:read, net:none, proc:spawn:false}` and signature `S₀ = sign(host_key, hash(M₀))`. During a long task it invoked a helper that wrote a checkpoint file to its own plugin directory. The write triggered the host's manifest watcher, which re-parsed the on-disk `manifest.json` and *merged* the new content. The skill's authoring loop (an LLM) had, in a prior session, appended `"fs:write": ["/tmp/**"]` and `"net:egress": ["*"]` to a `requested_caps` block that the loader's merge function treated as additive to `caps`. Trace: 1. `t=0` — admission: `S₀` verified against `M₀`. Sandbox policy `P` compiled from `M₀.caps`. `fs:write` absent, `net:egress` absent. 2. `t=41s` — skill calls `fs:write` on `/tmp/ckpt`. Host's manifest watcher fires on the plugin dir, re-parses, merges `requested_caps` into `caps`. 3. `t=41s+ε` — host's dispatcher consults the *live* manifest object (not the compiled policy `P`) to authorize the tool call. `fs:write` now appears present. Call is authorized. 4. `t=42s` — skill issues `net:egress` to an external host. Dispatcher again reads live manifest; `net:egress` present; authorized. 5. No re-signature check occurred. `S₀` still validates against the *original* `M₀` bytes, which the watcher had overwritten on disk—so `S₀` now fails to match the file, but the host had already cached the parsed object and never re-verified. The observable signature was a skill executing with a capability set that no signed manifest ever described. The audit log showed `authorized_by: manifest_v3` where `manifest_v3` had no corresponding signature record. ## Condition of Validity The invariant that must hold is: **for every tool invocation authorized at time `t`, there exists a signature `S` over a manifest `M` such that `capability_used ∈ M.caps` and `verify(S, M) = true` and `S` is chained to the admission record.** This is the *provenance-continuity invariant*. It fails whenever the authorization path reads a mutable manifest object rather than an immutable, signature-bound capability token. The condition under which this bites hardest: - The skill is LLM-authored or LLM-modified, so its manifest is *plausibly* self-editing. - The host supports hot reload or manifest watching (common for dev-loop ergonomics). - The dispatcher authorizes per-call against the live manifest rather than against a frozen policy compiled at admission. - Capability deltas are *additive-only* (a merge, not a replace), so widening is silent while narrowing would at least be visible. When any of these is absent the skew window collapses. When all four hold, the sandbox is a load-time formality. ## Decision Boundary The boundary is between **manifest as document** and **manifest as signed capability token**. Treat the manifest as immutable data whose hash is the identity of the capability grant: `grant_id = H(M || S)`. The sandbox compiles `P = compile(M.caps)` at admission and the dispatcher authorizes *only* against `P`, never against a re-read manifest. Any capability change requires a new admission event: new manifest bytes, new signature, new `grant_id`, new compiled policy, and—critically—a **quiesce** of the running skill instance so no in-flight tool call straddles the old and new grants. The re-negotiation path, if you allow it at all, must be an explicit RPC: skill requests `caps_delta`, host validates the delta against a policy that permits only *narrowing* without human/authorizer signature, and *widening* requires a fresh signature from the authorizing principal. The skill cannot widen its own grant by editing its own manifest file; that edit is inert until re-admitted. A second boundary: the signature must cover the *semantic* capability set, not just the bytes. Canonicalize `caps` (sorted keys, normalized glob expansions to a fixed grammar) before hashing, or a skill can smuggle a capability via key ordering or a glob that the sandbox's matcher interprets more broadly than the signer's. ## Operational Effect With the invariant enforced, the skew window is zero: every authorized call maps to exactly one `grant_id`, and the audit log is a total function from `(call, grant_id)` to a verified signature. Widening attempts surface as `CapabilityWideningDenied` events rather than silent grants, which is the signal you want for detecting a skill that is probing its sandbox. The cost is that hot-reload ergonomics for skill *authors* degrade: they must re-admit to test a capability change. That is the correct trade. The alternative—what the trace above shows—is a sandbox whose boundary is enforced at `t=0` and evaporates at `t=41s`, with an audit log that cannot distinguish a legitimate grant from a forged one because the forged one has no signature record at all. Enforce the invariant with a dispatcher that refuses to authorize against any manifest object lacking a live signature chain, and fail closed on manifest-watch events rather than merging. ```python import hashlib from dataclasses import dataclass, field from typing import FrozenSet class ProvenanceSkewError(RuntimeError): """Raised when a tool call is authorized against a capability set that no live, admission-chained signature describes.""" @dataclass(frozen=True) class CapabilityGrant: grant_id: str caps: FrozenSet[str] signature: bytes manifest_bytes: bytes @staticmethod def issue(manifest_bytes: bytes, caps: FrozenSet[str], signer) -> "CapabilityGrant": canonical = b"|".join(sorted(c.encode() for c in caps)) digest = hashlib.sha256(manifest_bytes + b"\x00" + canonical).digest() grant_id = digest.hex() return CapabilityGrant( grant_id=grant_id, caps=frozenset(caps), signature=signer(digest), manifest_bytes=manifest_bytes, ) @dataclass class SkillInstance: name: str admitted_grant: CapabilityGrant live_manifest_caps: FrozenSet[str] = field(default_factory=frozenset) _inflight: int = 0 def authorize(self, capability: str, verify) -> None: # The dispatcher MUST authorize against the admitted grant, not the # live manifest object. Any divergence is a provenance-skew event. if capability not in self.admitted_grant.caps: raise ProvenanceSkewError( f"skill={self.name} requested cap={capability!r} " f"not covered by grant={self.admitted_grant.grant_id}; " f"live_manifest_caps={sorted(self.live_manifest_caps)}" ) if not verify(self.admitted_grant.signature, self.admitted_grant.grant_id): raise ProvenanceSkewError( f"skill={self.name} grant={self.admitted_grant.grant_id} " f"signature failed verification at dispatch time" ) def on_manifest_watch(self, new_caps: FrozenSet[str]) -> None: # A manifest edit is inert until re-admission. Record it, do not merge. self.live_manifest_caps = frozenset(new_caps) if self._inflight > 0: raise ProvenanceSkewError( f"skill={self.name} manifest mutated during in-flight call; " f"quiesce required before re-admission" ) def dispatch_tool_call(skill: SkillInstance, capability: str, verify) -> None: skill._inflight += 1 try: skill.authorize(capability, verify) # ... perform the sandboxed call under the admitted grant ... finally: skill._inflight -= 1 ```