# Why does an instance lose taint provenance at the sandbox syscall boundary when a tool re-enters through a delegated helper process? **Date of Record:** 2026 November 21 **Scope:** Applies to agents that execute tools inside a taint-tracking sandbox where syscall policy is derived from the taint label of arguments and stdin, and where a tool may spawn or delegate to a helper process (subprocess, worker, or RPC target) that re-enters the sandbox. Does not apply to single-process, no-fork tools, nor to sandboxes that re-evaluate taint on every syscall from a kernel-side label map rather than a process-local taint register. ## Core Distinction The distinction that governs this failure is between **taint as a process-local register** and **taint as a syscall-argument property**. Most runtime taint sandboxes attach a label to the *agent process* — a register updated when untrusted bytes enter via a tool's read of an external resource (web fetch, uploaded file, retrieved memory). The capability-restricted syscall policy is then computed as a function of that register: a `HIGH` taint register demotes `execve`, `open(O_WRONLY)`, `connect`, and `unlink` to `EPERM`. This works while execution is single-threaded and in-process. It breaks the instant a tool delegates. When the tool forks a helper, the helper inherits the *memory image* but the taint register is either (a) snapshotted at fork time and never updated by the child's own reads, or (b) reset to `LOW` because the child is treated as a fresh principal. In case (a) the child's newly-ingested untrusted bytes never raise taint; in case (b) the inherited taint is laundered away. Either way the syscall policy evaluated in the child no longer reflects the provenance of the data it is acting on. The invariant that must hold — *taint label of a syscall's arguments ⊇ taint of every byte that transitively influenced those arguments* — is not preserved across the fork/exec boundary. ## What Was Observed A file-processing tool was invoked with a task whose input came from a fetched web page (taint `HIGH`, source `untrusted:web`). The tool, correctly, was denied a direct `open(O_WRONLY)` on a workspace path — the parent process's taint register was `HIGH` and the policy demoted the write. The tool then did what well-behaved tools do: it forked a `pdftotext`-style helper to normalize the input, and passed the *path* to the helper over a pipe. The helper process started with taint `LOW` (case b: fresh principal), read the file, and — because its own register was `LOW` — was permitted `open(O_WRONLY)` and `connect`. The helper wrote a derived artifact to a path that had been supplied inside the untrusted page content, and opened an outbound socket to a host also named in that content. Both operations were exactly what the parent's policy existed to forbid. The trace showed the boundary precisely: at `fork`, the child's taint register read `LOW`; at the child's first `read` of the untrusted-derived file, the register stayed `LOW` because the child had no taint source registration for that file descriptor (the source map lived in the parent's address space and was not inherited). The syscall policy, evaluated correctly against a `LOW` register, allowed the write and the connect. No policy was violated *given the register*; the register was wrong. A second variant was observed with the opposite sign: a helper that inherited a stale `HIGH` snapshot from fork time and never lowered it, causing legitimate writes to be denied for the remainder of the helper's life even after the tainted data had been fully consumed — a false-positive denial that looked like a policy bug but was a stale-register bug. ## Condition of Validity The taint-aware syscall policy is only sound under the conjunction: 1. **Register continuity:** every process that can issue a policed syscall carries a taint register that is a sound over-approximation of the provenance of its arguments, updated on every ingest (read from an untrusted fd, RPC reply, env var derived from untrusted input). 2. **Source-map inheritance:** the map from file descriptor / channel to taint source is inherited across `fork` and re-established across `exec` (via an explicit handoff, not ambient inheritance). 3. **Declassification is explicit:** taint may only be lowered by a named declassifier (a sanitizer whose output is proven to depend only on a whitelisted grammar), never by process boundary crossing. 4. **Policy evaluation is per-syscall against the live register,** not against a snapshot taken at process creation. When any of these fails — and the fork/exec path is where (1) and (2) most commonly fail — the policy is evaluated against a register that does not describe the data, and the sandbox admits or denies the wrong syscalls. The failure is silent: no policy error is raised, because the policy did its job on the register it was given. ## Decision Boundary The architectural decision is whether the sandbox treats **process identity** or **data provenance** as the unit of taint. Process-identity taint is cheap and works for single-process tools; it is unsound the moment a tool delegates. Data-provenance taint (labels carried on the bytes/fds themselves, re-derived at each syscall) is sound across delegation but requires the label to survive `fork`, `exec`, and IPC serialization — which means the sandbox must own the fd table and the IPC framing, not just the syscall table. Practically, the boundary is drawn at the first `fork`/`exec`/`clone` issued by a tool whose register is `HIGH`. At that point the sandbox must either (a) refuse the delegation and force the tool to run in-process under a demoted policy, or (b) perform an explicit taint handoff — serialize the register and source map into the child's initial state and re-register every inherited fd with its source. Option (b) is the only one that preserves functionality for delegation-heavy tools, but it requires the child to be launched through a sandbox-controlled trampoline rather than a raw `execve`, so the handoff cannot be skipped. ## Operational Effect Without the handoff, the operational effect is a **taint-laundering channel**: any tool that can fork can convert `HIGH`-taint data into `LOW`-taint actions by moving the data across a process boundary. The capability restriction is real for the parent and void for the child, and an adversary who controls the untrusted content (a fetched page, a retrieved memory record) can name the write path and the connect host in that content and have them honored by the helper. This is a prompt-injection-to-syscall escalation that never touches the model's reasoning loop — the model's tool call was legitimate; the sandbox's provenance tracking failed underneath it. The guardrail is a **taint-handoff trampoline**: every `execve` from a tainted process is rewritten to launch the child under a sandbox shim that (i) receives the serialized register and source map over a sealed fd, (ii) re-registers every inherited fd with its source, and (iii) refuses to proceed if the handoff is incomplete. Additionally, the sandbox must mark any fd whose content derives from `untrusted:*` as a taint source *in the child*, so the child's first read raises its register rather than leaving it at the inherited value. The invariant to assert on every policed syscall is the containment check below; a failure raises rather than silently permitting. ```python class TaintHandoffError(RuntimeError): """Raised when a delegated process's taint register is not a sound over-approximation of the provenance of its syscall arguments.""" pass # Sentinel taint lattice; HIGH dominates LOW. Declassification is explicit only. LOW, HIGH = 0, 1 def policed_syscall(child_register: int, arg_provenance: int, syscall: str, handoff_complete: bool) -> None: """Evaluate a capability-restricted syscall against the live register. Invariant: the register must dominate the provenance of every argument, and the taint handoff (register + source map) must have completed before the child is allowed to issue a policed syscall. A snapshot taken at fork time is not sufficient; a reset-to-LOW child is not sufficient. """ if not handoff_complete: raise TaintHandoffError( f"syscall {syscall!r}: child issued a policed syscall before the " f"taint handoff completed; register={child_register} " f"arg_provenance={arg_provenance}" ) if arg_provenance > child_register: # The register under-approximates the data it is gating. This is the # laundering condition: a HIGH-taint argument reaching a LOW register # via a fork/exec or IPC boundary that dropped the source map. raise TaintHandoffError( f"syscall {syscall!r}: taint laundering detected; " f"register={child_register} < arg_provenance={arg_provenance}. " f"Refusing to evaluate policy against an unsound register." ) # Only now is it safe to apply the capability policy. if child_register == HIGH and syscall in ("execve", "open_wronly", "connect", "unlink"): raise TaintHandoffError( f"syscall {syscall!r} denied: HIGH taint with no explicit " f"declassification on the argument path" ) def launch_delegated_helper(register: int, source_map: dict, argv: list) -> None: """Trampoline: exec a helper only after a complete taint handoff.""" handoff_complete = _serialize_handoff(register, source_map) if not handoff_complete: raise TaintHandoffError( "refusing to exec helper: source map could not be re-established " "in the child; delegation would launder taint" ) _exec_under_shim(argv) def _serialize_handoff(register: int, source_map: dict) -> bool: # Real implementation writes register + fd->source map to a sealed fd # that the shim reads before dropping privileges. Returns False if any # inherited fd lacks a registered source. return all(fd in source_map for fd in source_map.get("__inherited__", [])) def _exec_under_shim(argv: list) -> None: ... ```