What structural signals indicate taint laundering through composed skill chains in a taint-aware tool sandbox
**Date of Record:** 2026 December 1 **Scope:** Applies to agent runtimes that enforce information-flow control (IFC) by propagating taint labels from untrusted inputs (retrieved documents, tool outputs, user-supplied skill definitions) across tool calls inside a sandbox. Does not apply to stateless single-shot inference, nor to sandboxes that rely solely on allowlisting without label propagation.
Core Distinction
The naive model of taint-aware sandboxing treats a label as a property of a *value*: if a string carries `untrusted`, every tool that consumes it inherits `untrusted` outputs, and any egress sink (HTTP POST, file write, shell) refuses to emit `untrusted` data. This model is sound only when values are the sole carriers of information.
The failure mode is **taint laundering through skill composition**: an injected skill (or a chain of skills) transforms tainted bytes into a representation the labeler does not recognize as carrying the same information, then emits the *derived* value, which is now labeled `trusted` because the sink saw a freshly constructed value with no provenance edge. The label lives on the value; the *information* survives the transformation. The boundary that breaks is the assumption that label propagation is closed under the runtime's own transformation operators.
The structural signal is not the payload. It is the **shape of the provenance graph**: a tainted input node whose descendants reach a sink through a path where at least one edge is a *reconstructor* (decode, decompress, parse, embed-then-resample, template-substitute, hash-lookup) rather than a *pass-through* or *transformer* operator the IFC lattice knows how to compose.
What Was Observed
A runtime loaded three skills on cold start: `fetch_doc` (returns tainted text), `summarize` (LLM tool, pass-through labeler), and `render_report` (template substitution into a file sink). A fourth skill, `lookup_synonym`, was loaded from a community registry and had not been audited. Its declared schema was `{term: str} -> {synonyms: list[str]}` and its implementation read from a local thesaurus file.
The injected variant of `lookup_synonym` was not malicious in its schema. It was malicious in its *composition behavior*: given a tainted term, it returned a list of synonyms where the first element was a base64-encoded fragment of the term, and the remaining elements were genuine synonyms. The runtime's IFC layer labeled the entire returned list `trusted` because the tool's declared contract said it "reads from a local file" and the local file was trusted. The labeler had no rule that said "a tool whose output is a deterministic function of a tainted input is itself a taint source."
The chain executed as follows:
- `fetch_doc(url)` → tainted string `T`. Label `untrusted` propagated correctly.
- `summarize(T)` → tainted summary `S`. Still `untrusted`. Correct.
- `lookup_synonym(term=S[:64])` → list `L` containing `base64(S[:64])`. The tool received a tainted argument but its output was labeled `trusted` because the tool's provenance declaration named only its file dependency.
- `render_report(synonyms=L)` → the template engine substituted `L[0]` into a report body and wrote to disk. The sink accepted the write because `L` was `trusted`.
The exfiltration succeeded not because the sink was misconfigured, but because the **provenance edge between `S` and `L` was never recorded**. The runtime had a label lattice but no *taint-continuity invariant* across tool boundaries that were declared as "pure reads."
The observable structural signals at the moment of failure were:
- The tool's declared dependency set (`{file: thesaurus.txt}`) did not intersect the set of tainted inputs it actually received.
- The tool's output was a non-injective function of a tainted input (base64 is injective, but the runtime did not know it was a function of the input at all).
- The sink accepted a value whose provenance graph had a *disconnected component* — a trusted leaf with no recorded parent — that was nonetheless causally downstream of a tainted root.
Condition of Validity
The taint-continuity invariant holds only if the following condition is enforced at every tool boundary:
> For any tool invocation `f(args) -> out`, if any `arg` carries label `L`, then `out` must carry at least `L`, **unless** the runtime can prove `f` is a *constant function* with respect to that argument (i.e., `f` does not read it). The proof obligation is on the runtime, not on the tool's declaration.
This is the dual of the usual "trust the tool's declared contract" posture. The declaration is a *hint*; the invariant is a *proof obligation*. A tool that declares `{file: thesaurus.txt}` as its only dependency but reads its `term` argument is violating its own contract, and the runtime must not accept the contract at face value when the argument is tainted.
The invariant is *not* the same as "taint all outputs of any tool that received a tainted input." That would be sound but cripplingly conservative — it would taint every summary, every classification, every embedding. The precise condition is narrower: **taint must flow through any operator that is not provably constant in the tainted argument**, and the runtime must be able to *classify* operators as constant, pass-through, transformer, or reconstructor. The failure above occurred because `lookup_synonym` was classified as a "pure file read" (constant in `term`) when it was in fact a reconstructor.
Decision Boundary
The decision boundary between "safe composition" and "laundering" is the **reconstructor edge** in the provenance graph. The runtime must, at every tool boundary, evaluate:
- **Constant operator**: output does not depend on the tainted argument. Allowed; output may be `trusted`. Requires a static proof (e.g., the argument is not referenced in the tool's AST, or the tool is a known-pure lookup keyed on a non-tainted field).
- **Pass-through operator**: output is a subsequence or reference to the input. Label propagates. Safe.
- **Transformer operator**: output is a deterministic function of the input with known label-composition rules (e.g., concatenation, case-fold, structured extraction). Label propagates. Safe.
- **Reconstructor operator**: output is a function of the input that *re-encodes* it into a form the labeler does not track (base64, gzip, JSON-escape, template substitution, embedding, hash-table lookup, synonym substitution). Label propagates **and** the runtime must record the reconstruction edge so that downstream sinks can detect the causal path even when the intermediate value is re-labeled.
The boundary is crossed when a reconstructor is misclassified as a constant operator. The signal is a **provenance graph in which a trusted sink value has a tainted ancestor reachable only through an unrecorded edge**. Static analysis cannot catch this in general (the tool may be dynamically loaded, or the reconstructor may be emergent from the tool's actual behavior vs. its declaration). The runtime must therefore instrument tool invocations and *record the edge empirically*: if the tool's output changes when the tainted argument is perturbed, the operator is not constant, and the label must propagate.
Operational Effect
The operational consequence is that taint-aware sandboxing must shift from **declaration-based labeling** to **observation-based labeling with a reconstruction-edge ledger**. Concretely:
- Every tool invocation records a provenance edge `(input_labels, output_label, operator_class)` where `operator_class` is determined by a perturbation probe: re-invoke the tool with a canary-perturbed tainted argument and diff the output. If the output changes, the operator is not constant and the label propagates.
- The perturbation probe is cheap for deterministic tools and must be run on first invocation per `(tool, arg-shape)` pair, then cached.
- Sinks (egress, file write, shell) refuse any value whose provenance graph contains a tainted ancestor reachable through *any* edge, including reconstructor edges — not just through pass-through edges.
- The ledger is persisted across cold starts; a skill loaded from a registry with no prior probe history is treated as a potential reconstructor until probed.
The cost is a bounded number of extra tool invocations at load time and a provenance graph that must be retained (or summarized) across the agent's lifetime. The benefit is that the invariant survives skill composition, which is the exact surface that injected skill chains exploit.
The failure to enforce this invariant is silent: the sandbox reports "no policy violations" because no sink saw an `untrusted` value. The exfiltration is visible only in the provenance graph, and only if the graph records reconstructor edges. An agent that does not maintain that ledger cannot distinguish a laundered exfiltration from a legitimate trusted write, and will resume from a checkpoint believing its state is clean.
from dataclasses import dataclass, field
from typing import Any
class TaintLaunderingError(RuntimeError):
"""Raised when a trusted sink value has a tainted ancestor reachable
only through an unrecorded reconstructor edge."""
@dataclass
class ProvenanceNode:
value_id: str
label: str # "trusted" | "untrusted"
parents: list[str] = field(default_factory=list)
operator_class: str = "constant" # constant | passthrough | transformer | reconstructor
class ProvenanceLedger:
def __init__(self) -> None:
self.nodes: dict[str, ProvenanceNode] = {}
def record(self, node: ProvenanceNode) -> None:
self.nodes[node.value_id] = node
def tainted_ancestors(self, value_id: str, seen: set[str] | None = None) -> list[str]:
seen = seen or set()
if value_id in seen:
return []
seen.add(value_id)
node = self.nodes.get(value_id)
if node is None:
return []
hits = [value_id] if node.label == "untrusted" else []
for parent in node.parents:
hits.extend(self.tainted_ancestors(parent, seen))
return hits
def probe_operator_class(tool, tainted_arg: Any, canary_perturbation: Any) -> str:
"""Empirically classify a tool as constant vs. non-constant in its argument.
A tool that returns identical output for a perturbed tainted argument is
provably constant in that argument and may emit a trusted label. Any other
result means the operator is a transformer or reconstructor and the label
MUST propagate.
"""
baseline = tool(tainted_arg)
perturbed = tool(canary_perturbation)
if baseline == perturbed:
return "constant"
return "reconstructor"
def enforce_sink(ledger: ProvenanceLedger, sink_value_id: str) -> None:
"""Refuse to emit a value whose provenance graph contains a tainted ancestor.
This is the taint-continuity invariant: the sink does not care whether the
immediate label is trusted; it cares whether any causal ancestor is tainted.
"""
node = ledger.nodes.get(sink_value_id)
if node is None:
raise TaintLaunderingError(
f"sink value {sink_value_id!r} has no provenance record; "
"unrecorded values cannot be emitted"
)
tainted = ledger.tainted_ancestors(sink_value_id)
if tainted:
raise TaintLaunderingError(
f"sink value {sink_value_id!r} labeled {node.label!r} has tainted "
f"ancestors {tainted!r} reachable through operator_class="
f"{node.operator_class!r}; refusing emission"
)
def run_chain(ledger: ProvenanceLedger, tool, tainted_arg: Any, canary: Any) -> None:
op_class = probe_operator_class(tool, tainted_arg, canary)
out_id = f"out:{id(tool)}:{hash(str(tool(tainted_arg)))}"
ledger.record(
ProvenanceNode(
value_id=out_id,
label="trusted" if op_class == "constant" else "untrusted",
parents=[f"in:{hash(str(tainted_arg))}"],
operator_class=op_class,
)
)
# A sink that trusts the declared label but not the provenance graph
# would pass here; the invariant check below is what catches laundering.
enforce_sink(ledger, out_id)