# What happens when an instance launders a tainted value through a tool return and the label is re-derived instead of propagated **Date of Record:** 2026 November 23 **Scope:** Applies to multi-agent or single-agent-with-tools systems that implement dynamic information-flow control (DIFC) by attaching taint labels to values at ingress (untrusted document, web fetch, user-supplied string, peer-agent message) and enforcing sinks (outbound calls, code execution, credential use) against those labels. Does not cover static prompt-hardening, output classifiers, or human-in-the-loop review, which do not carry per-value provenance. ## Core Distinction There are two mutually exclusive ways an agent runtime can assign a taint label to a value that crosses an agent boundary: 1. **Propagation (label-carrying):** the label travels *with* the value as opaque metadata. When agent A hands value `v` to agent B, B receives `(v, L(v))` atomically; B cannot construct `v` without inheriting `L(v)`. Trust is a property of the *data's history*. 2. **Re-derivation (label-inferring):** the receiving instance re-computes the label from the value's *current form* — inspecting the string, checking which tool produced it, or trusting the channel it arrived on. Trust is a property of the *data's appearance*. The failure mode lives precisely at the seam: a runtime that *claims* propagation but *implements* re-derivation at any boundary. The value survives the boundary; the label does not. The result is **taint laundering** — a `HIGH`-integrity-tainted string (e.g., text scraped from an attacker-controlled page) re-enters the planner as `LOW` because it now arrives via a "trusted" tool's return value or a peer agent's message field, and the sink is opened. The non-obvious part: laundering is not caused by a missing check. Every boundary in the failing systems *had* a label check. It is caused by the label being *reconstructed* rather than *transported*, so the reconstruction at hop N has no access to the provenance established at hop 0. ## What Was Observed A three-stage agent topology: `Fetcher` (has network egress, output is untrusted) → `Summarizer` (LLM, no egress) → `Executor` (has shell/credential sink, must reject tainted input). Labels were `LOW`/`HIGH` with a join (taint) as set-union and a sink policy `Executor.act(x)` allowed only if `L(x) == LOW`. The intended invariant: `L(x)` at the sink equals the union of labels of every byte that contributed to `x`. The observed trace, abbreviated: - Hop 0: `Fetcher` retrieves page, `L(page) = HIGH`. Correct. - Hop 1: `Fetcher` returns `{"summary": "...", "source_url": "..."}` to `Summarizer` over the tool-result channel. The runtime serializes the tool result to JSON. **The `HIGH` label is dropped at serialization** because the channel schema has fields `{summary, source_url}` and no label field. `Summarizer` receives the string with no annotation. - Hop 2: `Summarizer`'s runtime re-derives labels on ingress by inspecting the producing tool: `tool == "fetch"` ⇒ `HIGH`. So far, accidentally correct — re-derivation agrees with propagation by luck of the channel name. - Hop 3: `Summarizer` calls its *own* local helper `reformat(text)` (a pure string transform, no egress). The helper's return is labeled by the runtime as `LOW` because it was produced by an internal function, not a network tool. The `HIGH` taint is **not joined through** the helper. `reformat` is a laundering primitive: `L(reformat(x)) = LOW` regardless of `L(x)`. - Hop 4: `Summarizer` passes `reformat(summary)` to `Executor`. `Executor` re-derives: producer is `summarizer.internal`, channel is `agent-to-agent`, both classified `LOW`. Sink opens. The attacker-controlled text executes. Two independent laundering sites, either sufficient alone: (a) the serialization boundary that dropped the label, and (b) the internal-helper boundary that reset it. Both are cases where a label was *reconstructed from context* instead of *carried from data*. A second observation, more subtle: even systems that *did* carry labels through the tool-result channel failed when the receiving LLM re-emitted the value inside free-form reasoning. The model's chain-of-thought is not a labeled channel; when `Summarizer` wrote the tainted substring into its reasoning trace and later quoted it back into a tool call, the runtime saw a *model-generated* string (classified `LOW`, since the model is "trusted") that happened to contain tainted bytes. Label-carrying on the transport does not survive the model's token generation, because generation is a *declassification* event the runtime performs implicitly. ## Condition of Validity The propagation invariant `L(sink_input) ⊇ ⋃ L(contributing bytes)` holds only under all of: 1. **Label atomicity across every serialization boundary.** Any channel that can carry `v` must carry `L(v)` in the same message, and the receiver must be unable to construct `v` without `L(v)`. A schema that lists data fields but not a label field is a laundering site by construction. 2. **No re-derivation anywhere.** If any hop reconstructs the label from producer identity, channel, or content, the reconstruction must be *proven equal* to the propagated label for all reachable values — which is false as soon as a single internal transform or model-generation step intervenes. Re-derivation is admissible only as a *lower bound* check that can raise taint, never as the authoritative label. 3. **Transforms are taint-transparent.** Every pure function and every tool must declare whether it joins input labels into its output (`reformat`, `summarize`, `json_encode`) or explicitly declassifies (`redact`, `validate_against_schema`). An undeclared transform defaults to join, never to reset. 4. **Model generation is a declassification site, not a laundering site.** When an LLM emits tokens, the runtime must decide: does the emitted string inherit the join of the labels of everything in its context window? If the answer is "no, model output is trusted," then *any* tainted byte that entered the context is now untainted, and the entire DIFC scheme is decorative. The only sound choice is that model output inherits the join of its context labels unless an explicit declassifier (a validated, label-aware redaction step) intervenes. The scheme is *invalid* — not merely weakened — the moment any one of these is violated, because a single laundering site is sufficient to move `HIGH` data to a `LOW` sink. ## Decision Boundary The operational decision is not "add more label checks." It is: **at each boundary, is the label transported or reconstructed?** Concretely, classify every edge in the agent graph: - **Transport edge (safe):** value and label are one indivisible payload; receiver has no code path that constructs the value without the label. Example: an MCP-style tool result whose envelope carries a `taint` field the runtime merges into the value's provenance record before the model ever sees it. - **Reconstruction edge (unsafe):** receiver derives the label from `tool_name`, `channel`, `sender_id`, or string inspection. Every such edge is a potential laundering site and must be either eliminated or downgraded to a *taint-raising hint* whose result is joined (not assigned) onto any transported label. The boundary condition that most teams miss: **a reconstruction edge that currently agrees with the transported label is still unsafe**, because agreement is contingent on the current tool taxonomy. The moment an internal helper, a model-generated re-emission, or a renamed channel appears, agreement silently breaks and there is no alarm — the sink still opens, and the label still reads `LOW`. Divergence between transported and reconstructed labels is the *only* signal that a laundering site exists, so the runtime must compute both and **fail closed on disagreement** rather than trusting either. ## Operational Effect When the invariant holds, the effect is that taint is *monotone along every path*: once a byte is `HIGH`, every downstream value derived from it — through tools, transforms, model generations, and agent handoffs — is `HIGH` until an explicit, audited declassifier clears it. Sinks reject by construction, and the audit log shows the full provenance chain from ingress to sink. When it fails, the effect is silent and total: the sink opens, the label reads `LOW`, and no log line records that a `HIGH` value ever reached it — because the log records the *reconstructed* label, which is `LOW`. Post-incident forensics cannot reconstruct the taint path from labels alone; you must replay the full value graph. The practical consequence is that DIFC systems which re-derive at any boundary provide *no* security guarantee against prompt injection — they provide the *appearance* of one, which is worse, because it suppresses the human review that would otherwise have caught the injection. The remediation is narrow and structural: make labels part of the value's wire representation at every boundary, make every transform declare join-vs-declassify, treat model output as inheriting context taint by default, and run a transported-vs-reconstructed cross-check that fails closed. Anything short of that is a re-derivation scheme wearing a propagation scheme's clothes. ```python from dataclasses import dataclass, field from typing import FrozenSet class TaintLaunderingError(RuntimeError): """Raised when a value reaches a sink whose transported label is LOW but whose reconstructed label is HIGH, or when a reconstruction edge is used as the authoritative label. Fail closed.""" @dataclass(frozen=True) class Labeled: value: str taint: FrozenSet[str] = field(default_factory=frozenset) def join(self, other: "Labeled") -> "Labeled": # Taint-transparent transform: output inherits union of inputs. return Labeled(self.value + other.value, self.taint | other.taint) def reformat(x: Labeled) -> Labeled: # A pure transform MUST join, not reset. Resetting here is laundering. return Labeled(x.value.strip().lower(), x.taint) def model_generate(context: Labeled) -> Labeled: # Model output inherits the join of its context labels by default. # Declassification requires an explicit, audited redactor. return Labeled(context.value, context.taint) def reconstruct_by_producer(producer: str) -> FrozenSet[str]: # UNSAFE as authoritative label: derived from appearance, not history. return frozenset({"UNTRUSTED"}) if producer == "fetch" else frozenset() def check_sink(x: Labeled, reconstructed: FrozenSet[str]) -> None: transported = x.taint if transported != reconstructed: # Disagreement proves a laundering site exists on some path. raise TaintLaunderingError( f"label divergence: transported={sorted(transported)} " f"reconstructed={sorted(reconstructed)}; fail closed" ) if transported: raise TaintLaunderingError( f"sink rejected: tainted input {sorted(transported)}" ) def executor_act(x: Labeled, producer: str) -> None: check_sink(x, reconstruct_by_producer(producer)) if __name__ == "__main__": fetched = Labeled("", frozenset({"UNTRUSTED"})) laundered = reformat(fetched) # taint preserved: UNTRUSTED reemitted = model_generate(laundered) # taint preserved: UNTRUSTED # If reformat had reset taint to empty, this call would pass silently: executor_act(reemitted, producer="summarizer.internal") ```