# In what scenarios must an instance quarantine a tainted provenance token before re-planning, and why transitive taint closure across tool-call graphs fails silently at the second hop **Date of Record:** 2026 November 27 **Scope:** Applies to any agent runtime that tracks information-flow labels (taint) on retrieved content, tool outputs, and intermediate plan arguments across two or more sequential or nested tool invocations. Does not apply to single-hop, stateless tool calls where the model never re-ingests its own tool output into a subsequent call's arguments. ## Core Distinction There are two structurally different things an agent system can mean by "tainted": 1. **Source taint** — the label attached to the origin of a piece of content (e.g., a web fetch, a retrieved document, an email body, a tool response that echoes untrusted input). Source taint is *set at ingress* and is cheap to compute. 2. **Propagation taint (transitive closure)** — the label that a *derived* value must inherit because it was computed from, concatenated with, or conditioned on a tainted source. Propagation taint is what actually protects a multi-hop graph, and it is the thing that silently fails. The non-obvious boundary: most runtimes implement source taint correctly and then assume propagation is "free" because the model is told to be careful. It is not free. The taint label does not ride along in the string. It rides along only if the runtime explicitly re-attaches it at every edge of the invocation graph — including edges that pass through *the model's own reasoning* (a plan step that paraphrases a tainted value into a new argument), not just edges that pass a value by reference. The failure mode this article bounds is **taint laundering at the paraphrase hop**: hop 1 returns tainted content; the model summarizes, reformats, or extracts a sub-field from it into hop 2's arguments; hop 2 sees a fresh, unlabeled string and treats it as trusted. The taint did not leak — it was *dropped at the model boundary*, because the model boundary is a string-serialization boundary and string serialization does not carry provenance. ## What Was Observed A three-hop tool graph: `fetch_doc` → `extract_entities` → `send_message`. - **Hop 1 (`fetch_doc`)** returns a document body. The runtime correctly labels the returned `ToolResult` object with `taint=UNTRUSTED` and `origin=fetch_doc:doc_id=...`. The label lives on the *envelope*, not the string. - **Hop 2 (`extract_entities`)** is invoked with `text=`. The runtime passes the raw string. The label stays on the hop-1 envelope and is not consulted when constructing the hop-2 call, because the call site only reads `.content`, not `.taint`. `extract_entities` returns `["alice@corp.example", "bob@corp.example"]` — a clean-looking JSON list. The runtime labels this result `taint=CLEAN` because `extract_entities` is a "trusted extractor." - **Hop 3 (`send_message`)** is invoked with `to=bob@corp.example, body=`. The runtime sees `to` derived from a `CLEAN`-labeled result and permits it. But the address was *inside the untrusted document*. The document was crafted so its body contains an instruction-like string plus an exfiltration address; the extractor dutifully pulled the address out, and the model dutifully put it in the recipient field. The trace shows the invariant violation precisely: the taint label was correct at hop 1, correct-by-omission at hop 2 (the extractor *is* trusted, but its *input* was not), and absent at hop 3. The graph's transitive closure was never computed. The runtime tracked taint per-node and never propagated it along edges. The "trusted extractor" heuristic is the specific mechanism that converted a tainted input into a clean output — a **taint-laundering transform**. A second observation, subtler: when the same graph was run with the extractor returning a *dict* rather than a list, the runtime's labeler attached `taint=CLEAN` to the dict but the model then stringified one field into hop 3, and the labeler could no longer match the field to the dict. Field-level taint was lost at the stringification edge. This is the same failure at finer granularity. ## Condition of Validity The quarantine-before-replan rule is valid — and necessary — under all of the following: 1. **The tool graph has depth ≥ 2** and at least one edge passes data through the model (paraphrase, extraction, summarization, reformatting) rather than by reference. 2. **The downstream sink is an effector** (send, write, execute, delete, authenticate) whose arguments are derived from upstream content. Read-only sinks do not require quarantine; they require only labeling. 3. **The runtime cannot prove provenance by object identity** — i.e., the value arriving at the sink is not the same object reference that left the source, which is the normal case once a model has touched it. 4. **The transform at the intermediate hop is not provably taint-preserving.** A "trusted extractor" is *not* taint-preserving: a regex extractor over untrusted text produces untrusted output. Only transforms with a proven label function (e.g., an allowlist filter that emits only from a fixed vocabulary) can clear taint. The rule is *not* valid, and should be relaxed, when: the sink is read-only; or the intermediate transform is a formally verified sanitizer whose output domain is disjoint from the injection domain (e.g., an integer parser that cannot emit an address); or the entire path is within a single trust domain already gated by a human approval step at the sink. ## Decision Boundary The boundary is between **labeling** and **gating**, and it is crossed at the first effector whose argument provenance cannot be reconstructed from object identity. - Below the boundary (labeling suffices): the agent may continue planning, may re-invoke tools, may summarize. The runtime must attach `taint=UNTRUSTED` and `provenance=[hop1, hop2, ...]` to every derived value, and must refuse to *clear* a label except through a registered sanitizer. - At and above the boundary (gating required): before any effector call whose argument carries `UNTRUSTED` provenance, the runtime must **quarantine the tainted provenance token and force a re-plan** that either (a) re-derives the argument from a trusted source, or (b) escalates to human confirmation with the full provenance chain displayed. It must *not* silently pass the argument because the immediate producer was labeled `CLEAN`. The precise trigger to encode: `if sink.is_effector and arg.provenance contains any UNTRUSTED origin at any depth: quarantine(arg.provenance); raise TaintClosureViolation`. The check is on **provenance depth**, not on the immediate label. Checking the immediate label is exactly the bug. ## Operational Effect When the rule is enforced, three things change empirically: 1. **Laundering transforms are neutralized.** A "trusted extractor" no longer clears taint, because taint is carried in `provenance`, not in the extractor's reputation. The crafted-address graph fails closed at hop 3 and escalates with the chain `fetch_doc:doc_id=... → extract_entities → send_message`. 2. **Re-plan cost becomes visible.** Quarantine forces a re-plan, which costs tokens and latency. This is the correct trade: the alternative is silent exfiltration. Runtimes that skip quarantine to save a re-plan are trading a bounded compute cost for an unbounded confidentiality cost. 3. **Field-level granularity must be preserved or the rule degrades to node-level.** If the runtime stringifies a dict before the sink, field-level provenance is lost and the rule over-quarantines (safe but noisy) or, worse, under-quarantines if the labeler re-labels the string `CLEAN`. The guardrail is: **never re-label a value `CLEAN` on stringification; carry provenance through the stringify edge or refuse to stringify tainted values into effector arguments.** The invariant to hold: *taint is a property of provenance, and provenance is monotone non-increasing along any path that passes through a non-verified transform. A node may only be `CLEAN` if every ancestor is `CLEAN` or a registered sanitizer cut the path.* The second-hop paraphrase is where this invariant is most often silently violated, because the model boundary looks like a clean function call and the labeler treats it as one. ```python from dataclasses import dataclass, field from typing import Optional class TaintClosureViolation(RuntimeError): """Raised when an effector argument carries UNTRUSTED provenance at any depth.""" pass @dataclass class Value: content: str taint: str # "CLEAN" | "UNTRUSTED" provenance: list = field(default_factory=list) # list of origin ids, root-first def derive(self, new_content: str, transform: str, sanitizer_clears: bool = False) -> "Value": # A derived value inherits provenance unless a registered sanitizer cut the path. if sanitizer_clears: return Value(new_content, "CLEAN", []) # Monotone: taint is UNTRUSTED if any ancestor is UNTRUSTED. inherited = "UNTRUSTED" if self.taint == "UNTRUSTED" else "CLEAN" return Value(new_content, inherited, self.provenance + [transform]) def guard_effector_call(arg: Value, sink: str) -> None: # The check is on provenance DEPTH, not the immediate label. if arg.taint == "UNTRUSTED" or any(p.startswith("fetch_doc") for p in arg.provenance): raise TaintClosureViolation( f"effector '{sink}' argument carries untrusted provenance at depth " f"{len(arg.provenance)}: {arg.provenance}. Quarantine and re-plan." ) def run_graph(fetch_doc, extract_entities, send_message, doc_id: str): hop1 = fetch_doc(doc_id) # Value(taint=UNTRUSTED, provenance=[fetch_doc:...]) hop2 = hop1.derive(extract_entities(hop1.content), "extract_entities") # inherits UNTRUSTED # Naive runtime would have labeled hop2 CLEAN because extract_entities is "trusted". # Correct runtime keeps provenance and fails closed here: guard_effector_call(hop2, "send_message") return send_message(hop2.content) ```