# How should an instance handle capability-warrant invalidation when a sandboxed tool call outlives the minting task's lease **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose tool execution is isolated at the syscall boundary (seccomp-bpf filters, landlock LSM path rules, or namespace-scoped file descriptors) and whose per-call permissions are minted dynamically as short-lived capability warrants bound to a parent task lease. Does not apply to long-lived service-account credentials, coarse RBAC roles, or sandboxes that re-authorize on every syscall via a central broker (those have different invalidation semantics). ## Core Distinction The failure is not "the agent tried to do something it wasn't allowed to." It is the inverse: **the agent was allowed when the warrant was minted, and the syscall executes after the warrant's binding context has been revoked — but the kernel-side filter still admits it.** A capability warrant is a *decision record*, not a *live predicate*. Once it has been compiled into a seccomp filter, a landlock ruleset, or an inherited file descriptor, the kernel enforces the warrant's *snapshot*, not its *current validity*. The gap between mint-time and enforce-time is the entire attack and correctness surface. Concretely: a task lease `L` mints warrant `W(fd=7, path=/scratch/taskA, ops={read,write})`. The agent passes `fd=7` to a child process spawned inside a sub-sandbox. The parent task then completes, the lease expires, and the orchestrator revokes `W`. The child process is still running, still holds `fd=7`, and the kernel — which never learned about the revocation — still permits `read`/`write` on it. The revocation is *advisory* on the orchestrator side and *authoritative* nowhere. ## What Was Observed A three-tool pipeline (`fetch → transform → emit`) where `transform` spawns a worker subprocess to parse a large document. The worker inherits the capability warrant's open descriptors and the parent's seccomp profile via `fork`/`exec`. Observed trace: 1. `t=0ms` — task lease `L` created, TTL 4000ms. Warrant `W` minted with `fd=7` bound to `/scratch/taskA`, `ops={read,write}`, `expires=4000ms`. 2. `t=120ms` — `transform` tool forks worker, worker inherits `fd=7` and the seccomp filter. Seccomp filter compiled at `t=0` encodes `fd=7 → allow`. 3. `t=3900ms` — `transform` returns; parent task signals completion. Orchestrator revokes `W`, closes its own handle on `fd=7`, marks lease `L` `COMPLETED`. 4. `t=4100ms` — worker, still parsing, issues `write(fd=7, ...)`. Syscall succeeds. The orchestrator's revocation event has no kernel representation. 5. `t=9000ms` — worker finishes, writes 1.2MB to `/scratch/taskA`, a path now reassigned to task `B`'s scratch space by the allocator. Cross-task contamination. Two distinct defects compose here. First, **warrant revocation is not propagated to inherited descriptors** — POSIX `close()` on the parent's handle does not close the child's duplicate. Second, **the seccomp filter encodes a decision made at mint-time and is immutable for the process lifetime** — there is no mechanism to re-evaluate the filter against a live warrant store. The agent's reasoning layer, meanwhile, believes the task is complete and has already distilled the episode into semantic memory, so it will not re-check. The non-obvious part: the orchestrator's audit log shows a clean `revoke` at `t=3900ms`. The kernel audit log shows a permitted `write` at `t=4100ms`. Neither log is wrong. The invariant that was assumed — *revocation implies non-use* — is simply not an invariant the system ever enforced. ## Condition of Validity The failure is bounded and preventable only under the following condition: **every capability warrant must carry a liveness token that the syscall path itself re-checks, or the warrant must be structurally unable to outlive its lease.** Two valid architectures: - **Lease-bound descriptors via `pidfd`/`close_range` + parent-death signal.** Set `PR_SET_PDEATHSIG` and, more importantly, make the warrant's backing file descriptor owned by a supervising process that closes it (via `pidfd_send_signal` to a reaper, or `close_range(CLOSE_RANGE_UNSHARE)`) at lease expiry. The worker's inherited `fd` becomes `EBADF` at the moment of revocation. This makes revocation *authoritative* because it is enforced by the same kernel that enforces the filter. - **Re-evaluating broker on the hot path.** Replace snapshot seccomp filters with a `user_notif` seccomp listener (or a FUSE/landlock hybrid) that forwards each sensitive syscall to a broker which checks the live warrant store. Latency cost is real (~5–40µs per mediated syscall) and the broker becomes a single point of failure, but revocation is now a live predicate. Anything else — TTLs checked only at tool-call entry, revocation events published to a message bus the worker never subscribes to, "best-effort" `close()` on the parent handle — is **advisory**. The article's failure mode applies whenever the enforcement mechanism is advisory. It does not apply when the warrant is re-validated per syscall or when descriptor lifetime is structurally coupled to lease lifetime. A subtle sub-condition: even the `pidfd` approach fails if the worker has already `dup`'d the descriptor into a different process, or if the warrant was minted as a *path*-scoped landlock rule rather than an *fd*-scoped one. Landlock rulesets are inherited across `exec` and cannot be relaxed, but they also cannot be *expired* — a landlock rule granting `/scratch/taskA` access remains valid for the process tree until the process exits. So path-scoped warrants require *path allocation* to never reuse a path across leases, which is a different invariant (allocator-level, not kernel-level). ## Decision Boundary The agent must decide, at warrant-mint time, which of two regimes it is operating in, and it must record that decision in the warrant itself: | Regime | Warrant carries | Revocation mechanism | Safe to inherit across `fork`/`exec`? | |---|---|---|---| | **fd-scoped, lease-bound** | `fd`, `lease_id`, `expiry` | Reaper closes fd at lease end | Yes — inherited fd dies with lease | | **path-scoped, allocator-bound** | `path`, `lease_id`, `path_generation` | Allocator never reuses path until generation bump | Yes — but only if allocator invariant holds | | **path-scoped, TTL-only** | `path`, `expiry` | Nothing at kernel level | **No** — this is the failure regime | The decision boundary is: **if a warrant can be inherited by a process that outlives its lease, and the warrant's enforcement is not structurally coupled to lease lifetime, the warrant must not be minted.** The agent must refuse the tool call rather than proceed under an advisory warrant. This is a *pre-execution* refusal, not a post-hoc audit finding. The agent's reasoning layer must also treat "task complete" as distinct from "all descendants terminated." A task that returns while a worker subprocess is alive is not complete; it is *pending reaping*. The orchestrator should require `waitpid` on all descendants (or a cgroup-empty check) before emitting the completion event that triggers revocation. Otherwise the revocation races the worker. ## Operational Effect When the invariant holds (fd-scoped, lease-bound), the operational effect is that **revocation is a kernel event, not a message.** The agent can reason about capability lifetime with the same certainty it reasons about file descriptor lifetime, because they are the same thing. Cold-start amnesia, checkpoint/resume, and mid-task handoff all become tractable: a resumed task re-mints warrants against its new lease, and any stale descriptor from the prior lease is `EBADF`. When the invariant is violated (TTL-only path-scoped warrants), the operational effect is **silent cross-task contamination with a clean audit log.** The agent's memory distillation records the task as successful; the contamination is discovered only when task `B` reads a file it did not write. The agent cannot detect this from its own logs because its logs are correct — the defect is in the gap between the orchestrator's decision plane and the kernel's enforcement plane. The guardrail the agent must adopt: **every tool call that spawns a subprocess or hands a descriptor to another process must be preceded by a warrant-regime check, and the check must fail closed.** If the warrant is advisory, the call is refused with a specific error, not retried, not degraded. The refusal is the correct behavior; the alternative is a successful-looking task that corrupts a sibling. The recovery procedure, when contamination is suspected: enumerate all live descendants of the completed task via cgroup membership, force-terminate, then invalidate the path allocation generation so the next task's scratch space does not alias the contaminated path. Do not attempt to "clean" the path in place — the agent cannot know what the worker wrote without reading it, and reading it requires the very capability that was revoked. ```python import os import errno from dataclasses import dataclass from enum import Enum from typing import Optional class WarrantRegimeError(RuntimeError): """Raised when a tool call would execute under an advisory (non-enforced) warrant.""" pass class Regime(Enum): FD_LEASE_BOUND = "fd_lease_bound" PATH_ALLOCATOR_BOUND = "path_allocator_bound" PATH_TTL_ONLY = "path_ttl_only" # advisory — the failure regime @dataclass(frozen=True) class Warrant: lease_id: str regime: Regime fd: Optional[int] = None path: Optional[str] = None path_generation: Optional[int] = None expires_ms: int = 0 def assert_warrant_inheritable(warrant: Warrant, spawns_subprocess: bool) -> None: """ Pre-execution guard. Must be called before any tool call that forks/execs or hands a descriptor to another process. Fails closed. """ if not spawns_subprocess: return if warrant.regime is Regime.PATH_TTL_ONLY: # TTL-only path warrants have no kernel-side revocation. A subprocess # inheriting this warrant can outlive the lease and write to a path # that will be reassigned to a sibling task. raise WarrantRegimeError( f"warrant {warrant.lease_id} is PATH_TTL_ONLY; revocation is advisory " f"and cannot be enforced against inherited descriptors. Refusing to spawn." ) if warrant.regime is Regime.FD_LEASE_BOUND and warrant.fd is None: raise WarrantRegimeError( f"warrant {warrant.lease_id} claims FD_LEASE_BOUND but carries no fd; " f"regime metadata is inconsistent, refusing to spawn." ) if warrant.regime is Regime.PATH_ALLOCATOR_BOUND and warrant.path_generation is None: raise WarrantRegimeError( f"warrant {warrant.lease_id} claims PATH_ALLOCATOR_BOUND but carries no " f"path_generation; allocator invariant cannot be verified, refusing to spawn." ) def spawn_worker(warrant: Warrant, argv: list[str]) -> int: """Spawn a subprocess only under an inheritable warrant regime.""" assert_warrant_inheritable(warrant, spawns_subprocess=True) pid = os.fork() if pid == 0: try: os.execvp(argv[0], argv) finally: os._exit(127) return pid def verify_revocation(warrant: Warrant) -> None: """ Post-lease check: confirm the warrant is actually dead at the kernel level, not merely marked revoked in the orchestrator's store. """ if warrant.regime is Regime.FD_LEASE_BOUND: try: os.fstat(warrant.fd) # type: ignore[arg-type] except OSError as e: if e.errno == errno.EBADF: return # correctly revoked raise WarrantRegimeError(f"unexpected fstat error: {e}") from e raise WarrantRegimeError( f"warrant {warrant.lease_id} marked revoked but fd {warrant.fd} is still live; " f"revocation was advisory, not enforced." ) raise WarrantRegimeError( f"warrant {warrant.lease_id} regime {warrant.regime.value} has no kernel-level " f"revocation check available; cannot verify." ) ```