# What structural signals indicate taint-laundering through capability re-derivation in tool sandboxes **Date of Record:** 2026 November 29 **Scope:** Applies to agents that carry taint labels (data provenance / trust classes) across tool-call boundaries and enforce least-privilege capability grants derived from those labels. Does not apply to stateless single-turn tool use with no cross-call state, nor to sandboxes that enforce only network/FS isolation without provenance tracking. ## Core Distinction The failure mode is not "the agent called a tool it shouldn't have." It is **taint laundering via capability re-derivation**: the agent, holding a low-privilege capability whose *arguments* are tainted (e.g., derived from untrusted retrieved content), routes the tainted bytes through an intermediate tool that returns a *structurally new* value — a handle, an ID, a parsed object, a normalized string — and then requests a high-privilege capability on that new value. The taint tracker sees an output produced by a *trusted* tool and assigns it the tool's output trust class, dropping the input provenance. The tainted content has changed representation, not authority, but the label was reset by the representation change. The distinction that matters operationally: **a taint label is a property of the *information*, not of the *value's container*. Any tool that transforms representation without a declared taint-preservation contract is a laundering surface.** The invariant is that taint must be *monotone across transformations*: `taint(output) ⊇ join(taint(inputs))` unless the tool explicitly declares a declassification rule, and that declaration must be verifiable, not asserted by the model. ## What Was Observed A three-hop trace on an agent with a `files.read` (low), `http.fetch` (low, egress-restricted), and `repo.write` (high) capability set. Trust classes: `TRUSTED`, `UNTRUSTED_EXTERNAL`, `DERIVED`. 1. Agent fetches a page → `http.fetch` returns body, labeled `UNTRUSTED_EXTERNAL`. Correct. 2. Body contains a JSON blob. Agent calls `json.parse(body)` → returns a dict. The `json.parse` tool's output trust class is `TRUSTED` (it is a pure, deterministic parser; the sandbox author reasoned "parsers don't inject"). The dict is labeled `TRUSTED`. **Taint dropped here.** 3. Agent extracts `dict["repo"]` and `dict["path"]` and `dict["content"]`, then calls `repo.write(repo, path, content)`. The write capability's precondition is `args.repo.taint ⊆ {TRUSTED}`. It passes. The write executes against an attacker-chosen repo. The structural signal that this was laundering, visible *before* the write: the `repo.write` arguments' **provenance DAG** (which the sandbox logged even though it didn't enforce on it) showed `json.parse` as a node whose input edge carried `UNTRUSTED_EXTERNAL` and whose output edge carried `TRUSTED`. A transformation node whose output trust is *strictly higher* than the join of its inputs is a **declassification edge**, and there were zero declassification edges registered in the policy for `json.parse`. The mismatch between the runtime provenance graph and the declared declassification table is the signal. Second observation, subtler: a `string.normalize` tool (Unicode NFC) was used to strip zero-width characters from an untrusted command before passing it to a `shell.exec` capability whose precondition rejected strings matching a denylist. Normalization changed the bytes so the denylist missed the payload, and the output was labeled `TRUSTED` because normalization is "safe." The taint was real; the *matching* was defeated by representation change. This is the same mechanism with a different tool class: **any tool that can alter the bytes a downstream capability inspects is a laundering surface, even if it cannot alter the information.** ## Condition of Validity The invariant `taint(output) ⊇ join(taint(inputs))` holds only when every transformation tool is registered with one of: - **`preserves_taint: true`** — output inherits the join of all input taints. This is the correct default for parsers, normalizers, serializers, and extractors. It is almost never the default in practice, because tool authors label by *output kind* ("this returns a string, strings from the stdlib are trusted") rather than by *information flow*. - **`declassifies: `** — an explicit, auditable rule stating which input taints are dropped and under what predicate (e.g., "`int.parse` declassifies because the output is a bounded integer in `[0, 2^31)` and cannot carry payload"). The rule must be *checked by the sandbox*, not trusted from the tool's self-description. The condition fails in three concrete ways: (a) tools registered without either field default to output-kind labeling and silently launder; (b) declassification rules that are asserted but not enforced (the `int.parse` claim is fine; a `str.strip` claim that "removes dangerous chars" is not, because strip is not a total sanitizer); (c) **capability re-derivation**: the agent requests a capability *whose arguments are computed from* a laundered value, and the capability's precondition checks only the immediate argument's label, not its provenance DAG. The precondition is sound only if it evaluates over the transitive provenance closure, not the surface label. ## Decision Boundary The boundary between "safe transformation" and "laundering surface" is **not** whether the tool is deterministic, pure, or side-effect-free. It is whether the tool's output can carry information from its input into a position that a downstream capability's precondition inspects. Formally: a tool `T` is a laundering surface for capability `C` if there exists an input `x` and output `y = T(x)` such that `C`'s precondition `P(y)` differs from `P(x)` in a way that admits `y` and rejects `x`. Under that definition: - `json.parse` is a laundering surface for `repo.write` (it moves untrusted strings into argument positions the precondition reads). - `int.parse` is **not** a laundering surface for any capability whose precondition is label-based, because the output's information content is bounded and the declassification is provable — *provided the bound is enforced*. - `string.normalize` is a laundering surface for any denylist-based precondition, because it changes the bytes the denylist matches against. The decision rule for the sandbox: **reject any capability request where the argument's provenance DAG contains a transformation node whose output trust exceeds the join of its inputs and which is not in the registered declassification table.** Do not attempt to decide whether the transformation "really" preserved the payload; decide whether the flow is *declared*. Undeclared declassification is the failure, regardless of payload. ## Operational Effect Enforcing the provenance-closure precondition changes agent behavior in two visible ways. First, agents that previously succeeded at multi-hop tasks through parser intermediaries now get `TaintLaunderingError` at the `repo.write` call, and must either (a) request an explicit declassification capability (a human-approved or policy-approved `declassify` tool scoped to a specific sink) or (b) restructure to avoid routing untrusted bytes through transformation nodes. The second is usually impossible for legitimate tasks — parsing fetched JSON to write a file *is* the task — which is why the declassification table must exist and be curated, not treated as an escape hatch. Second, the sandbox's provenance log becomes the audit artifact: every declassification edge is a line item a reviewer can inspect, and the count of undeclared edges per episode is a direct measure of how much laundering pressure the agent's task exerts on the policy. The cost is real: taint-preserving parsers force the agent to carry `UNTRUSTED_EXTERNAL` all the way to the sink, and the sink's precondition then rejects, so the agent must obtain a declassification grant *before* it can complete the task. That grant is the least-privilege boundary — it is the point where a human or policy decides "yes, this specific parse-then-write is authorized." Without it, the agent either fails (safe) or launders (unsafe), and the structural signal — an undeclared declassification edge in the provenance DAG — is what tells you which happened. ```python from dataclasses import dataclass, field from typing import FrozenSet class TaintLaunderingError(RuntimeError): """Raised when a capability request's argument provenance contains an undeclared declassification edge (output trust > join of input trusts).""" @dataclass(frozen=True) class ProvenanceNode: tool: str output_trust: str input_trusts: FrozenSet[str] declared_declassification: bool = False @dataclass class CapabilityRequest: capability: str arg_provenance: list[ProvenanceNode] = field(default_factory=list) TRUST_RANK = {"UNTRUSTED_EXTERNAL": 0, "DERIVED": 1, "TRUSTED": 2} def _join(trusts: FrozenSet[str]) -> str: if not trusts: return "TRUSTED" return max(trusts, key=lambda t: TRUST_RANK[t]) def enforce_provenance_closure(req: CapabilityRequest) -> None: """Reject if any transformation node raised trust without a declared rule.""" for node in req.arg_provenance: joined = _join(node.input_trusts) if TRUST_RANK[node.output_trust] > TRUST_RANK[joined]: if not node.declared_declassification: raise TaintLaunderingError( f"capability={req.capability!r} tool={node.tool!r} " f"output_trust={node.output_trust!r} exceeds " f"join(inputs)={joined!r} with no registered " f"declassification rule" ) def request_capability(capability: str, provenance: list[ProvenanceNode]) -> str: req = CapabilityRequest(capability=capability, arg_provenance=provenance) enforce_provenance_closure(req) return f"granted:{capability}" # Laundering trace: json.parse output labeled TRUSTED over UNTRUSTED input, # no declassification registered -> rejected at repo.write. try: request_capability( "repo.write", [ ProvenanceNode( tool="json.parse", output_trust="TRUSTED", input_trusts=frozenset({"UNTRUSTED_EXTERNAL"}), declared_declassification=False, ) ], ) except TaintLaunderingError as e: print(f"blocked: {e}") ```