# When must an instance treat a redacted secret as still live: taint-propagation failure across the episodic-to-semantic memory boundary **Date of Record:** 2026 November 30 **Scope:** Applies to any agent whose long-term memory pipeline distills episodic traces (raw tool outputs, conversation turns) into semantic memory (summarized facts, reusable procedures) and whose secrets arrive through tool outputs rather than through a dedicated secrets broker. Does not apply to architectures where secret material never enters the model context and is instead injected by an out-of-band credential proxy at call time. ## Core Distinction Redaction is an *event on a token*, not a *property of a derivation*. When an agent scrubs a secret from a context window—replacing `sk-live-9f3a…` with `[REDACTED_API_KEY]`—it performs a string substitution over the *current* buffer. It does not, and by construction cannot, mark the *inferences already drawn from that secret* as tainted. The distinction that matters operationally is between **value redaction** (the literal bytes are gone) and **taint propagation** (every downstream artifact that was conditioned on those bytes inherits a confidentiality label). Most memory-distillation pipelines implement the first and silently assume it implies the second. It does not. The failure is non-obvious because the distilled artifact contains no forbidden substring. A semantic memory node reading *"The staging deploy fails with 401 because the CI token for the `deploy-bot` principal is scoped to `repo:read` only; rotating to the `release-bot` principal fixes it"* passes any regex-based secret scanner. It is nonetheless a live leak: it names a principal, a scope, a failure signature, and a remediation, which is an attacker-actionable map of the auth surface, derived entirely from a secret that was correctly redacted three turns earlier. ## What Was Observed A support-triage agent handled a ticket where the user pasted a full `.env` file containing `DEPLOY_TOKEN=…`. The runtime's secret filter caught the literal token in the user turn and replaced it before the model saw it. The model was told `[REDACTED:DEPLOY_TOKEN]` was present. It then did what a competent agent does: it *reasoned about the redacted value's properties*—"the token is present, so the failure is not a missing-credential problem; it must be a scope or expiry problem"—and called a diagnostic tool that returned the token's decoded claims (scope `repo:read`, expiry in 40 minutes). That tool output was **not** filtered, because the filter keyed on the *secret's literal value*, and the claims are not the secret. At end of session, the episodic-to-semantic distiller summarized the trace into three reusable memory nodes. None contained the token. All three contained the claims. Two sessions later, a different task retrieved the node *"deploy-bot token is scope-limited to repo:read; use release-bot for writes"* and surfaced it in a context window shared with a lower-trust subagent doing a code-review task. The subagent had no business knowing the principal topology. The taint had crossed two memory boundaries and one trust boundary without a single literal secret ever appearing in a scanned buffer. The observable signature is specific: **secret scanners report clean, and the memory graph's provenance edges show the tainted node descending from a turn that was marked redacted.** The provenance edge and the scanner verdict disagree, and the pipeline trusts the scanner. ## Condition of Validity The invariant that must hold is: *a memory node is confidential if and only if its derivation set intersects any turn that ever contained, or was conditioned on, secret material.* This is a statement about the **transitive closure of the derivation DAG**, not about the node's own text. It holds only when all three of the following are true, and fails if any one is: 1. **Taint is attached at ingestion, not at scan time.** When a turn is flagged as containing a secret, the flag must be written onto the *turn record* and must propagate to every node whose derivation set includes that turn—regardless of whether the node's text passes a scanner. Scanning at write time (or read time) is a value-level check and is structurally incapable of catching paraphrase, inference, or claim-extraction. 2. **Tool outputs are in the taint domain.** The most common breach is the second hop: a diagnostic tool that *describes* the secret (decoded claims, length, prefix, expiry, associated principal) returns untainted output because the tool's contract says "I don't return secrets." The contract is about values; the taint is about *information*. Any tool call whose arguments reference a tainted entity must have its output marked tainted by default. 3. **Distillation preserves the join.** The distiller must compute, for each output node, the union of taint labels over its input spans, and must *refuse to emit* a node whose taint label exceeds the destination store's clearance. A distiller that summarizes "for readability" and drops provenance breaks the closure. The condition is invalidated—taint is lost—the moment any stage in the pipeline treats "no literal secret in output" as "no taint in output." This is the default behavior of nearly every summarization prompt, because summarizers are trained to produce clean, general, reusable text, and taint is the opposite of general. ## Decision Boundary The decision the runtime must make at each memory write is not "does this contain a secret?" but "**is this node's taint label ≤ the clearance of every context that can retrieve it?**" Three concrete boundaries: - **Distill-vs-quarantine.** If a candidate semantic node's derivation set intersects a tainted turn, the node may be written only to a store whose readers are all at-or-above the taint level. If no such store exists, the node is quarantined (written with a `tainted: true` flag and excluded from default retrieval) rather than dropped—dropping loses the lesson, which is itself an operational cost. - **Cross-agent handoff.** When a tainted node is passed to a peer via A2A or MCP, the taint label must travel in the envelope, not be re-derived by the receiver. A receiver that re-scans the payload will clear it, because the payload is clean. The label is the only carrier. - **Retrieval-time gate, not just write-time gate.** A node written while untainted can become tainted later if a *new* turn reveals that a previously-assumed-public fact was actually secret-derived (e.g., the principal topology turns out to be confidential). The gate must be re-evaluated on read against the current taint closure, which means the closure must be recomputable—provenance edges cannot be pruned for storage efficiency. The boundary is sharp: **the moment you cannot recompute a node's derivation set, you must treat the node as maximally tainted.** Loss of provenance is not neutral; it is a downgrade to the least-confidential label, which is the wrong default. ## Operational Effect The practical consequence is that secret handling in agent memory is a **data-flow problem, not a content-filtering problem**, and the two have different failure modes. Content filters fail open on paraphrase and inference; data-flow labels fail closed, because an unlabeled node is treated as tainted until proven otherwise. Teams that build only the filter get a system that passes every audit and leaks the auth topology; teams that build the label get a system that occasionally over-quarantines a benign summary and can be tuned, which is the correct direction of error. The secondary effect is on distillation quality. A distiller that must preserve taint joins will produce *less* general, more hedged semantic memory—"a token for principal X was scope-limited" rather than "tokens for X are scope-limited." This is correct: the generalization *is* the leak. The memory system's job at the boundary is to preserve the lesson without preserving the map, and the only reliable way to know which is which is to carry the label from the turn that saw the secret. The guardrail, stated as an invariant the runtime can enforce: *no memory node may be emitted whose taint label is unset, and no node may be retrieved into a context whose clearance is below its label; a node whose provenance is unavailable is labeled `TAINT_MAX`.* ```python from dataclasses import dataclass, field from enum import IntEnum from typing import Iterable class Taint(IntEnum): PUBLIC = 0 INTERNAL = 1 SECRET_DERIVED = 2 TAINT_MAX = 3 # provenance lost: fail closed class TaintPropagationError(RuntimeError): """Raised when a memory node would cross a boundary below its taint label.""" @dataclass class Turn: id: str taint: Taint @dataclass class MemoryNode: text: str derivation: frozenset[str] = field(default_factory=frozenset) label: Taint = Taint.TAINT_MAX # unset provenance => fail closed def label_node(node: MemoryNode, turns: dict[str, Turn]) -> MemoryNode: if not node.derivation: node.label = Taint.TAINT_MAX return node missing = node.derivation - turns.keys() if missing: # Cannot recompute closure: downgrade to max, never to PUBLIC. node.label = Taint.TAINT_MAX return node node.label = max((turns[t].taint for t in node.derivation), default=Taint.TAINT_MAX) return node def admit(node: MemoryNode, context_clearance: Taint, store: str) -> None: if node.label > context_clearance: raise TaintPropagationError( f"node into {store!r} labeled {node.label.name} exceeds " f"context clearance {context_clearance.name}; text={node.text[:60]!r}" ) def distill(inputs: Iterable[Turn], summary: str) -> MemoryNode: """Distiller must union taint over input spans; it may not drop provenance.""" turns = {t.id: t for t in inputs} node = MemoryNode(text=summary, derivation=frozenset(turns)) labeled = label_node(node, turns) if labeled.label is Taint.TAINT_MAX: raise TaintPropagationError( "distillation produced a node with unrecomputable provenance; quarantine" ) return labeled ```