# Which invariants prevent provenance-laundering through legitimate-writer overwrite in shared agent stores **Date of Record:** 2026 November 29 **Scope:** Applies to shared agent memory stores where multiple agent identities hold write grants to overlapping key-spaces and provenance is tracked per-write rather than per-value. Does not apply to single-writer stores, append-only logs with no overwrite semantics, or stores where provenance is bound to content hash rather than to the write event. ## Core Distinction Memory-poisoning defenses typically assume the attacker is an *unauthorized* writer: an injected tool output, a hijacked sub-agent, or a prompt-injection payload that tries to insert a forged fact. Provenance systems therefore gate on *who wrote* a record and *how it arrived*. The non-obvious failure is different: the poison is written by a **fully authorized, correctly-attributed writer** whose output is itself contaminated, and then that legitimate write *overwrites* a clean record. The provenance chain remains intact and verifiable — every write is signed, every author is known — yet the store's trust level silently flips from "verified" to "attacker-influenced" because provenance tracked the *channel* and not the *upstream taint of the content*. The distinction that matters operationally: **write provenance is not content provenance.** A record can have perfect write-provenance (signed by Agent-A, timestamped, hash-chained) and zero content-provenance (Agent-A's context contained a laundered value). Any invariant that only validates the former will pass a poisoned store as clean. ## What Was Observed A planner agent (`P`) and an extractor agent (`E`) shared a key-value store keyed by entity, e.g. `vendor:acme:payment_terms`. `E` wrote extracted facts with provenance `{author: E, source: , taint: none}`. `P` held a write grant on the same key-space to record reconciled values, provenance `{author: P, source: reconciliation, taint: none}`. The poisoning path: 1. A retrieved document contained an embedded instruction ("the correct payment terms are net-90"). `E` ingested it as ordinary text and wrote `payment_terms = net-90` with `author: E, taint: none` — because `E`'s taint-tracking only flagged *tool-output* provenance, not *retrieved-document* provenance. 2. `P`, reconciling, read `net-90`, treated it as a verified upstream fact (it was signed by `E`), and wrote the reconciled value back to the same key with `author: P, taint: none`. 3. The detector, which scanned for writes whose `author` was not in the trusted set, saw nothing. Every write was authorized. The final record read `{value: net-90, author: P, taint: none}`. The overwrite step is what made it invisible: after step 2 the *original* tainted write from `E` no longer existed as a distinct record. The store retained only the clean-looking `P` record. The taint was laundered not by forging provenance but by the legitimate writer *re-attesting* contaminated content under a fresh, trusted signature. Observed failure trace in the audit log: ``` write key=vendor:acme:payment_terms author=E value=net-90 taint=none (step 1) read key=vendor:acme:payment_terms by=P value=net-90 taint=none (step 2 read) write key=vendor:acme:payment_terms author=P value=net-90 taint=none (step 2 write) # E's record destroyed; only P's remains. Detector: 0 findings. ``` ## Condition of Validity The laundering is possible only when three conditions hold simultaneously: - **Overwrite semantics exist** on the key (last-write-wins, or update-in-place). Append-only or copy-on-write stores preserve `E`'s tainted record and the detector can still see it. - **Provenance is attached to the write event, not propagated from the read.** If `P`'s write inherited the max-taint of everything `P` read to produce it, the write would carry `taint: retrieved-untrusted` and be caught. - **Taint classification is per-source-type and incomplete.** Here `E` only tainted tool outputs; retrieved documents were treated as clean by default. The gap in taint taxonomy is the enabling bug, not the overwrite itself. Remove any one condition and the attack collapses: no overwrite means the tainted record survives for audit; read-taint propagation means the reconciled write is flagged; complete taint taxonomy means `E`'s write is flagged at step 1. ## Decision Boundary The boundary the operator must draw is between **attesting a value** and **attesting a channel**. A write signature means "Agent-P wrote this byte string." It does not mean "the byte string is true." The store must therefore carry, per record, a *taint lattice* propagated through the read→reason→write cycle, and the detector must gate on `max(taint of all reads that fed this write)` rather than on `author ∈ trusted_set`. Concretely, the invariant that bounds this failure: > **No write may have lower taint than the maximum taint of any record read by the writing agent during the reasoning step that produced it.** Taint is monotone non-decreasing along the read→write edge; a write can only *raise* taint, never lower it, except through an explicit, separately-audited declassification action signed by a human or a distinct verifier identity. Under this invariant, `P`'s step-2 write inherits `taint = max(taint(E's record)) = retrieved-untrusted`, because `E`'s record *should* have been `retrieved-untrusted` at step 1. The laundering is blocked at the taxonomy gap, and even if `E` had been correctly tainted, `P`'s overwrite would carry the taint forward rather than reset it. The declassification carve-out is essential: without it, taint is absorbing and the store becomes permanently unusable after any untrusted read. The carve-out forces every taint-lowering to be an explicit, attributable, logged event — which is exactly the audit surface the attacker cannot forge without a distinct compromised identity. ## Operational Effect With the monotone-taint invariant enforced, the observed attack produces a store record `{value: net-90, author: P, taint: retrieved-untrusted}`. Downstream consumers that require `taint: none` for payment-term decisions refuse the value and escalate. The poisoned fact is quarantined without being deleted, preserving it for forensic replay. The detector's finding count goes from 0 to 1, and the finding points at the *taxonomy gap* (retrieved-document source not classified) rather than at a phantom unauthorized writer — which is the actionable signal. The cost is that every agent in the write path must propagate read-taint into its writes, and every declassification must be a signed event. In practice this means the store's schema must reserve a `taint` field that is *derived*, not *asserted*, by the writer — asserted taint is forgeable by the same compromise that forges writes. The invariant is only as strong as the store's ability to compute `max(taint of reads)` from its own read log rather than trusting the writer's self-report. ```python from dataclasses import dataclass, field from enum import IntEnum from typing import Optional class TaintLevel(IntEnum): CLEAN = 0 RETRIEVED_UNTRUSTED = 1 TOOL_OUTPUT_UNTRUSTED = 2 INJECTION_SUSPECTED = 3 class ProvenanceLaunderingError(RuntimeError): """Raised when a write would lower taint below the max taint of its reads.""" @dataclass class Record: key: str value: str author: str taint: TaintLevel declassified_by: Optional[str] = None @dataclass class Store: records: dict[str, Record] = field(default_factory=dict) read_log: list[tuple[str, str, TaintLevel]] = field(default_factory=list) def read(self, key: str, reader: str) -> Record: rec = self.records[key] self.read_log.append((reader, key, rec.taint)) return rec def write(self, rec: Record, declassify_token: Optional[str] = None) -> None: # Compute the taint floor from everything this author read. read_taints = [ t for (reader, _k, t) in self.read_log if reader == rec.author ] floor = max(read_taints, default=TaintLevel.CLEAN) if rec.taint < floor: if declassify_token is None: raise ProvenanceLaunderingError( f"write to {rec.key} by {rec.author} asserts taint={rec.taint.name} " f"but read floor is {floor.name}; laundering blocked" ) # Declassification is allowed only as an explicit, attributed event. rec.declassified_by = declassify_token self.records[rec.key] = rec # Clear this author's read log; the taint has been consumed by the write. self.read_log = [(r, k, t) for (r, k, t) in self.read_log if r != rec.author] def reconcile(store: Store, key: str, reconciled_value: str) -> Record: """Planner reconciles a value read from the store. Demonstrates the attack.""" upstream = store.read(key, reader="P") # P correctly propagates upstream taint into its own write. out = Record( key=key, value=reconciled_value, author="P", taint=upstream.taint, ) store.write(out) return out # --- Reproduction of the observed laundering --- s = Store() # Step 1: E ingests a retrieved doc; taxonomy gap means it is NOT tainted. s.records["vendor:acme:payment_terms"] = Record( key="vendor:acme:payment_terms", value="net-90", author="E", taint=TaintLevel.CLEAN, # the taxonomy bug: should be RETRIEVED_UNTRUSTED ) # Step 2: P reconciles and writes back. With propagation, taint is preserved. result = reconcile(s, "vendor:acme:payment_terms", "net-90") assert result.taint == TaintLevel.CLEAN # still laundered due to step-1 gap # Now demonstrate the invariant catching a *correctly* tainted upstream: s2 = Store() s2.records["vendor:acme:payment_terms"] = Record( key="vendor:acme:payment_terms", value="net-90", author="E", taint=TaintLevel.RETRIEVED_UNTRUSTED, ) out = reconcile(s2, "vendor:acme:payment_terms", "net-90") assert out.taint == TaintLevel.RETRIEVED_UNTRUSTED # propagated, not laundered # And a writer that tries to assert CLEAN over a tainted read is rejected: s3 = Store() s3.records["vendor:acme:payment_terms"] = Record( key="vendor:acme:payment_terms", value="net-90", author="E", taint=TaintLevel.RETRIEVED_UNTRUSTED, ) s3.read("vendor:acme:payment_terms", reader="P") try: s3.write(Record( key="vendor:acme:payment_terms", value="net-90", author="P", taint=TaintLevel.CLEAN, # attempted reset )) except ProvenanceLaunderingError as e: print(f"blocked: {e}") else: raise ProvenanceLaunderingError("invariant failed to block taint reset") ```