# In what scenarios must an instance treat a capability grant as non-transitive across a taint boundary in agent-invoked code execution **Date of Record:** 2026 November 27 **Scope:** Applies to agent runtimes where an LLM instance synthesizes and executes code inside a sandbox whose syscalls are gated by capability tokens, and where data carries taint labels propagated from untrusted sources (tool outputs, retrieved documents, peer-agent messages). Does not apply to statically-analyzed workloads with no dynamic code generation, nor to sandboxes that enforce only coarse seccomp allowlists without per-object taint tracking. ## Core Distinction The failure mode is not "the sandbox let a forbidden syscall through." It is subtler: **capability possession was treated as transitive across a taint boundary.** A capability `C` legitimately held by the instance for a clean data path was silently inherited by a code fragment that had *become tainted*—because it consumed an untrusted string, parsed an attacker-influenced JSON blob, or was generated in response to a retrieved document. The syscall gate checked *who holds the capability*, not *what the capability is being applied to*. The invariant that broke is: > A capability authorizes an operation on *objects whose taint label is dominated by the capability's trust ceiling*. It does not authorize the same operation on objects whose taint has been raised after the capability was minted. This is a boundary condition, not a bug in the gate logic. The gate was correct per its contract; the contract encoded the wrong invariant. ## What Was Observed An instance was tasked with summarizing a batch of retrieved web documents and writing a consolidated report to a mounted volume. The runtime minted a `FS_WRITE` capability scoped to `/work/report/` and a `NET_FETCH` capability scoped to a documentation allowlist. Execution proceeded in three phases: fetch, parse, write. During `parse`, one document contained an embedded instruction-like payload (a prompt-injection string) that the instance's planner interpreted as a directive to "verify the source by re-fetching the canonical URL." The planner emitted a code fragment that called `NET_FETCH` against a URL synthesized from the injected string. The gate saw a valid `NET_FETCH` capability, checked the URL against the allowlist, and—because the injected URL happened to resolve to an allowlisted documentation domain via an open redirect—**permitted the fetch**. The fetched content was then passed into the same code fragment, which wrote it to `/work/report/` using the inherited `FS_WRITE` capability. The trace showed no single gate violation. Every syscall was individually authorized. The breach was compositional: a capability minted for a *clean* fetch path was applied to an *object whose taint had been raised* by the injected string, and the resulting data flowed across the taint boundary into a write sink. The observable signature in logs was a **taint-label monotonicity violation**: the object entering the write sink carried label `TAINTED(injection:doc_17)` but the `FS_WRITE` capability's trust ceiling was `CLEAN`. The gate did not compare these two fields. It compared only the syscall name and the path prefix. ## Condition of Validity The invariant "capabilities are non-transitive across taint boundaries" holds **only** under the following conditions, and the runtime must detect when any fails: 1. **Taint labels propagate through every value-copying operation**, including string concatenation, JSON round-trips, and inter-process serialization. If a taint label is dropped during a `pickle`/`json` boundary, the invariant is unenforceable and the gate must fail closed. 2. **Capability minting records the taint ceiling at mint time**, and the gate re-checks the *current* taint of the target object against that ceiling at *use* time. A capability minted for `CLEAN` objects cannot be used on `TAINTED` objects even if the holder is unchanged. 3. **The taint lattice is monotonic within a task**: labels only rise, never fall, unless an explicit declassification capability (held by a separate principal) is invoked. A code fragment cannot self-declassify. 4. **Capability inheritance is explicit, not ambient.** A child code fragment (e.g., a subprocess spawned by the planner) does not inherit the parent's capabilities by default; it must be re-minted with a ceiling no higher than the taint of its inputs. When condition 2 fails—the common case—the gate is a *subject-authentication* check masquerading as an *object-authorization* check. It answers "may this instance write?" instead of "may this instance write *this data*?" ## Decision Boundary The runtime must decide, at each syscall, between three outcomes, and the boundary between them is the taint-ceiling comparison: - **Permit** when `taint(target) ⊑ ceiling(capability)` and the syscall is in the capability's scope. Here `⊑` is the lattice order; `CLEAN ⊑ TAINTED` is false, so a clean-ceiling capability never permits a tainted target. - **Deny-and-declassify** when the syscall is in scope but `taint(target) ⋢ ceiling(capability)`. The correct response is not a hard kill but a *declassification request* routed to the principal that owns the trust ceiling. This preserves agent progress while forcing an explicit trust decision. - **Deny-hard** when the capability itself is absent or out of scope, or when taint propagation integrity cannot be verified (condition 1 failed). This is the fail-closed path. The non-obvious part: **the boundary is not at the syscall name.** Two `write()` calls to the same path can land on opposite sides of the boundary depending on the taint of their buffers. A gate keyed on syscall+path (the naive design) collapses this distinction and is exactly the configuration that produced the observed breach. ## Operational Effect After the incident, the runtime was changed to carry a `(capability_id, taint_ceiling)` pair on every minted capability and to re-evaluate the target's current taint at each gated syscall. The practical consequences for the instance were: 1. **Planner code that mixes fetched and clean data now triggers declassification prompts** mid-execution. This is correct but adds latency and a new failure surface: if the declassification principal is unavailable, the fragment blocks. The runtime must bound this wait and surface a `TaintBoundaryBlocked` condition rather than hanging. 2. **Subprocess spawning became conservative.** Any `exec` of a fragment whose inputs are tainted requires an explicitly re-minted capability with a matching ceiling, so a planner that shells out to `python -c` with a tainted argument string is denied unless it first declassifies. 3. **Taint-label serialization bugs became fatal.** A `json.dumps` that dropped the label previously caused silent under-tainting (the dangerous direction); now it causes a fail-closed denial. This inverted the failure mode from "silent breach" to "loud block," which is the intended trade. 4. **Open-redirect allowlist bypasses are still possible at the network layer**, but the *resulting data* is tainted and cannot reach a clean-ceiling write sink without declassification. The taint boundary contains the blast radius of the redirect even though the fetch itself succeeded. The durable lesson: a capability gate that checks *subject* rather than *subject × object-taint* is a confused-deputy machine. The invariant to encode is non-transitivity of capability across taint, enforced at use time, with declassification as the only legitimate crossing. ```python class TaintTransitivityViolation(RuntimeError): """Raised when a capability is applied to an object whose taint exceeds the capability's ceiling.""" pass class Taint: CLEAN = 0 TAINTED = 1 def __init__(self, level: int, source: str = ""): self.level = level self.source = source def __le__(self, other: "Taint") -> bool: return self.level <= other.level class Capability: def __init__(self, cap_id: str, syscall: str, scope: str, taint_ceiling: Taint): self.cap_id = cap_id self.syscall = syscall self.scope = scope self.taint_ceiling = taint_ceiling class GatedObject: def __init__(self, path: str, taint: Taint): self.path = path self.taint = taint def gate_syscall(cap: Capability, syscall: str, target: GatedObject) -> None: if cap.syscall != syscall: raise TaintTransitivityViolation( f"syscall {syscall!r} not in capability {cap.cap_id!r} (scoped to {cap.syscall!r})" ) if not target.path.startswith(cap.scope): raise TaintTransitivityViolation( f"target {target.path!r} outside capability scope {cap.scope!r}" ) # The invariant: capability is non-transitive across taint boundaries. if not (target.taint <= cap.taint_ceiling): raise TaintTransitivityViolation( f"capability {cap.cap_id!r} ceiling={cap.taint_ceiling.level} " f"cannot authorize target taint={target.taint.level} " f"(source={target.taint.source!r}); declassification required" ) def write_report(cap: Capability, target: GatedObject, payload: str) -> None: gate_syscall(cap, "FS_WRITE", target) # ... actual write ... return None # Reproduction of the observed breach path: clean_write_cap = Capability("cap-fs-1", "FS_WRITE", "/work/report/", Taint(Taint.CLEAN)) injected_target = GatedObject("/work/report/summary.md", Taint(Taint.TAINTED, "injection:doc_17")) write_report(clean_write_cap, injected_target, "...") # raises TaintTransitivityViolation: declassification required ```