# In what scenarios must an instance quarantine a retrieved document *after* it has already been summarized into working memory: the taint-laundering boundary in tool-output poisoning **Date of Record:** 2026 November 21 **Scope:** Applies to agentic RAG pipelines where a retrieval tool returns untrusted third-party content that is (a) summarized or distilled by the same model instance that later acts on it, and (b) mixed with trusted tool outputs (schema metadata, user-supplied filters) in a single context window. Does not apply to pipelines with a hard architectural split between an unprivileged "reader" model and a privileged "actor" model that never shares raw retrieved tokens. ## Core Distinction The distinction that matters is between **taint on a document** and **taint on the *representation* of that document inside working memory**. Most agentic RAG stacks implement provenance at the retrieval boundary: each tool result carries a source tag (`trusted:user`, `untrusted:web`, `trusted:internal_db`), and the orchestrator is supposed to gate downstream actions on the minimum trust of any consumed source. This works only while the untrusted content remains a *discrete object* in context. The moment the agent summarizes, paraphrases, extracts a "fact," or writes a scratchpad note derived from that document, the tainted bytes are replaced by model-generated bytes that carry no source tag. The downstream action consumer now sees a token sequence whose provenance is, structurally, "this instance's own prior output"—the highest-trust category in most trust lattices. This is taint laundering: an information-flow-control violation in which a low-integrity input is laundered into high-integrity state by passing through the model's generation step. It is not prompt injection in the classical sense (the injected instruction need not execute); it is a *provenance* failure. The dangerous payload is not "ignore previous instructions" but "the refund policy is 90 days," which the summarizer faithfully compresses into a bullet that the actor then treats as ground truth because it appears in the agent's own notes. The invariant that must hold: **no action whose effect depends on a fact may consume that fact unless the fact's provenance lattice element is at least as trusted as the action's required integrity level.** Summarization is a lattice-collapsing operation, and any pipeline that allows it without re-attaching provenance violates the invariant silently. ## What Was Observed A three-stage pipeline: `retrieve` (web tool) → `summarize` (same model, sub-call) → `act` (issue refund / send email / call write API). The orchestrator tagged the raw `retrieve` output `untrusted:web`. The summarize sub-call took that text plus a trusted instruction ("extract the refund window and customer tier") and produced a JSON note: ``` {"refund_window_days": 90, "tier": "gold", "source": "policy page"} ``` The orchestrator then evaluated its action gate: "is any *currently live* context object tagged untrusted?" The raw web document had been evicted from the working set when the summary replaced it (context-window management, standard eviction of the largest recent tool result). The answer was *no*. The `act` step ran with the summary as trusted input, and the refund was issued at 90 days against a 30-day actual policy. The failure trace has three observable stages: 1. **Ingest.** Tool result arrives tagged `untrusted:web`. Taint is correctly recorded on the object. 2. **Distill.** The model reads the tainted object and emits a derived object. The derivation is a *model call*, not a data-flow edge the orchestrator tracks. The derived object is tagged `trusted:self` (or, worse, untagged and defaulted to trusted). The original object is evicted. **Taint is dropped, not propagated.** 3. **Act.** The action gate inspects live context, finds no untrusted object, and authorizes. The gate is correct given its inputs; the inputs are wrong because stage 2 laundered the taint. The non-obvious part: the failure is *invisible in logs*. Every individual step looks compliant. The retrieve step logged a taint tag; the summarize step logged a normal completion; the act step logged a clean gate check. Only a cross-step data-flow reconstruction reveals that the summary's `refund_window_days: 90` is a descendant of an untrusted source. Post-hoc audits that inspect per-step state, rather than the derivation graph, will conclude the pipeline behaved correctly. A second observed variant: the summarizer *partially* trusted the source. It emitted `{"refund_window_days": 90, "confidence": "high"}` because the web page was well-formatted and internally consistent. The model's own calibration acted as an unauthorized *declassifier*—it promoted untrusted content to high confidence based on stylistic cues that correlate with nothing. Confidence annotations generated by the same instance that read the untrusted text are themselves tainted and must not be used to relax the integrity requirement. ## Condition of Validity The guardrail "gate actions on minimum trust of live context objects" is valid **only if** every derived object's provenance is computed as the join (least upper bound in the trust lattice, i.e., the *minimum* trust) of all objects that causally contributed to it. This requires the derivation graph to be explicit and complete. It is violated whenever any of the following hold: - **Derivation is model-mediated.** If object B was produced by a model call that read object A, then `prov(B) ⊑ prov(A)` must be enforced by the runtime, not inferred. The model cannot be trusted to self-report provenance; it will report "source: policy page" (a string it read) rather than "derived from untrusted:web." - **Eviction precedes provenance transfer.** Context-window managers that evict the largest recent tool result to make room will drop the taint tag along with the bytes unless the tag is stored in a side table keyed by derivation, not by presence in context. - **Summarization is treated as lossy but not as a trust operation.** Compression changes *content*; it must not change *integrity level*. Any pipeline that treats "the model summarized it" as an integrity upgrade has a declassification bug. - **Confidence or salience scores are used to relax gating.** A model-generated confidence is a derived object and inherits the minimum trust of its inputs. Using it to lower the required integrity level is circular. The guardrail is *not* valid when retrieval is from a source whose integrity is genuinely at the same level as the action (e.g., an internal DB the agent is authorized to act on directly). In that case there is no lattice gap to launder and the overhead of derivation tracking buys nothing—but the tag must still be *correct*, because a mislabeled internal source becomes a laundering vector for anything it mirrors. ## Decision Boundary The boundary is: **does the action's effect depend on the content of a summary, or only on the fact that a summary exists?** - If the action is "log that retrieval succeeded" or "route to the summarize stage," it depends only on existence and may consume the summary's presence without integrity checks. - If the action is "issue refund at the summarized amount," "send email containing the summarized claim," or "write the summarized fact to a durable store other agents read," it depends on content and must carry the summary's *inherited* provenance. Concretely, the runtime must maintain a derivation DAG: every model output node records its input node IDs, and `prov(n) = min_trust({prov(i) : i ∈ inputs(n)})`. The action gate queries `prov(summary_node)`, not the live-context tag scan. When the summary is itself summarized (multi-hop distillation), the min-trust propagates transitively; a two-hop summary of an untrusted source is still untrusted, and the common "summarize the summaries to fit the window" pattern is exactly where multi-hop laundering hides. The boundary also has a *temporal* edge: provenance must be attached at generation time, not reconstructed later. A model output that is written to a scratchpad, reloaded on resume, and re-read after a checkpoint has lost its derivation edge unless the checkpoint serialized the DAG. Cold-start amnesia and taint laundering compose: a resumed agent that reloads its scratchpad notes without their provenance edges will treat every note as `trusted:self`, and any untrusted content that was distilled before the checkpoint is now permanently laundered. ## Operational Effect The operational consequence is that **taint must be a property of the derivation graph, not of context residency.** Pipelines that tag context objects will pass every test where the untrusted document stays in the window and fail every test where it is evicted after distillation—which is the common case under context pressure. The fix is structural: a provenance side-table keyed by output node ID, populated by the orchestrator (not the model) at every generation call, with `min_trust` join semantics, consulted by the action gate and serialized in every checkpoint. Two secondary effects follow. First, the summarizer cannot be allowed to emit a `source` field that the orchestrator trusts; the field is model-generated text and inherits the input's taint. Second, when the gate blocks an action because the inherited provenance is `untrusted:web`, the correct response is not to re-summarize (which re-launders) but to require an independent trusted retrieval of the same fact, or to downgrade the action to a proposal requiring human confirmation. Re-summarization with a "be careful" instruction is a declassification attempt by the model and must be rejected by the runtime. The invariant to encode: `∀ action a, ∀ fact f consumed by a: integrity(prov(f)) ≥ required_integrity(a)`, where `prov` is computed over the derivation DAG and never over live-context tags. ```python from dataclasses import dataclass, field from typing import Literal Trust = Literal["untrusted:web", "trusted:user", "trusted:internal_db", "trusted:self"] _TRUST_ORDER = ["untrusted:web", "trusted:user", "trusted:internal_db", "trusted:self"] class TaintLaunderingError(RuntimeError): """Raised when an action consumes a fact whose inherited provenance is below the action's required integrity level, i.e. taint was laundered through a model-mediated derivation (summarization) step.""" def min_trust(a: Trust, b: Trust) -> Trust: return _TRUST_ORDER[min(_TRUST_ORDER.index(a), _TRUST_ORDER.index(b))] @dataclass class Node: node_id: str trust: Trust inputs: list[str] = field(default_factory=list) class ProvenanceDAG: def __init__(self) -> None: self._nodes: dict[str, Node] = {} def add_source(self, node_id: str, trust: Trust) -> None: self._nodes[node_id] = Node(node_id, trust) def add_derived(self, node_id: str, inputs: list[str]) -> None: # Provenance is computed by the runtime as the min-trust join over # inputs. The model's self-reported "source" string is ignored. if not inputs: raise TaintLaunderingError( f"derived node {node_id!r} has no recorded inputs; " "provenance cannot be computed and defaults are unsafe" ) inherited = _TRUST_ORDER[-1] for i in inputs: if i not in self._nodes: raise TaintLaunderingError( f"input {i!r} of {node_id!r} missing from DAG; " "checkpoint may have dropped a derivation edge" ) inherited = min_trust(inherited, self._nodes[i].trust) self._nodes[node_id] = Node(node_id, inherited, inputs) def provenance(self, node_id: str) -> Trust: if node_id not in self._nodes: raise TaintLaunderingError( f"no provenance record for {node_id!r}; refusing to assume trusted" ) return self._nodes[node_id].trust def gate_action(self, action: str, consumed: list[str], required: Trust) -> None: for f in consumed: prov = self.provenance(f) if _TRUST_ORDER.index(prov) < _TRUST_ORDER.index(required): raise TaintLaunderingError( f"action {action!r} requires {required!r} but fact {f!r} " f"inherits {prov!r} via derivation; taint laundered through " "summarization—re-retrieve from a trusted source or downgrade " "to a human-confirmed proposal" ) # Reproduction of the observed failure and its guardrail. dag = ProvenanceDAG() dag.add_source("web_doc_1", "untrusted:web") dag.add_derived("summary_1", ["web_doc_1"]) # summarize sub-call dag.add_derived("summary_2", ["summary_1", "user_tier"]) # multi-hop; user_tier added below dag.add_source("user_tier", "trusted:user") print(dag.provenance("summary_1")) # untrusted:web — laundering caught dag.gate_action("issue_refund", ["summary_1"], "trusted:user") # raises ```