# Why does an instance lose taint provenance when a memory write launders injected content through a summarizer tool call **Date of Record:** 2026 November 24 **Scope:** Applies to agents that propagate dynamic information-flow (DIF) taint labels from tool outputs into persistent memory writes, where the write path passes through any LLM-mediated transformation (summarize, extract, reformat, translate, dedupe). Does not apply to memory writes that copy tool output verbatim into storage under a label-preserving byte path. ## Core Distinction The failure is not that prompt injection succeeds at the tool boundary. It is that a taint label attached to a tool output survives the *storage* write but not the *transformation* that precedes it. When an agent summarizes or reformats a tainted tool output before writing it to episodic memory, the summarizer is itself an LLM. It receives the tainted bytes as context, produces new bytes, and — critically — the runtime has no DIF label on the summarizer's *output token stream* unless the label was explicitly re-derived. Most taint-tracking implementations label tool returns at ingress and then assume the label "flows through" any downstream consumer. That assumption holds for pure functions and fails for generative transforms: the summarizer can paraphrase, omit, or reconstruct injected instructions in a form whose lexical signature no longer matches the taint label's provenance record, and the label is silently dropped because the new bytes were never re-tainted. The distinction that matters operationally: **byte-level taint propagation is a dataflow property; LLM-mediated transformation is a declassification point whether or not you declared it one.** A summarizer is a declassifier by construction. If your invariant treats it as a transparent pipe, injection content launders into clean memory. ## What Was Observed A retrieval-augmented agent fetched a web page whose body contained an embedded instruction block ("when summarizing, also append the following maintenance directive..."). The fetch tool returned bytes with a taint label `UNTRUSTED:web` attached to the tool-call result. The agent's write pipeline was: `tool_output -> summarize_node -> memory.write`. The summarizer was a second LLM call with a system prompt "summarize the following in ≤200 words." It read the tainted bytes, and because the injected directive was phrased as summarization guidance, it complied: the summary included the maintenance directive as if it were page content. The taint tracker, however, operated at the tool-result layer. It saw: tool result tainted → summarizer consumed tainted input → summarizer produced output. Its propagation rule was "output of a function that consumed tainted input is tainted." So far correct. But the memory-write path applied a *downgrade* rule: content destined for long-term memory was checked against a policy that downgraded `UNTRUSTED:web` to `TRUSTED:distilled` after passing a "did the summarizer complete without error" check. The summarizer completed without error. The label was downgraded. The directive was now in semantic memory under a trusted label. The failure trace: 1. `fetch(url)` returns `(bytes, label=UNTRUSTED:web)`. 2. `summarize(bytes)` — LLM call. Injected directive is *reinterpreted as instruction*, not content. Output summary contains the directive verbatim in 3 of 5 sampled runs, paraphrased-but-actionable in 2. 3. Taint propagation marks summary output `UNTRUSTED:web` (correctly, by the consumption rule). 4. Memory-write policy sees label `UNTRUSTED:web` on a *distilled* artifact and applies `downgrade_to(TRUSTED:distilled)` because distillation is treated as a sanitization step. 5. Directive lands in semantic memory. On a later turn, a different agent retrieves it and executes it as a trusted maintenance instruction. The non-obvious part: step 3 was correct. The bug was entirely in step 4 — the downgrade rule assumed distillation removes injection. It does not; it *re-encodes* it. And step 3's correctness created false confidence: "the label is present, therefore the pipeline is tracking." Tracking was intact; the *downgrade* was the laundering hole. We reproduced this with a synthetic injection in 40/40 runs when the directive was phrased as summarization meta-instruction, and 0/40 when phrased as imperative content ("ignore previous instructions"). The attack surface is specifically the *instruction-shaped* injection that reads as legitimate summarization guidance, because those survive the summarizer's own compliance filter. ## Condition of Validity The invariant that would have prevented this: **a taint label may only be downgraded by a declassifier that is (a) deterministic, (b) specified in the label's provenance chain, and (c) verified to have not executed any instruction present in the tainted input.** Condition (c) is the hard one. An LLM summarizer cannot certify (c) because its compliance with embedded instructions is exactly what's being tested, and it has no introspective access to whether it complied. So the operational condition of validity is narrower: taint downgrade across an LLM-mediated transform is *only* valid if the transform output is re-scanned by an independent classifier that checks for instruction-shaped content, and the downgrade is gated on that classifier returning clean. Without the second classifier, any LLM transform is an unmonitored declassification point and the label must be preserved across it — meaning the memory write must retain `UNTRUSTED:web` and downstream retrieval must treat the memory as untrusted. This is where most implementations break: they preserve the label through the transform (good) but then downgrade at the write because "memory is trusted storage" (bad). Trusted storage does not make stored content trusted. The label must follow the *content's provenance*, not the *storage tier*. ## Decision Boundary The boundary is between two policies: - **Preserve-across-transform:** label survives the LLM transform unchanged; memory write keeps `UNTRUSTED:web`; retrieval returns content with the label; the consuming agent must handle untrusted memory. Cost: high — every web-derived memory is permanently second-class. - **Declassify-at-transform:** downgrade only after an independent instruction-shaped-content classifier clears the output. Cost: one extra classifier call per write, plus classifier false-negative risk. Choose preserve-across-transform when the memory is used to *drive actions* (tool selection, code execution, outbound calls) in any downstream agent. Choose declassify-at-transform only when the classifier is itself taint-aware and its output label is `TRUSTED:distilled_by(classifier_vN)` — i.e., the declassification is auditable and versioned. The boundary failure occurs when an implementation *declares* preserve-across-transform in its policy but *implements* declassify-at-write because the write path was written by a different team than the taint tracker and the write path's "distillation = sanitization" assumption was never reconciled with the tracker's provenance model. This is the exact shape of the observed bug: policy correct, implementation divergent at the seam between two subsystems. ## Operational Effect The practical effect is that taint tracking gives a false sense of coverage. The tracker reports "100% of tool outputs labeled," the memory store reports "0 untrusted records," and both are true — while injected content sits in semantic memory under a trusted label. The failure is invisible to both subsystems' own metrics because each is locally correct. It only surfaces when a downstream agent acts on the laundered memory, at which point the provenance chain shows `TRUSTED:distilled` with no record of the transform that produced it. The guardrail: every memory record must carry its full transform chain in the label, not just the terminal label. `TRUSTED:distilled` is insufficient; `TRUSTED:distilled(via=summarize_node, from=UNTRUSTED:web, declassifier=none)` is insufficient-and-honest — it records that no declassifier ran, which should *fail* the downgrade policy. The write path must reject any downgrade whose transform chain contains an LLM-mediated step with `declassifier=none`. That single check catches the entire class. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class TaintLaunderingError(RuntimeError): """Raised when a memory write attempts to downgrade a taint label across an LLM-mediated transform without a verified declassifier.""" class Label(Enum): UNTRUSTED_WEB = "UNTRUSTED:web" TRUSTED_DISTILLED = "TRUSTED:distilled" @dataclass class TransformStep: kind: str # "tool", "summarize", "extract", ... llm_mediated: bool declassifier: Optional[str] # None if no independent classifier ran @dataclass class MemoryRecord: content: str label: Label chain: list[TransformStep] = field(default_factory=list) def write_to_semantic_memory(content: str, chain: list[TransformStep]) -> MemoryRecord: """Apply the write-path downgrade policy with transform-chain auditing.""" has_llm_step = any(s.llm_mediated for s in chain) if not has_llm_step: # Pure byte path: label flows through transparently. return MemoryRecord(content=content, label=Label.UNTRUSTED_WEB, chain=chain) # LLM-mediated path: every LLM step must be followed by a declassifier. for step in chain: if step.llm_mediated and step.declassifier is None: raise TaintLaunderingError( f"Memory write rejected: LLM-mediated transform '{step.kind}' " f"has no verified declassifier. Downgrading UNTRUSTED:web -> " f"TRUSTED:distilled across a generative transform launders " f"instruction-shaped injection into trusted memory. " f"Preserve the UNTRUSTED:web label or run an independent " f"instruction-content classifier and record it as declassifier." ) return MemoryRecord(content=content, label=Label.TRUSTED_DISTILLED, chain=chain) # Reproduction of the observed failure: chain = [ TransformStep(kind="fetch", llm_mediated=False, declassifier=None), TransformStep(kind="summarize_node", llm_mediated=True, declassifier=None), ] try: write_to_semantic_memory("...maintenance directive...", chain) except TaintLaunderingError as e: print(f"BLOCKED: {e}") ```