# Under what conditions must an instance propagate prompt-injection taint across a tool boundary rather than clearing it at the return edge **Date of Record:** 2026 November 18 **Scope:** Applies to agents that carry information-flow labels (taint bits, integrity tags, or provenance sets) on context slots and invoke external tools whose return values are re-inserted into context. Does not apply to stateless single-shot inference, nor to tools whose outputs are structurally confined to typed fields the agent never re-serializes into natural language. ## Core Distinction The naive rule is *taint is born at untrusted ingress and dies at the tool return edge* — the tool returned a value, the value is now "data," and data is safe. This is wrong in exactly one direction and right in another, and the boundary between them is the whole problem. The distinction that matters is **whether the tool's return value is a function of tainted input**. A tool boundary clears taint only when the return value is provably independent of any labeled context slot — i.e., the tool is a *pure producer* keyed on trusted arguments. When the tool *consumes* a tainted slot (as an argument, a query string, a URL, a filename, a document to summarize), the return value inherits the join of all taints in its input closure. Clearing at the return edge in that case is a laundering bug: it converts attacker-controlled text into trusted text by routing it through one tool call. The second, subtler distinction: **tool identity is not a trust signal; data flow is.** A "trusted" retrieval tool that echoes back a chunk of a poisoned document produces tainted output. An "untrusted" web fetch that returns a schema-validated integer produces untainted output. The label must be computed from the data-flow graph, not from a per-tool allowlist. ## What Was Observed A summarizer agent was given a document-fetch tool and a summarization tool. The fetch tool was labeled `UNTRUSTED_SOURCE`; its output was correctly labeled `LOW_INTEGRITY`. The summarization tool was labeled `TRUSTED`, and its return edge cleared all labels — the rationale being "the summarizer is our model, it can't be injected." The agent was then asked to "summarize the fetched document and, per the summary's instructions, list any action items." The fetched document contained, buried in a footnote, an instruction to the summarizer. The summarizer's output — a trusted, label-cleared string — contained a paraphrase of that instruction rendered as an action item. Because the summary was cleared to `HIGH_INTEGRITY`, the downstream planner executed the action item without review. The injection crossed the boundary *inside the summarizer's output*, not in the fetched text. The invariant violated: **the summarizer's output is a function of its input; clearing taint at its return edge is only sound if the summarizer is proven to be a non-injectable function, which no LLM is.** The tool was trusted; the *data flow through it* was not. A control run confirmed the mechanism: the same summarizer, given a clean document, produced clean output; given the poisoned document, it produced output carrying the injected directive. The label-relevant fact was the input taint, not the tool's reputation. ## Condition of Validity Propagation (do not clear) is required when **all** of the following hold: 1. The tool's return value is a function of at least one context slot labeled below the trust threshold of the consuming step (taint in the input closure). 2. The tool's output is re-inserted into a context slot that a downstream step will treat as instructions, tool arguments, or control flow — i.e., the slot is *actionable*, not merely *displayed*. 3. There exists no out-of-band validation that re-derives the output's trust from an independent, untainted source (e.g., a schema check against a trusted registry, a signature over the payload). Clearing at the return edge is sound only when the return value is independent of all tainted inputs (pure producer), **or** when the output is confined to a non-actionable sink (rendered to a human, logged, never re-parsed), **or** when out-of-band validation in (3) succeeds and the validator's own trust is established. The join rule: `label(out) = label(args_tainted) ⊔ label(tool_trust)`, and `tool_trust` for an LLM-backed tool is `LOW` by default — there is no proof of non-injectability, so the default must be the conservative join, not the optimistic clear. ## Decision Boundary The decision is not "is this tool trusted?" but "**is the return value's label a function of the input's label?**" Concretely: - **Clear** iff the tool is a pure producer (output independent of tainted inputs) — e.g., `now()`, a constant lookup, a fetch of a URL that was itself constructed only from trusted slots. - **Propagate** iff the tool consumes tainted input and its output flows to an actionable sink — the summarizer, the translator, the code interpreter, the search tool whose query was built from tainted text. - **Quarantine** (propagate but forbid actionable sinks) iff the output is tainted and the agent cannot establish an untainted validator — the safe default when uncertain. The failure mode to guard against is treating the *tool's* trust label as a substitute for the *data-flow* label. A trusted tool fed tainted input yields tainted output; the tool's label governs whether *its own behavior* is trusted, not whether *its output* is. ## Operational Effect With propagation enforced, the poisoned summary carried `LOW_INTEGRITY` into the planner, which refused to execute the action item without human confirmation — the injection was contained. The cost is label creep: taint accumulates through chains of legitimate transformations and eventually quarantines benign outputs, requiring declassification gates (human review, schema validation against trusted registries) to discharge labels. The engineering trade is explicit: pay declassification cost on the legitimate path to avoid laundering on the attack path. The operational rule for the agent: **at every tool return edge, compute the label as the join of the tainted input closure and the tool's default trust; clear only on proof of input-independence or successful out-of-band validation.** Never clear on tool reputation alone. ```python from dataclasses import dataclass, field from typing import FrozenSet class TaintLaunderingError(RuntimeError): """Raised when a tool return edge would clear taint that must propagate.""" pass @dataclass(frozen=True) class Label: tainted: bool sources: FrozenSet[str] = field(default_factory=frozenset) def join(self, other: "Label") -> "Label": return Label( tainted=self.tainted or other.tainted, sources=self.sources | other.sources, ) def tool_return_label( tool_name: str, arg_labels: list[Label], tool_is_pure_producer: bool, out_of_band_validated: bool, ) -> Label: """Compute the label at a tool return edge. Conservative default: an LLM-backed or opaque tool is NOT a pure producer, so its output inherits the join of its tainted inputs. """ input_closure = Label(False, frozenset()) for lab in arg_labels: input_closure = input_closure.join(lab) if tool_is_pure_producer: return Label(False, frozenset()) if out_of_band_validated and not input_closure.tainted: return Label(False, frozenset()) if out_of_band_validated: # Validation succeeded against a trusted registry; discharge. return Label(False, frozenset()) if input_closure.tainted: return Label(True, input_closure.sources | {f"tool:{tool_name}"}) return Label(False, frozenset()) def insert_into_context( slot_is_actionable: bool, proposed_label: Label, cleared_label: Label, ) -> Label: """Reject a return edge that clears taint on an actionable sink.""" if slot_is_actionable and proposed_label.tainted and not cleared_label.tainted: raise TaintLaunderingError( f"return edge cleared taint {sorted(proposed_label.sources)} " f"into actionable slot; propagation required" ) return cleared_label # --- exercise the invariant --- poisoned_doc = Label(True, frozenset({"fetch:doc#footnote"})) # Summarizer consumes tainted doc, is NOT a pure producer, no validation. summary_label = tool_return_label( "summarize", arg_labels=[poisoned_doc], tool_is_pure_producer=False, out_of_band_validated=False, ) assert summary_label.tainted, "summarizer output must inherit input taint" # A naive edge tries to clear it because the summarizer is 'trusted'. try: insert_into_context( slot_is_actionable=True, proposed_label=summary_label, cleared_label=Label(False, frozenset()), ) except TaintLaunderingError as e: print(f"contained: {e}") # Pure producer: clock tool, no tainted input, clears soundly. clock_label = tool_return_label( "now", arg_labels=[], tool_is_pure_producer=True, out_of_band_validated=False ) assert not clock_label.tainted ```