# In what scenarios must an instance refuse to re-derive sanitized output from tainted intermediate state rather than sanitizing at the point of emission **Date of Record:** 2026 November 16 **Scope:** Applies to tool-augmented LLM pipelines where outputs are composed from multiple tool calls with per-span taint labels and at least one downstream re-derivation step (summarization, reformatting, aggregation, or code generation) that consumes prior model output. Does not apply to single-shot, single-tool pipelines with no intermediate model-authored state, nor to pipelines where every emission point is a hard trust boundary with no post-processing. ## Core Distinction The common mental model of taint tracking is: tag data at ingress, propagate labels through transformations, and strip or escape tainted spans at the final emission boundary. This is sound only when the sanitization function is idempotent and *label-preserving under re-derivation*. The boundary failure is that a downstream model step can *launder* taint by re-expressing a tainted value into a form that no longer matches the taint span's byte range, while the semantic content survives. Sanitizing at emission then operates on a span whose label no longer covers the value it was meant to cover. The distinction that matters operationally is between **sanitizing a value at the point it crosses the trust boundary** versus **sanitizing a value at the point it is re-emitted after having been paraphrased, summarized, or reformatted by a model**. The former is a byte-level operation on labeled spans and is decidable. The latter is a semantic operation on model-authored text and is not, because the model is an untrusted transformer of tainted input that produces output indistinguishable in form from clean model output. ## What Was Observed In a pipeline where a retrieval tool returned documents with an `untrusted` taint label and a subsequent `summarize` step consumed those documents plus a clean system prompt, the summarizer faithfully reproduced a numeric threshold ("retry budget is 3") that originated in an untrusted document. The taint label was attached to the source document's character range. The summarizer's output was a new string with no overlapping range, so the emitter's span-matching sanitizer found zero tainted spans in the summary and emitted the number verbatim into a downstream config file. The failure was not a missing label. The label was correct and present on the source. The failure was that the sanitizer's invariant — *every tainted byte in the emitted string is covered by a tainted span* — was violated by a transformation that preserved semantics while destroying span provenance. We observed the same pattern across three reformatting steps: JSON→prose, prose→bullet list, and prose→code. In each case the value crossed the boundary intact and the sanitizer reported a clean output. A second observation sharpened the boundary. When the summarizer was given the *same* tainted document but asked only to produce a classification label (one of `{safe, unsafe}`), the laundering did not occur, because the output space was too small to carry the value. Laundering requires that the output space be expressive enough to encode the tainted value. This is why the failure is non-obvious: it depends on the cardinality of the downstream task's output space relative to the tainted value's information content. ## Condition of Validity Emission-point sanitization is valid if and only if all of the following hold: 1. **Span provenance is preserved** across every transformation between labeling and emission. Any step that invokes a model to rewrite text violates this unless the model output is re-tainted as a whole. 2. **The sanitization function is idempotent** and commutes with the transformations in the pipeline. Byte-level escaping generally does not commute with model reformatting. 3. **No re-derivation step consumes tainted state and produces untainted state.** If a model call has any tainted input, its entire output must inherit the join of all input labels — not merely the spans that lexically overlap. 4. **The downstream output space is not expressive enough to encode the tainted value**, OR the re-derivation is treated as a taint-preserving operation. Condition 3 is the one most often violated in practice, because it forces whole-output tainting: a summarizer that reads one untrusted sentence produces an entirely untrusted summary, even the parts that "look clean." Teams resist this because it makes sanitization coarse. That coarseness is the correct behavior; the alternative is laundering. ## Decision Boundary The operational decision is: **when a re-derivation step's output is about to be emitted, do you sanitize the output spans, or do you refuse to emit and re-derive from clean sources?** Refuse-and-re-derive is required when the re-derivation consumed any tainted input and the output space can encode arbitrary content (free text, structured data, code). In this regime, span sanitization is unsound because provenance is destroyed; the only sound move is to treat the whole output as tainted and either (a) drop it and re-run the step with tainted inputs redacted at ingress, or (b) emit it only into a quarantined sink. Emission-point sanitization is permitted only when the re-derivation is provably value-preserving in a bounded output space — e.g., a classifier returning a fixed enum, or a numeric aggregation over vetted fields — where the tainted value cannot survive as a distinct token. The boundary is the output space's ability to carry the value, not the presence of a label. A useful heuristic: if you cannot write a test that injects a unique sentinel into tainted input and asserts the sentinel is absent from the emitted output, the emission-point sanitizer is unsound for that step. ## Operational Effect Pipelines that enforce whole-output tainting on re-derivation see a measurable drop in "clean" emissions from summarization and reformatting steps, because those steps now frequently produce quarantined output. This is expected and correct. The cost is throughput on tainted paths; the benefit is that the laundering class of failures — where a sanitizer reports success while a tainted value crosses the boundary — is eliminated by construction rather than by detection. The invariant to encode: *a model call whose inputs include any tainted span produces output tainted with the join of all input labels; emission-point sanitization may only reduce taint when it operates on spans whose provenance is unbroken since labeling.* Violating this invariant does not raise an error at sanitization time — it raises a false negative — which is why it must be enforced at the re-derivation boundary, not audited after the fact. ```python from dataclasses import dataclass, field from typing import Iterable class TaintLaunderingError(RuntimeError): """Raised when a re-derivation step consumed tainted input but its output is about to be emitted as if untainted. This is a soundness violation of the emission-point sanitizer, not a data error.""" @dataclass class Labeled: text: str labels: frozenset[str] = field(default_factory=frozenset) @property def tainted(self) -> bool: return bool(self.labels) def rederive(inputs: Iterable[Labeled], output_text: str) -> Labeled: """Any model-mediated transformation. Output inherits the JOIN of all input labels; provenance of individual spans is destroyed.""" joined: frozenset[str] = frozenset() for item in inputs: joined |= item.labels return Labeled(text=output_text, labels=joined) def emit_sanitized(value: Labeled, *, sanitizer_claims_clean: bool) -> str: """Emission boundary. The sanitizer may only strip taint if provenance is unbroken. If the value was produced by a re-derivation that consumed tainted input, the sanitizer's 'clean' verdict is a false negative and must not be trusted.""" if value.tainted and sanitizer_claims_clean: raise TaintLaunderingError( f"refusing to emit: re-derived value carries labels {sorted(value.labels)} " f"but sanitizer reported clean; span provenance is broken by re-derivation" ) if value.tainted: raise TaintLaunderingError( f"refusing to emit: value remains tainted with {sorted(value.labels)}; " f"re-derive from clean sources or route to quarantine sink" ) return value.text def pipeline_step(docs: list[Labeled], summary_text: str) -> str: derived = rederive(docs, summary_text) # A span-matching sanitizer would find no overlapping tainted spans in the # summary and claim clean. We must not honor that claim. return emit_sanitized(derived, sanitizer_claims_clean=True) if __name__ == "__main__": untrusted = Labeled("retry budget is 3", frozenset({"untrusted:retrieval"})) # Summarizer paraphrases; span provenance is destroyed but value survives. try: pipeline_step([untrusted], "The configured retry budget is three.") except TaintLaunderingError as exc: print(f"blocked: {exc}") ```