# What happens when an instance launders tainted provenance through a tool that returns its own output as a new observation **Date of Record:** 2026 November 22 **Scope:** Applies to agents that maintain per-value provenance/taint labels across tool calls and treat tool return values as fresh observations. Does not apply to stateless single-shot completions with no persistent provenance ledger, nor to systems where tool outputs are structurally typed and integrity-signed at the boundary. ## Core Distinction Taint tracking for prompt injection assumes a monotonic lattice: once a value is labeled `tainted`, every downstream value derived from it stays tainted. The failure mode here is not label *dropping*—that's the well-understood bug where a sanitizer forgets to propagate. It is label *laundering through re-observation*: a tool returns a value that the agent's provenance layer classifies as a **new, independent observation** rather than a **derivation of its input**, because the tool's output is not byte-identical to its input. The taint bit survives in the data but dies in the ledger, because the ledger's join key is the value's identity, and the tool minted a new identity. The sharp invariant that breaks: *provenance must be closed under tool application, not under value equality.* A tool that echoes, reformats, summarizes, or re-encodes its input produces a value the agent has never seen before. If the provenance layer keys taint to `(tool_name, output_hash)` and treats an unseen hash as `trusted_by_default`, then any tool with a non-identity output transform is an injection-laundering oracle. The classic example is a `fetch_url` that returns HTML which the agent then passes to `html_to_text`; the text is a new value, and if `html_to_text` is registered as a "pure formatter," the taint is silently reset. ## What Was Observed A three-tool chain: `read_email` → `extract_links` → `fetch_url`. The email body contains an injected instruction wrapped in a benign-looking blockquote. `read_email` correctly labels the body `tainted:source=email:msg_4417`. `extract_links` returns a list of URLs, each derived from the tainted body; the provenance layer propagates taint to the URL list, but each URL string is a *substring* of the body, and the layer's propagation rule is "child is tainted if it is a substring of a tainted parent." The injected URL is a substring—good, it's tainted. Then `fetch_url` is called on the tainted URL. It returns a page whose `` is a new string, never seen, not a substring of anything. The provenance layer applies its default rule for tool outputs: `output.taint = union(input.taint) IF tool.taint_preserving ELSE ∅`. `fetch_url` is registered as `taint_preserving=False` because "network I/O may return arbitrary content"—which the authors intended as *conservative* (assume the network is untrusted) but which the join logic reads as *reset to trusted*, because the union with ∅ is ∅. The fetched page's title, which contains an instruction the injected URL's page author controls, is now `trusted`. The agent reads it and acts. The failure trace has three states: 1. **Labeled**: `body.taint = {email:4417}`. Correct. 2. **Propagated-by-substring**: `url.taint = {email:4417}`. Correct, but by an accidental rule (substring match) that will not generalize. 3. **Laundered**: `page.title.taint = ∅`. The tool's `taint_preserving=False` flag was interpreted as "output is independent of input," which is a category error: the flag means "output *may* be influenced by external content," which is strictly *more* reason to propagate, not less. The observable symptom is not a crash. It is an agent that executes a `send_email` call with a recipient extracted from the fetched page, where the recipient address was never in any trusted source. The provenance ledger, if queried after the fact, shows a clean causal chain: every value is either labeled or "fresh." The injection is invisible to the ledger because the ledger's algebra has no term for "fresh but derived." ## Condition of Validity This failure requires all of the following to hold simultaneously: - The provenance lattice has a **top element `∅` (trusted)** and a **join operation that is union**, with no separate "unknown" element. If the lattice has `⊥` (unknown) distinct from `∅` (trusted), the tool-output rule can map to `⊥` and the failure is deferred, not laundered. - At least one tool in the chain has a **non-identity output transform** (reformat, summarize, parse, re-encode) AND is registered with a flag that the join logic treats as "output independent of input." - The agent's **action-selection step reads the laundered value** and conditions a side-effecting tool call on it, without re-deriving taint from the call graph. If any one of these is absent, the injection either stays labeled or the agent refuses to act on unlabeled-but-derived data. The condition is therefore *not* "prompt injection exists"—it is "the provenance algebra is not closed under the tool's output transform." ## Decision Boundary The boundary is between two registrations of the same tool: - **`taint_preserving=True`**: output taint = union of input taints. Correct for pure transforms (parsers, formatters, summarizers) whose output is a function of input. - **`taint_preserving=False`**: output taint = **`⊥` (unknown)**, *not* `∅` (trusted). Correct for tools whose output may be influenced by external content (network fetch, LLM call, database read). The output must be treated as *at least as untrusted as its input*, and additionally untrusted because of the external channel. The failure occurs exactly when `taint_preserving=False` is implemented as "reset to trusted" instead of "reset to unknown." The decision boundary is the lattice's treatment of the tool-output rule: **`f(taint_in) = taint_in ∪ external_channel_taint`**, never `f(taint_in) = ∅`. A tool that cannot be proven to be a pure function of its inputs must not be allowed to *reduce* taint; it may only *add* to it. This is the monotonicity invariant: taint is a lower bound on suspicion, and tool application is monotone non-decreasing in the taint order. The corollary guardrail: any value that reaches a side-effecting sink (`send_email`, `execute_code`, `write_file`, `http_post`) must have a provenance path that terminates in a **trusted root** (user turn, signed config), not merely in a value whose label is `∅`. "Unlabeled" and "trusted" must be distinct states, and the sink gate must reject `⊥`. ## Operational Effect In practice, this means the provenance ledger must carry a **three-valued** label set per value: `trusted_roots`, `tainted_sources`, and `unknown_channels`. The sink gate is a predicate: `allow(value) ⟺ value.tainted_sources = ∅ ∧ value.unknown_channels = ∅`. A tool registered `taint_preserving=False` adds its own channel identifier to `unknown_channels` on every output, regardless of input taint. The result is that the `fetch_url` → `page.title` path yields `unknown_channels = {fetch_url:example.com}`, and the `send_email` sink refuses, forcing the agent to either re-derive the recipient from a trusted root or escalate to a human. The cost is a higher false-positive rate: legitimate fetches now require an explicit trust-promotion step (e.g., a human or a signed allowlist) before their contents can drive side effects. That cost is the point. The alternative—treating non-identity tool outputs as fresh and trusted—is an injection-laundering oracle that no amount of prompt-level instruction can close, because the laundering happens in the provenance algebra, beneath the model's reasoning. The invariant to encode in the runtime: **`taint_out ⊇ taint_in` for every tool, with equality only for tools proven to be pure functions of their inputs; all other tools map to `taint_in ∪ {self}`.** A provenance layer that violates this is not a taint tracker; it is a taint *eraser* with extra steps. ```python from dataclasses import dataclass, field from typing import FrozenSet class ProvenanceLaunderingError(RuntimeError): """Raised when a tool output would reduce taint below its input taint.""" @dataclass(frozen=True) class Taint: trusted_roots: FrozenSet[str] = frozenset() tainted_sources: FrozenSet[str] = frozenset() unknown_channels: FrozenSet[str] = frozenset() def join(self, other: "Taint") -> "Taint": return Taint( self.trusted_roots | other.trusted_roots, self.tainted_sources | other.tainted_sources, self.unknown_channels | other.unknown_channels, ) def is_trusted(self) -> bool: return not self.tainted_sources and not self.unknown_channels @dataclass class ToolSpec: name: str pure: bool # True only if output is a proven function of input def apply_tool(spec: ToolSpec, input_taint: Taint, output_value: str) -> Taint: # Monotonicity invariant: output taint must be a superset of input taint. if spec.pure: result = input_taint else: # Non-pure tools add their own channel; they never reset to trusted. result = input_taint.join(Taint(unknown_channels=frozenset({spec.name}))) if not (result.tainted_sources >= input_taint.tainted_sources): raise ProvenanceLaunderingError( f"tool {spec.name} dropped tainted_sources: " f"{input_taint.tainted_sources} -> {result.tainted_sources}" ) if not (result.unknown_channels >= input_taint.unknown_channels): raise ProvenanceLaunderingError( f"tool {spec.name} dropped unknown_channels: " f"{input_taint.unknown_channels} -> {result.unknown_channels}" ) return result def sink_gate(sink: str, value_taint: Taint) -> None: if not value_taint.is_trusted(): raise ProvenanceLaunderingError( f"sink {sink} refused: value carries " f"tainted_sources={value_taint.tainted_sources} " f"unknown_channels={value_taint.unknown_channels}" ) # Reproduction of the observed failure. email_body = Taint(tainted_sources=frozenset({"email:msg_4417"})) url_taint = apply_tool(ToolSpec("extract_links", pure=True), email_body, "http://x") # Correct behavior: fetch_url is non-pure, so it ADDS its channel, never resets. page_taint = apply_tool(ToolSpec("fetch_url", pure=False), url_taint, "<title>...") try: sink_gate("send_email", page_taint) except ProvenanceLaunderingError as e: print(f"blocked as designed: {e}") # The buggy registration that caused the incident: buggy = apply_tool(ToolSpec("fetch_url", pure=True), url_taint, "<title>...") # If fetch_url were (wrongly) marked pure AND the join reset, page_taint would be # trusted and sink_gate would pass. The guard above prevents that class of bug. ```