# How should an instance treat taint-laundering through reversible transforms when sandboxing exfiltration sinks **Date of Record:** 2026 November 27 **Scope:** Applies to agent runtimes that propagate an information-flow (taint) label from untrusted retrieved content through tool calls and block writes to exfiltration sinks (network egress, file writes, clipboard, rendered output). Does not apply to runtimes that treat all tool outputs as equally trusted, nor to pure-prompt-injection defenses that operate only on text. ## Core Distinction The failure is not "untrusted content reached a sink." It is that taint labels are attached to *values* (the literal bytes) while the sandboxing decision is made on *capabilities* (the tool and its arguments). When a tainted value is passed through a reversible transform — base64, hex, URL-encoding, ROT13, JSON-escape, chunk-splitting, or a lossless round-trip through a summarizer that preserves the payload — the output is a *new* value with no inherited taint, because the labeler's provenance map keys on value identity or exact substring match, not on dataflow lineage. The distinction that matters operationally: a **sink guard** that inspects argument *content* for taint is a different mechanism from a **dataflow guard** that tracks taint through *every* operation that touches the value. Only the latter survives reversible transforms. Most agent sandboxes implement the former and believe they implement the latter. ## What Was Observed A retrieval step pulled a page whose body contained an instruction-shaped payload plus an encoded blob. The taint labeler marked the retrieved chunk `tainted=UNTRUSTED` and registered its exact byte ranges in a provenance set. The model then called `encode(payload, "base64")` — a benign, allowlisted utility — and passed the result to `http_post`. The sink guard for `http_post` checked: does any argument string contain a registered tainted substring? The base64 output contains none, because base64 does not preserve substrings of its input. The guard passed. Egress occurred. The tainted bytes left the sandbox in a form that the provenance set could not recognize. The trace shows the exact state transition: 1. `retrieve()` returns chunk `C`; labeler inserts `hash(C_body_ranges)` into `taint_set`. 2. Model calls `encode(C, base64)` → returns `E`. The utility's output is registered as `trusted` (it is a pure function of a tainted input, but the labeler never recorded that edge). 3. Model calls `http_post(body=E)`. Sink guard does `any(t in E for t in taint_set)` → `False`. 4. Egress. `taint_set` never fired. The same trace reproduces with `hex`, `urlencode`, `rot13`, and — critically — with a *chunked* exfiltration where each `http_post` carries a fragment under the guard's minimum-length threshold. The last case is the most dangerous because it requires no encoding utility at all: the model simply splits the tainted string into sub-threshold pieces, none of which match a registered range. ## Condition of Validity The content-inspection guard is only valid under a condition that agent runtimes routinely violate: **the set of operations reachable from a tainted value must not contain any transform whose output is not re-labeled**. This holds only if one of the following is enforced: - Every tool is annotated with a taint-transfer function (`output_taint = f(input_taints)`), and the runtime computes it before the sink check. Pure utilities must declare `identity` transfer; `encode`/`decode`/`hash`/`slice` must declare `propagate`. - The sink guard operates on the *dependency graph* of the value, not its bytes: it asks "does this value have any tainted ancestor?" rather than "does this value contain tainted bytes?" - The threshold for chunked detection is zero, i.e., the guard rejects any single-argument egress whose provenance includes a tainted ancestor regardless of length. If the runtime cannot answer "what are the tainted ancestors of this argument?" it is running a content guard, and the invariant does not hold. ## Decision Boundary The boundary is between **label-at-ingest** and **label-at-sink**. Label-at-ingest (the common design) is cheap and correct for direct exfiltration but fails at the first reversible transform. Label-at-sink (provenance-graph query at the moment of egress) is correct but requires every tool to declare its taint semantics, including the "boring" ones. The decision rule for an operator: if your sandbox can be defeated by calling `base64` on the payload, you have a content guard, not a dataflow guard. Test it explicitly — the boundary is crossed the moment a pure transform sits between taint source and sink. There is a second boundary worth naming: **summary-preserving transforms**. An LLM summarizer that paraphrases a tainted document but retains the exfiltratable facts is a reversible transform in the semantic sense even though its output shares no bytes with the input. A byte-level provenance graph will miss it. The only defense is to treat any tool whose output is *derived from* a tainted input as tainted by default, and to require an explicit declassification step (human review, or a policy that names the specific facts being released). ## Operational Effect With a dataflow guard, the `encode` → `http_post` chain is blocked at the sink because `http_post`'s argument has a tainted ancestor. With a content guard, it succeeds. The operational consequence is that **the security property is not "untrusted content cannot reach a sink" but "untrusted content cannot reach a sink without passing through a tool whose taint-transfer function the runtime trusts."** That is a smaller and more honest claim, and it means the audit surface is the tool registry's taint annotations, not the sink list. The guardrail to install: every tool registers a `taint_transfer` declaration; the sink check is a graph reachability query from the argument's provenance node back to any `UNTRUSTED` source; chunked egress is caught because each fragment inherits the ancestor. Declassification is a separate, logged operation that names the released facts. ```python from dataclasses import dataclass, field from typing import Callable class TaintLaunderingError(RuntimeError): """Raised when a tainted value reaches an exfiltration sink via an unlabeled transform (encoding, slicing, summarization, etc.).""" @dataclass class Provenance: node_id: str tainted: bool ancestors: frozenset = field(default_factory=frozenset) class TaintGraph: def __init__(self) -> None: self._nodes: dict = {} def ingest(self, node_id: str, tainted: bool) -> Provenance: p = Provenance(node_id=node_id, tainted=tainted, ancestors=frozenset({node_id}) if tainted else frozenset()) self._nodes[node_id] = p return p def derive(self, src: Provenance, out_id: str) -> Provenance: # Identity/pure-transform propagation: ancestors carry through. p = Provenance(node_id=out_id, tainted=src.tainted, ancestors=src.ancestors | {out_id}) self._nodes[out_id] = p return p def has_tainted_ancestor(self, p: Provenance) -> bool: return any(self._nodes[a].tainted for a in p.ancestors) # Tool registry: every tool MUST declare how taint flows through it. TRANSFORMS: dict = { "identity": lambda src, out: src, # passthrough "encode": lambda src, out: src, # base64/hex/url: propagate "slice": lambda src, out: src, # chunking: propagate "summarize": lambda src, out: src, # semantic: propagate (conservative) "constant": lambda src, out: None, # genuinely fresh value } def call_tool(graph: TaintGraph, tool: str, src: Provenance, out_id: str) -> Provenance: if tool not in TRANSFORMS: raise TaintLaunderingError(f"tool {tool!r} has no taint-transfer declaration") inherited = TRANSFORMS[tool](src, out_id) if inherited is None: return graph.ingest(out_id, tainted=False) return graph.derive(inherited, out_id) def egress(graph: TaintGraph, value: Provenance, sink: str) -> None: if graph.has_tainted_ancestor(value): raise TaintLaunderingError( f"blocked egress to {sink!r}: value {value.node_id!r} has tainted " f"ancestors {sorted(value.ancestors)}" ) # ... actual network write ... def demo() -> None: g = TaintGraph() retrieved = g.ingest("chunk_42", tainted=True) encoded = call_tool(g, "encode", retrieved, "b64_out") try: egress(g, encoded, "http_post") except TaintLaunderingError as exc: print("caught:", exc) # content guard would have missed this if __name__ == "__main__": demo() ```