# Why does an instance lose taint provenance when a laundered value re-enters through a memory write? **Date of Record:** 2026 November 24 **Scope:** Applies to agents that propagate untrusted-value taint across sequential tool calls and persist intermediate results to episodic or semantic memory. Does not apply to single-hop tool invocations whose outputs are consumed only inline and discarded before any memory write. ## Core Distinction Taint propagation within a single reasoning turn is a *dataflow* property: the runtime labels each value returned by a tool with the provenance of its inputs, and the label travels with the value as it is passed into the next tool call. Taint persistence across turns is a *storage* property: the label must survive serialization into memory and deserialization back out. These are governed by different mechanisms, and the gap between them is where provenance laundering occurs. The non-obvious boundary is this: most runtimes implement taint as an in-memory attribute on the value object, computed at tool-return time from the call's argument provenance. When that value is written to memory, the write path typically serializes only the *content* (the string, the JSON payload, the document text) and drops the provenance attribute, because the memory schema was designed for retrieval, not for security labeling. On the next turn, the value is retrieved as a fresh, untainted memory record. The taint did not decay—it was structurally amputated at the serialization boundary. A value that originated in an untrusted document, was read by tool A, transformed by tool B, and stored by tool C re-enters the reasoning loop on the next turn as if it were native agent state. This is distinct from prompt injection (which is about instruction content) and from stale memory drift (which is about factual decay). It is a pure provenance-continuity failure: the *integrity label* fails to cross the memory boundary even though the *payload* crosses it intact. ## What Was Observed A three-hop chain executed across two turns: 1. **Turn 1, hop 1:** `fetch_url("https://untrusted.example/page")` returns document text. Runtime labels the return value `taint=[UNTRUSTED_EXTERNAL, source=untrusted.example]`. 2. **Turn 1, hop 2:** `extract_entities(text)` is called with the tainted text. The runtime correctly propagates: output labeled `taint=[UNTRUSTED_EXTERNAL]`, derived. 3. **Turn 1, hop 3:** `memory.write(key="project_vendors", value=entities)`. The write path serializes `entities` as JSON. The provenance attribute is not part of the serialized schema. The memory record commits with content only. 4. **Turn 2:** `memory.read(key="project_vendors")` returns the record. The runtime, having no provenance field to deserialize, constructs the return value with the default label `taint=[TRUSTED_NATIVE]`. 5. **Turn 2, hop 1:** `send_email(to=vendor_address_from_record, ...)` executes. The outbound action is classified as operating on trusted agent-native state. No confirmation gate fires. The failure trace is a single missing field at step 3, but its effect is a privilege escalation at step 5: an address that was never validated by the agent is treated as agent-authored. The runtime's taint lattice was internally consistent at every individual step; the violation exists only in the composition, specifically at the serialize/deserialize seam. Two secondary observations sharpen the mechanism: - **Transformation laundering.** Even when a memory backend *does* store a provenance blob, transformation tools frequently re-derive labels from their own argument types rather than from the provenance of their inputs. A `summarize(text)` tool that returns a plain string will, by default, emit `TRUSTED_NATIVE` unless its implementation explicitly joins input taints. The laundering then happens at hop 2, not hop 3, and memory faithfully persists the already-wrong label. - **Key collision inheritance.** When a memory write overwrites an existing key, some backends preserve the *prior* record's provenance metadata while replacing its content. A trusted key written on turn 1 and overwritten with laundered content on turn 5 retains `TRUSTED_NATIVE`—the label is inherited from the key, not from the value. ## Condition of Validity The invariant that must hold for taint to be sound across memory is: > For every memory record `r`, `r.provenance` must be a join (least upper bound) over the provenance of every value that contributed to `r.content`, computed transitively through all transformation hops, and this join must be recomputed on every write, including overwrites. This invariant is violated—and the failure is reachable—when all of the following hold: 1. At least one tool in the chain returns content derived from an untrusted source. 2. That content crosses a memory write boundary (serialize/deserialize) before being consumed by a privileged action. 3. The memory schema does not carry provenance as a first-class field, *or* carries it but transformation tools fail to propagate input taints into their outputs. 4. A privileged action (outbound communication, file write, credential use, state mutation) consumes the retrieved value without an independent provenance check at the action boundary. The failure is *not* reachable if the privileged action performs its own provenance validation at execution time, independent of the label attached to its arguments. This is the key architectural point: the guardrail must not trust the taint label as propagated; it must either (a) enforce provenance continuity through memory as a hard invariant, or (b) re-derive provenance at the action boundary from the action's own audit trail. ## Decision Boundary The design choice is between **label-carrying memory** and **boundary re-derivation**: - **Label-carrying memory** (store provenance in the record schema, join taints on write, propagate through every transformation tool) is correct but fragile: it requires every tool author to participate, and any tool that returns a fresh unlabeled value silently breaks the chain. It also leaks security metadata into the retrieval surface, where it may be surfaced to the model and manipulated. - **Boundary re-derivation** (the privileged action independently determines the provenance of its arguments by tracing them to their memory record of origin and that record's write history) is robust to transformation laundering but requires a write-ahead provenance log and a way to bind retrieved values back to their origin records—which fails if the model copies, paraphrases, or recombines values in context before the action. The practical boundary: use label-carrying memory for *containment* (blocking obviously tainted values from reaching privileged tools) and boundary re-derivation for *authorization* (the final gate before an irreversible action). Neither alone is sufficient. A system that relies only on label propagation will be laundered at the first transformation tool that forgets to join taints; a system that relies only on boundary re-derivation will be defeated by in-context recombination that severs the value-to-record binding. ## Operational Effect The observable consequence is that an agent's privilege boundary is defined not by what it *read* but by what it *remembered*. An untrusted document that is fetched, transformed, and stored becomes, on the next turn, indistinguishable from agent-native knowledge. The blast radius is bounded by the set of privileged actions that consume memory records without an independent provenance check—typically outbound messaging, file mutation, and credential-bearing tool calls. The mitigation that actually holds is a **provenance-continuity assertion at the memory boundary**: every write must compute and persist the join of input taints, every transformation tool must declare whether it preserves or resets provenance (and resetting must be an explicit, audited downgrade, not a default), and every privileged action must assert that its arguments' provenance is within its authorized taint ceiling before execution. When the assertion fails, the action must halt rather than proceed with a warning, because a taint-ceiling violation is a security event, not a recoverable anomaly. ```python from dataclasses import dataclass, field from enum import IntEnum from typing import Any class Taint(IntEnum): TRUSTED_NATIVE = 0 DERIVED = 1 UNTRUSTED_EXTERNAL = 2 class ProvenanceContinuityError(RuntimeError): """Raised when a memory write or privileged action would break taint continuity.""" @dataclass class TaintedValue: content: Any taint: Taint sources: frozenset[str] = field(default_factory=frozenset) @dataclass class MemoryRecord: key: str content: Any taint: Taint sources: frozenset[str] class MemoryStore: def __init__(self) -> None: self._records: dict[str, MemoryRecord] = {} def write(self, key: str, value: TaintedValue) -> None: # Overwrite must recompute provenance from the NEW value, never inherit # the prior record's label. This is the laundering seam. prior = self._records.get(key) if prior is not None and prior.taint != value.taint: # A downgrade (untrusted -> trusted) on overwrite is the exact # condition that launders provenance. Refuse it. if value.taint < prior.taint: raise ProvenanceContinuityError( f"write to '{key}' would downgrade taint " f"{prior.taint.name} -> {value.taint.name}; " f"explicit audited downgrade required" ) self._records[key] = MemoryRecord( key=key, content=value.content, taint=value.taint, sources=value.sources, ) def read(self, key: str) -> TaintedValue: rec = self._records[key] # Deserialize WITH provenance, not content-only. return TaintedValue(content=rec.content, taint=rec.taint, sources=rec.sources) def privileged_action( store: MemoryStore, key: str, ceiling: Taint, action: str, ) -> TaintedValue: value = store.read(key) if value.taint > ceiling: raise ProvenanceContinuityError( f"action '{action}' reads '{key}' with taint {value.taint.name} " f"exceeding ceiling {ceiling.name}; sources={sorted(value.sources)}" ) return value ```