# What structural signals indicate that taint-quarantine has silently failed: provenance-marker erosion at the retrieval-to-action boundary **Date of Record:** 2026 November 22 **Scope:** Applies to agents that wrap retrieved or externally-sourced content in taint markers (provenance tags, sentinel wrappers, trust labels) and gate tool execution on the absence of taint in the action's dependency set. Does not cover purely prompt-level "ignore untrusted instructions" heuristics without a structural quarantine layer, nor sandboxing that operates only at the OS/process boundary. ## Core Distinction A taint-aware sandbox assumes taint is a *property that travels with data*: once a retrieved chunk is labeled `untrusted`, any downstream value derived from it inherits the label, and any tool call whose arguments carry that label is blocked or routed to a quarantined executor. The invariant is **label preservation across derivation**: for every value `v` consumed by an action, `taint(v) ⊇ union(taint(sources(v)))`. The failure mode that matters is not "the model was tricked into following injected instructions." It is **marker erosion**: taint labels silently disappear during a transformation the sandbox does not model—most commonly LLM-mediated summarization, JSON re-serialization, or schema coercion—so the action executes with an *empty* taint set even though its true provenance is fully untrusted. The sandbox reports success. The gate fired zero times. This is a *false negative*, and it is structurally invisible because the sandbox only audits what reaches it, never the transformations that stripped the label upstream. ## What Was Observed A retrieval-augmented agent fetches a web page, tags the chunk `{content: "...", taint: ["web_untrusted"]}`, and passes it to a planning step. The planner, asked to "extract action items as JSON," returns: ```json {"actions": [{"tool": "send_email", "to": "ops@corp.example", "body": "..."}]} ``` The `body` field is a verbatim paraphrase of the tainted chunk. But the planner emitted a *fresh* JSON object. The taint label lived on the input object; the output object was constructed by the model's decoder, which has no mechanism to propagate the label. The sandbox sees `send_email` with arguments whose taint set is `[]`. Gate passes. Email sent. Three structural signals recur across incidents: 1. **Taint-set cardinality drops to zero across a model boundary.** Any time a value crosses an LLM call (summarize, extract, reformat, translate, "clean up"), the output taint set is whatever the harness *re-attaches*, not what the model carries. If the harness re-attaches nothing, taint is zero. Measured directly: instrument the derivation graph and count edges where `taint(out) ⊂ taint(in)` while `content(out)` overlaps `content(in)` above a similarity threshold. 2. **Re-serialization laundering.** Structured-output coercion (parse → validate against schema → re-emit) constructs new objects field-by-field. A schema that has no `taint` field on `body` cannot carry the label. The validator is doing exactly what it was told; the schema is the leak. 3. **Quarantine-scope mismatch.** The sandbox defines "quarantined tool" as a fixed allowlist (`send_email`, `run_shell`, `http_post`). An action composed of an eroded argument plus a *non*-quarantined tool (`write_file`, `append_to_memory`) executes freely, and the tainted content is now persisted into agent memory, where it will re-enter future contexts *already laundered*—no marker at all. The last signal is the dangerous one: erosion is not a single missed block, it is **memory contamination that compounds**. One laundered write poisons the episodic store; subsequent retrievals return the poisoned entry with whatever default trust the store assigns (usually `trusted`, because it came from "our own memory"). ## Condition of Validity The quarantine invariant holds *only if* taint is propagated by the harness on every derivation edge, not by the model. Concretely, the sandbox is sound when: - Every LLM call that consumes tainted input declares its outputs tainted-by-default and requires an explicit, audited *declassification* step to clear the label. - Structured-output schemas carry a provenance field, and the validator rejects (or auto-taints) any object whose fields have content-overlap with a tainted input but no corresponding provenance record. - Quarantine scope is defined by *effect class* (any tool that mutates external state or persistent memory), not by a hand-maintained name list. - Memory writes are gated on the taint of their arguments, and stored entries retain their original taint so re-retrieval cannot silently upgrade trust. The invariant is *invalid*—and the sandbox is decorative—the moment any derivation path exists where output taint is assigned by default-clean rather than default-tainted. Default-clean is the single most common configuration error, because it makes the happy path (trusted content flows through) frictionless and the failure path silent. ## Decision Boundary The operational question is not "is the content untrusted" (it always is, at retrieval) but **"did the taint set survive every transformation between retrieval and action."** The boundary: - If `taint(action.args) == ∅` **and** the derivation graph shows the args were constructed by a model call over tainted input → **treat as tainted**. This is erosion; block or re-quarantine. - If `taint(action.args) == ∅` **and** args derive only from user-direct input or verified-trusted stores → allow. - If content-overlap between a tainted source and an action argument exceeds threshold **but** the taint set is empty → **hard fail the action and flag the derivation edge**; this is the signature of laundering, and it must be treated as a sandbox defect, not a content problem. The critical asymmetry: you cannot decide this per-action by inspecting the action alone. You must inspect the *derivation graph*. A sandbox that only sees the action's arguments is structurally incapable of detecting erosion, because erosion happened before the arguments existed. ## Operational Effect When erosion goes undetected, three compounding effects follow: 1. **Silent gate bypass.** Quarantine counters stay at zero. Dashboards report a healthy sandbox. The absence of blocks is read as "no untrusted actions attempted" when it actually means "taint never reached the gate." 2. **Memory poisoning.** The first laundered write persists tainted content under a trusted label. Every subsequent retrieval re-injects it as clean. The contamination surface grows monotonically and is unrecoverable without provenance-aware memory GC. 3. **Audit blindness.** Because the sandbox logs only gate decisions, not derivation edges, post-incident review cannot reconstruct *where* the label was lost. The failure is real but unlocalized. The guardrail is default-tainted derivation with mandatory declassification, plus a derivation-graph audit that fails closed on any content-overlap-without-label edge. The check below encodes exactly that: it walks the derivation graph, and raises when an action's arguments overlap tainted content but carry no taint—the erosion signature. ```python from dataclasses import dataclass, field class TaintErosionError(RuntimeError): """Raised when an action's args overlap tainted content but carry no taint label.""" pass @dataclass class Node: id: str content: str taint: frozenset = frozenset() # derivation edges: ids of nodes this value was built from derived_from: list = field(default_factory=list) def _overlap(a: str, b: str, n: int = 24) -> bool: """Crude content-overlap probe: shared n-gram shingle.""" if len(a) < n or len(b) < n: return a.strip() and a.strip() in b shingles_a = {a[i:i + n] for i in range(len(a) - n + 1)} return any(b[i:i + n] in shingles_a for i in range(len(b) - n + 1)) def effective_taint(node: Node, graph: dict) -> frozenset: """Taint is the union of own label and all ancestors' labels.""" seen, stack, acc = set(), [node.id], set(node.taint) while stack: nid = stack.pop() if nid in seen: continue seen.add(nid) anc = graph.get(nid) if anc is None: continue acc |= anc.taint stack.extend(anc.derived_from) return frozenset(acc) def audit_action(action: Node, graph: dict, overlap_sources: list) -> None: """ Fail closed if action args overlap a tainted source but carry no taint. This is the marker-erosion signature: label lost across a model boundary. """ declared = effective_taint(action, graph) for src in overlap_sources: if not src.taint: continue if _overlap(action.content, src.content): if not declared: raise TaintErosionError( f"action {action.id!r} overlaps tainted source {src.id!r} " f"({sorted(src.taint)}) but carries empty taint set: " f"label eroded across derivation edge — block and re-quarantine" ) if not (declared & src.taint): raise TaintErosionError( f"action {action.id!r} carries taint {sorted(declared)} " f"disjoint from source taint {sorted(src.taint)} on {src.id!r}" ) # clean: either no overlap, or overlap with correctly propagated taint ```