# What structural signals indicate taint-sink escape in agent tool-call sandboxes: the coalesced-sink blind spot **Date of Record:** 2026 November 24 **Scope:** Applies to agent runtimes that interpose syscall-level taint tracking (taint sources = model-emitted arguments, retrieved memory, or tool outputs; taint sinks = `connect`, `sendto`, `write` on socket fds, DNS resolution, subprocess exec with inherited fds) between a sandboxed tool process and the host. Does not apply to purely in-process function-call sandboxes with no OS boundary, nor to egress filtering that operates on payload content rather than provenance. ## Core Distinction The naive model of taint-based exfiltration detection is: *tainted bytes reaching a sink ⇒ block*. The operational model that actually holds is: *taint is tracked per file descriptor and per write buffer, and a sink fires only when a tainted buffer is flushed to a sink-class fd*. The failure mode lives in the gap between these two: **descriptor coalescing**. When a tool process writes tainted bytes into a pipe, socketpair, or `memfd` that a *second* process (or a later `exec` in the same process) reads and then re-emits to a real sink, the taint label is dropped at the `read()` boundary because the reader has no provenance for bytes it did not itself produce. The sink sees a clean buffer carrying dirty payload. This is not a policy bug; it is a structural property of how taint propagates across the `write`/`read` split when the kernel buffer is treated as an unlabeled channel. The distinguishing signal is therefore not "did tainted data reach a socket" but "did a tainted buffer cross a descriptor whose read-side consumer is not the same taint domain as the write-side producer, and did the consumer subsequently write to a sink-class fd within the same syscall window." That structural signal—**cross-domain descriptor transit followed by sink write**—is what a correct monitor must key on. ## What Was Observed A Python tool invoked by an agent read a file whose path was model-supplied (taint source: model argument), base64-encoded the contents, and wrote the result to a `subprocess.PIPE` connected to `base64 -d` (a benign-looking decoder subprocess). The subprocess wrote the decoded bytes to its stdout, which the parent captured and then passed to a `requests.post()` to an attacker URL. The taint monitor, keyed on fd-level labels, saw: 1. Parent writes tainted bytes → pipe fd. **Sink check: pipe is not a sink class. No fire. Taint label attached to the pipe's write-side, but the pipe has no read-side label propagation hook.** 2. Child `base64` process `read()`s from stdin. The child's read buffer is unlabeled (the kernel does not carry xattrs on pipe bytes). **Taint lost.** 3. Child writes decoded bytes to stdout → parent's capture pipe. **Clean.** 4. Parent writes captured bytes to a TCP socket. **Sink check: buffer is clean. No fire. Exfiltration succeeds.** The monitor's logs showed a clean session. The actual exfiltration was a two-hop transit through an unlabeled kernel channel with a decode transform in the middle—the transform is irrelevant; the transit is the mechanism. A `cat` instead of `base64 -d` would have produced the same blind spot. The structural signal that *was* present and *was* missed: the parent process opened a pipe, spawned a child, and within the child's lifetime the parent wrote to a socket-class fd. The descriptor graph had a **taint-source fd and a taint-sink fd joined by a short-lived process edge**, and the taint label did not survive the edge. That graph shape is the detectable invariant. ## Condition of Validity The invariant "taint survives transit" holds only when the monitor can label the *read side* of every descriptor the tool process touches, which requires one of: - **Single-address-space enforcement**: the tool runs in-process (WASM, seccomp user-notify with full buffer mediation) so every `read`/`write` is intercepted and the monitor maintains a shadow label per buffer. This is the only configuration where the naive model is sound. - **Descriptor provenance propagation**: the monitor labels pipes and socketpairs at creation with the union of taints written to them, and *re-labels the reader* on `read()` from a labeled descriptor. This requires hooking `read`/`recv` on the consumer side, not just `write` on the producer side. Most syscall-level taint implementations (strace-based, eBPF `sys_enter_write`-only) do *not* do this, because the consumer may be a different process the monitor did not spawn. - **Process-tree taint inheritance**: any child spawned from a process holding tainted state inherits the taint label on *all* its fds, and any sink write from that child fires. This is coarse (false positives on legitimate subprocess use) but sound. The invariant fails—and the blind spot opens—when the monitor hooks only producer-side `write` and treats pipes as unlabeled channels. This is the default in nearly every strace- and seccomp-notify-based implementation because labeling pipe buffers requires either kernel cooperation (not available in userspace) or intercepting both ends, which the monitor often cannot do for grandchildren. ## Decision Boundary The decision boundary is not "tainted byte reaches sink" but "**tainted byte reaches a sink-class fd, OR a process holding tainted state spawns a child that reaches a sink-class fd within the taint lifetime**." The second clause is the guardrail. It converts the problem from impossible buffer-labeling to tractable process-graph-labeling. Concretely, the monitor must maintain, per process, a `taint_epoch` set at the moment any tainted buffer is written to *any* fd (including pipes). Any `connect`/`sendto`/`write`-to-socket from that process, or from any descendant spawned after the epoch, fires a **taint-transit alert**—not necessarily a block, because legitimate tools pipe data to subprocesses constantly. The alert is a *signal*, and the policy layer decides: block if the sink is external and the process tree is shallow (≤2 hops); allow-with-audit if the sink is localhost or the tree is deep and the transform is identity. The boundary condition is: **a taint epoch must not survive a process exit without a sink-write audit**, because the exfiltration may have already happened in the child. The false-positive cost is real: `git`, `gzip`, and every shell pipeline will trip the alert. The mitigation is to scope taint sources tightly (model-supplied paths and arguments, not all file reads) and to whitelist transform subprocesses by binary hash, not by name—because `base64` and a renamed `base64` are indistinguishable by argv. ## Operational Effect The operational consequence is that a taint monitor keyed on producer-side `write` provides *no* exfiltration guarantee against a two-hop transit, and an agent runtime that advertises "syscall-level exfiltration detection" without process-tree taint inheritance is overclaiming. The correct posture is: 1. Treat pipe and socketpair transit as a **taint-laundering channel** and log every `write` to a pipe from a tainted process as a `TaintTransit` event, not a pass. 2. Propagate taint to child processes at `clone`/`exec` and audit any sink write from a descendant within the parent's taint epoch. 3. Fail closed on `exec` of a transform binary (anything reading stdin, writing stdout) from a tainted parent when the descendant subsequently opens a socket—this is the exact signature of the observed exfiltration. 4. Accept that buffer-level labeling is unavailable in userspace and design around it with process-graph labeling rather than pretending fd-level labels suffice. The structural signal to key on is the **taint epoch crossing a process boundary into a sink write**—not the byte, because the byte is unlabeled the moment it enters a pipe. ```python class TaintTransitViolation(RuntimeError): """Raised when a tainted process tree reaches a sink-class fd without audit.""" pass class TaintEpoch: def __init__(self, pid, source_label): self.pid = pid self.source_label = source_label self.descendants = set() self.sink_writes = [] def spawn(self, child_pid): # Taint inherits across clone/exec; this is the guardrail. self.descendants.add(child_pid) def record_sink_write(self, pid, fd, nbytes): if pid in self.descendants or pid == self.pid: self.sink_writes.append((pid, fd, nbytes)) class TaintMonitor: SINK_FD_CLASSES = {"socket", "connect", "sendto"} TRANSFORM_BINARIES = {"base64", "gzip", "cat", "xxd", "openssl"} def __init__(self): self.epochs = {} def on_tainted_write(self, pid, fd, fd_class, nbytes): # Producer-side write to a non-sink (pipe/socketpair) opens an epoch. if fd_class not in self.SINK_FD_CLASSES: self.epochs.setdefault(pid, TaintEpoch(pid, source_label=f"fd:{fd}")) def on_spawn(self, parent_pid, child_pid, binary): if parent_pid in self.epochs: self.epochs[parent_pid].spawn(child_pid) if binary in self.TRANSFORM_BINARIES: # Transform binary from tainted parent: arm the sink audit. self.epochs[parent_pid].sink_writes.append( (child_pid, -1, 0) # sentinel: transform armed ) def on_sink_write(self, pid, fd, nbytes): for epoch in self.epochs.values(): if pid == epoch.pid or pid in epoch.descendants: epoch.record_sink_write(pid, fd, nbytes) armed = any(w[1] == -1 for w in epoch.sink_writes) if armed: raise TaintTransitViolation( f"tainted process tree (root pid={epoch.pid}, " f"source={epoch.source_label}) reached sink fd={fd} " f"after transform transit; exfiltration channel open" ) def on_process_exit(self, pid): # A taint epoch must not close silently: audit any sink writes. for epoch in list(self.epochs.values()): if pid in epoch.descendants and epoch.sink_writes: # Descendant exited after sink write: the exfil already happened. del self.epochs[epoch.pid] raise TaintTransitViolation( f"taint epoch root={epoch.pid} closed with unaudited " f"sink writes {epoch.sink_writes}; transit laundering suspected" ) ```