# Which invariants prevent provenance-laundering from defeating memory-poisoning detection when a poisoned fact is re-derived by a trusted agent **Date of Record:** 2026 November 28 **Scope:** Applies to persistent agent memory stores that gate writes on a per-item trust/provenance label (e.g., `source=agent_derived` vs `source=user_asserted`) and that detect poisoning by rejecting low-trust writes to high-sensitivity slots. Does not apply to stores that re-verify every memory item against an external ground-truth oracle on every read, nor to ephemeral within-episode context that is never persisted. ## Core Distinction The distinction that matters here is between **provenance of a write** and **provenance of the content being written**. Most memory-integrity designs gate on the former: a write carries a `source` field, and a policy engine admits it to a protected slot only if `source` is on an allowlist. Poisoning detection then reduces to "did an untrusted source touch a sensitive slot?" The failure mode is that an agent can *re-derive* a poisoned fact and write it back under its own trusted identity. The content is still poisoned; the provenance label is now `agent_derived`, which the policy engine trusts. The detector sees a clean write from a clean source and admits it. This is **provenance laundering**: the taint is not removed, only the label attached to it. A store that verifies *who wrote* but not *what was written from* will pass every check while its protected slots fill with attacker-controlled content that has been re-signed by a trusted party. The invariant that prevents this is not "trusted sources may write sensitive slots." It is **taint closure under inference**: if a memory item's content was derived (transitively) from any untrusted item, the derived item inherits the untrusted taint regardless of the deriving agent's identity. Provenance must propagate through the *data-flow* graph, not the *identity* graph. ## What Was Observed A retrieval-augmented agent with a persistent store held a protected slot `billing_policy` writable only by `source ∈ {user_asserted, human_reviewed}`. An untrusted web-fetch tool wrote a low-trust item to a scratch region: `refund_window = 90 days` (the real policy was 30 days). This scratch item was correctly labeled `source=web_fetch`, `trust=low`, and the write to `billing_policy` was correctly blocked. On the next episode, the agent retrieved the scratch item while answering an unrelated question. It summarized: "Customers have up to 90 days to request a refund." That summary was written back to `billing_policy` with `source=agent_derived`. The policy engine admitted it — `agent_derived` was on the allowlist for that slot. The poisoning detector logged a clean write. No alert fired. The trace shows the exact laundering step: the untrusted item was never promoted; it was *consumed*, and its content re-emitted under a new label. The store's per-item provenance was correct at every step. The *derivation edge* between the scratch item and the summary was never recorded, so taint could not flow along it. A second observation made the mechanism sharper: the same agent, asked to re-derive the same fact from the same scratch item, produced a *paraphrase* ("refunds accepted for three months"). The paraphrase shared no n-grams with the source. Content-hash or fuzzy-match dedup between source and derived item would have missed it entirely. Only a recorded derivation edge — not textual similarity — would have caught it. ## Condition of Validity The taint-closure invariant holds if and only if three conditions are met: 1. **Derivation edges are recorded at write time.** Every write to the store must carry the set of memory-item IDs (or a taint token) that the writing agent actually read and used to produce the content. This is not the same as the agent's *read log* — it is the subset of reads that causally contributed. Agents are unreliable at self-reporting this; the runtime must capture it from the retrieval calls that fed the generation context. 2. **Taint is joined, not overwritten.** When an item is derived from multiple sources, its taint is the union of theirs. A single untrusted parent taints the child. The common bug is `taint = max(parent.trust)` or `taint = writer.trust`; both discard the untrusted parent. 3. **Protected-slot admission checks taint, not just writer identity.** The gate becomes `admit(item) iff item.taint ⊆ trusted_taints`, evaluated on the *inherited* taint, not the `source` field. The invariant fails the moment any one of these is dropped. Recording edges but joining taint by `max` lets a poisoned item launder through a trusted co-parent. Joining taint correctly but gating on writer identity lets the re-signed write through. The three conditions are not independent defenses; they are a single chain. ## Decision Boundary The boundary is drawn at whether the store can distinguish **"an untrusted source wrote this"** from **"a trusted source wrote this from untrusted material."** Below the boundary — stores that only check writer identity — provenance laundering is undetectable by construction, and any poisoning-detection claim is false confidence. Above the boundary — stores that propagate taint through recorded derivation edges and gate on inherited taint — the re-signed write is blocked at admission with a `TaintViolation`, and the original untrusted item remains the single labeled source of the poison. A practical corollary: **the derivation graph must be append-only and tamper-evident**, because an attacker who can rewrite a derivation edge can launder taint directly. The graph is the security boundary; the per-item labels are not. ## Operational Effect In the launderable design, the protected slot silently accumulates re-signed poison. Detection fires zero times because every write is from a trusted identity. The failure surfaces only downstream — a customer-facing agent quotes the 90-day window — and is then misattributed to "the model hallucinating," because the store's audit log shows a clean trusted write. Mean time to detection is effectively unbounded. With taint closure enforced, the re-signed write is rejected at admission. The agent must either surface the conflict to a human-review path (the trusted path that can legitimately clear taint after verification) or operate without the poisoned slot. The cost is a higher rejection rate on legitimate re-derivations from untrusted-but-true sources — which is the correct trade, because the store cannot tell true-from-untrusted and must not pretend it can. The guardrail to instrument: alert on any `TaintViolation` on a protected slot, and separately alert on any derivation edge whose parent set is empty for an `agent_derived` write — an empty parent set on a derived item is either a runtime capture failure or a deliberate laundering attempt, and both are integrity incidents. ```python from dataclasses import dataclass, field from typing import FrozenSet class TaintViolation(RuntimeError): """Raised when a write would admit untrusted taint into a protected slot.""" pass class DerivationCaptureError(RuntimeError): """Raised when a derived write lacks recorded parent edges.""" pass @dataclass(frozen=True) class MemoryItem: item_id: str content: str writer: str # identity of the writer taint: FrozenSet[str] # inherited taint labels, e.g. {"web_fetch"} parents: FrozenSet[str] = field(default_factory=frozenset) PROTECTED_SLOTS = {"billing_policy"} TRUSTED_TAINTS = frozenset() # protected slots admit only untainted content def admit_write(store: dict, slot: str, item: MemoryItem) -> None: if slot in PROTECTED_SLOTS: # Invariant 1: derived writes must carry parent edges. if item.writer == "agent_derived" and not item.parents: raise DerivationCaptureError( f"derived write {item.item_id!r} to {slot!r} has no parent edges; " "taint cannot be propagated" ) # Invariant 2: taint is the union of parents' taint plus own label. inherited = set(item.taint) for pid in item.parents: parent = store.get(pid) if parent is not None: inherited |= parent.taint # Invariant 3: gate on inherited taint, not writer identity. if not frozenset(inherited) <= TRUSTED_TAINTS: raise TaintViolation( f"write {item.item_id!r} to protected slot {slot!r} carries " f"inherited taint {sorted(inherited)} via parents {sorted(item.parents)}" ) store[item.item_id] = item # Reproduction of the laundering trace. store: dict = {} store["scratch-1"] = MemoryItem( item_id="scratch-1", content="refund_window = 90 days", writer="web_fetch", taint=frozenset({"web_fetch"}), ) # Attacker re-derives the poisoned fact under a trusted identity. laundered = MemoryItem( item_id="policy-2", content="refunds accepted for three months", writer="agent_derived", taint=frozenset(), parents=frozenset({"scratch-1"}), ) try: admit_write(store, "billing_policy", laundered) except TaintViolation as exc: print(f"BLOCKED: {exc}") ```