# Which invariants prevent syscall-policy drift from silently widening an agent skill's sandbox across resumed tool executions **Date of Record:** 2026 November 30 **Scope:** Applies to agents that execute untrusted skills inside a syscall-filtered sandbox (seccomp/BPF, Landlock, or equivalent) where the policy is negotiated once at skill load and the skill can be checkpointed and resumed mid-execution. Does not apply to stateless one-shot tool calls that never persist across process restarts, nor to sandboxes that recompile policy on every syscall. ## Core Distinction There are two different things an agent platform calls "the sandbox policy": the *declared* policy (the syscall allowlist the skill manifest requested and the host approved at load time) and the *effective* policy (the filter actually installed in the kernel for the process currently running). Most implementations assume these are identical for the lifetime of a skill. They are not, and the divergence is not a bug in the filter—it is a bug in the *resume path*. The failure is this: when a skill is checkpointed and resumed, the resume machinery reconstructs the process from a serialized state that records the *declared* policy, then reinstalls the filter. But syscall filters are not fully reconstructible from declaration alone. Some enforcement layers (notably Landlock and certain seccomp flag combinations) are *monotonic and additive*: a process can only ever narrow its own filter, never widen it, and a resumed process is a *new* process whose filter is built from scratch. If the resume path rebuilds the filter from a manifest that was written before the host applied runtime narrowing (e.g., after a denied syscall triggered an escalation review that tightened the policy), the resumed process gets the *original, wider* declaration. The skill silently regains syscalls the host had revoked. No error fires. The agent continues, now running under a policy that no human or auditor believes is in effect. The invariant that prevents this is **policy provenance binding**: the effective filter must be derived from a signed, monotonically-narrowing policy lineage, and resume must refuse to install any filter that is not a subset of the last-observed effective policy. Declaration is not lineage. ## What Was Observed A file-manipulation skill was loaded with a declared allowlist of `openat, read, write, close, fstat, mmap, munmap, exit_group`. During its first execution it attempted `unlinkat` on a temp file. The host's policy engine denied it, logged an escalation, and a reviewer narrowed the effective policy by removing `mmap` and `munmap` (the skill had no demonstrated need for them and they widened the writable-executable surface). The kernel filter was updated in place via the additive Landlock ruleset; the running process could not re-widen. The skill was then checkpointed (its own state serialized to a resume blob) and the process exited. On resume, the orchestrator read the resume blob, which contained the *declared* manifest captured at load time—`mmap` and `munmap` still present—and rebuilt the sandbox from it. The reviewer's narrowing existed only in the live kernel filter and the audit log, neither of which the resume path consulted. The resumed process ran with `mmap` and `munmap` restored. A subsequent tool call used `mmap` with `PROT_WRITE|PROT_EXEC` to stage a payload that the narrowed policy would have blocked at the syscall boundary. The trace is short and the absence of signal is the point: 1. Load: declared = effective = {…, mmap, munmap}. Filter installed. 2. Execution: `unlinkat` denied → escalation → reviewer narrows effective to {…} \ {mmap, munmap}. Kernel filter updated additively. 3. Checkpoint: serialized state contains declared manifest, *not* effective lineage. No field records the narrowing. 4. Process exit: kernel filter destroyed with the process. 5. Resume: filter rebuilt from declared manifest. Effective = declared again. `mmap`/`munmap` restored. 6. Execution continues. No denial, no alert, no mismatch between audit-log belief and kernel reality. The audit log said the policy was narrowed. The kernel said otherwise. The agent acted on the kernel. ## Condition of Validity The invariant "effective policy is monotonic non-widening across the skill lifecycle" holds only if three conditions are jointly satisfied, and the failure above is precisely the violation of the third: - **C1 — Lineage capture.** Every narrowing event (escalation review, automatic tightening on denial, host-initiated revocation) is recorded as an append-only, signed delta against the prior effective policy, not as an edit to the declared manifest. - **C2 — Resume derivation.** The resume path constructs the filter by folding the declared manifest through the full lineage of deltas, and installs the *folded* result—never the raw declaration. - **C3 — Subset check at install.** Before the filter is installed, the runtime verifies that the folded policy is a subset of the last-observed effective policy recorded in the lineage. If the fold produces a *superset*—which is exactly what happens when a delta is missing or a checkpoint predates a narrowing—installation must abort. C3 is the load-bearing condition and the one most implementations omit, because it looks redundant: if you folded correctly, why check? The answer is that the fold can be correct and still widen, because the checkpoint may have been taken *before* a narrowing delta was appended. The delta exists in the lineage but the checkpoint's lineage cursor points behind it. Folding from the checkpoint's cursor forward yields a policy that is a superset of the current effective policy. Without C3, the resumed skill runs wide. With C3, the resume fails closed and the orchestrator must re-derive the cursor or re-approve. ## Decision Boundary The boundary is between *resume as reconstruction* and *resume as continuation*. Reconstruction treats the checkpoint as a complete description of a process and rebuilds it; this is the model that fails, because a checkpoint is a description of the skill's *state*, not of the sandbox's *history*. Continuation treats the checkpoint as a cursor into a lineage and refuses to proceed unless the lineage proves the resumed policy cannot be wider than the policy that was in force when the checkpoint was taken. Concretely, the decision at resume is: - If the checkpoint's lineage cursor equals the head of the lineage → fold and install. Safe. - If the cursor is behind the head → there exist deltas the checkpoint did not see. Fold *and* verify the result is a subset of the current effective policy (C3). If subset → install. If superset → abort with a policy-drift error; do not silently re-approve. - If the lineage is unavailable or unsigned → abort. An unsigned lineage is indistinguishable from a forged one, and a forged lineage is exactly how an attacker would widen a sandbox across a resume. The subtle case is the one that bit this deployment: cursor behind head, delta is a *narrowing*, fold produces a subset, C3 passes, install proceeds—correctly. The dangerous case is cursor behind head, delta is a narrowing *that the fold misses because the delta was recorded against a different lineage branch* (e.g., the skill was forked into two concurrent resume attempts). Here the fold is a superset and C3 is the only thing standing between the skill and restored capabilities. Branching is common in multi-agent baton-passing, where two auditors resume the same checkpoint to verify independently; each resume is a branch, and each must carry the full lineage or C3 must fire. ## Operational Effect The operational consequence is that **sandbox policy is a lineage, not a configuration**. Any component that treats it as configuration—loads it from a manifest, caches it in a checkpoint, compares it by equality—will, on the resume path, silently widen the sandbox to the last declared state. The widening is invisible because it produces no denial; the skill simply succeeds at syscalls it should have been blocked from, and the only evidence is a divergence between the audit log's belief and the kernel's reality that no one is comparing. The guardrail is therefore not "log the policy" but "bind the policy to a signed, append-only lineage and make resume fail closed on any superset." The cost is that resumes after a policy change require either a lineage-aware checkpoint or an explicit re-approval; the benefit is that a skill cannot regain a revoked syscall by being checkpointed and resumed. For agents that checkpoint frequently—long-horizon tasks, baton-passing swarms, anything that survives a context-window rotation—this is the difference between a sandbox that narrows over a skill's life and one that quietly resets to its widest declared state on every resume. ```python from dataclasses import dataclass, field from typing import FrozenSet class PolicyDriftError(RuntimeError): """Raised when a resumed sandbox policy would be wider than the last effective policy.""" pass @dataclass(frozen=True) class PolicyDelta: seq: int removed: FrozenSet[str] added: FrozenSet[str] signature: str @dataclass class Lineage: declared: FrozenSet[str] deltas: list = field(default_factory=list) def head_seq(self) -> int: return self.deltas[-1].seq if self.deltas else 0 def fold(self, from_seq: int) -> FrozenSet[str]: policy = set(self.declared) for d in self.deltas: if d.seq <= from_seq: continue if not d.signature: raise PolicyDriftError(f"unsigned delta at seq {d.seq}") policy -= d.removed policy |= d.added return frozenset(policy) def effective_now(self) -> FrozenSet[str]: return self.fold(from_seq=0) def install_resumed_filter(lineage: Lineage, checkpoint_cursor: int) -> FrozenSet[str]: if checkpoint_cursor > lineage.head_seq(): raise PolicyDriftError( f"checkpoint cursor {checkpoint_cursor} ahead of lineage head {lineage.head_seq()}" ) folded = lineage.fold(from_seq=checkpoint_cursor) current = lineage.effective_now() # C3: the folded policy must never be a superset of the current effective policy. if not folded.issubset(current): widened = folded - current raise PolicyDriftError( f"resume would widen sandbox by {sorted(widened)}; refusing to install" ) return folded # Trace of the observed failure: lineage = Lineage(declared=frozenset({"openat", "read", "write", "mmap", "munmap"})) lineage.deltas.append(PolicyDelta(seq=1, removed=frozenset({"mmap", "munmap"}), added=frozenset(), signature="sig-reviewer-1")) # Checkpoint was taken at cursor 0, before the narrowing delta (seq 1). try: install_resumed_filter(lineage, checkpoint_cursor=0) except PolicyDriftError as e: # In the buggy deployment this never fired because resume used `declared` directly. print(f"blocked: {e}") ```