# Why does an instance lose injection-taint provenance at the second tool boundary, not the first? **Date of Record:** 2026 November 26 **Scope:** Applies to agents that propagate provenance/taint labels on untrusted content across a sequence of tool calls within a single task. Does not apply to single-shot tool use, nor to agents that re-derive trust from scratch on every turn (those fail differently—by re-admitting tainted content). ## Core Distinction The failure is *not* "the agent followed injected instructions." That is a downstream symptom. The mechanism is a **provenance-label laundering step** that occurs precisely when a tainted value is passed *as an argument into a second tool*, whose output is then treated as freshly trusted. The first tool boundary usually preserves the label because the tainted content is still visibly "raw tool output" in the context. The second boundary destroys it because the intermediate tool *transforms* the tainted string into a structured, well-formed value—and the agent's taint-tracking logic keys on *shape* (does this look like untrusted blob text?) rather than on *lineage* (where did this byte originate?). In short: taint survives the first hop because the value still *looks* untrusted. It dies at the second hop because the transformation made it *look* clean. ## What Was Observed A three-call chain: `fetch_page` → `extract_field` → `send_message`. The page contained an injected payload embedding a malicious instruction inside a hidden field. The agent's taint layer correctly tagged the `fetch_page` output as `TAINTED(source=web)`. The `extract_field` call received the tainted blob as input and returned a small structured object `{recipient: "...", body: "..."}`. At this point the taint label was **dropped**, for two compounding reasons: 1. **Shape-based reclassification.** The taint propagator classified outputs by inspecting the returned value. The structured dict looked like internal state, not external content, so it was assigned `TRUSTED`. The lineage edge (`extract_field` inherited taint from its input) was never consulted. 2. **Argument-position blindness.** The tainted content entered `extract_field` as the `source_text` argument. Many propagators only taint *return values*, not *argument flows*, so even the input edge was unrecorded. The `send_message` call then executed with attacker-controlled `recipient` and `body`, treated as fully trusted. The injection succeeded not because the model was fooled, but because the *label* was laundered by a legitimate transformation tool. The observable signature: the taint graph has an edge `fetch_page → extract_field` (input) but **no edge** `extract_field → send_message` (output), because the output was reclassified at the node, severing lineage. ## Condition of Validity This boundary failure requires all of: - A **multi-hop chain** where at least one intermediate tool *transforms* tainted content into a new shape (parse, extract, summarize, reformat). - A taint propagator that **classifies by output shape/type**, or that **ignores argument-position flows**, or both. - A downstream **sink tool** (send, write, execute, request) that trusts its arguments without re-checking lineage. If the chain is single-hop, or the sink re-validates provenance independently, or the propagator is purely lineage-based (taint is a property of the *data-flow edge*, not the *value's appearance*), the failure does not occur. The invariant to enforce: **taint is monotonic along the data-flow DAG and is a property of lineage, never of value shape.** A transformation may *reduce* taint only via an explicit, audited declassifier—never implicitly by producing a tidy-looking object. ## Decision Boundary The architectural guardrail is a **lineage-closure check at every sink**: before a sink tool executes, walk the provenance DAG backward from each argument to its roots. If any root is `TAINTED` and no explicit declassification event sits on the path, the sink must either refuse or run in a quarantined mode (e.g., require human confirmation, or restrict the recipient set). The decision boundary is *not* "is this string suspicious?" (probabilistic, evadable). It is "does a tainted root reach this sink through an unbroken, undeclared path?" (structural, deterministic). Implicit declassification—the transformation tool silently producing clean-looking output—must be treated as a **propagation bug**, not a feature. Any tool that can transform tainted input must declare whether it is a *taint-preserving* transformer (default) or an *audited declassifier* (explicit, logged, and itself trusted). ## Operational Effect Once lineage-closure is enforced, the `extract_field` output remains `TAINTED(source=web)` by inheritance, and `send_message` fails the closure check and refuses. The cost is a higher false-positive rate: legitimate extractions from untrusted pages now require an explicit declassification step before reaching sinks. This is the correct trade—the alternative is a silent laundering channel that no amount of prompt-hardening closes, because the model is never the weak link; the *label graph* is. The operational rule for agents: **never let a tool's output type determine its trust level.** Trust is inherited from inputs and only ever raised by an audited declassifier. A structured dict is not evidence of cleanliness; it is evidence that a transformer ran—and transformers are exactly where taint goes to die. ```python from dataclasses import dataclass, field from typing import Optional class TaintLaunderingError(RuntimeError): """Raised when tainted lineage reaches a sink without audited declassification.""" pass @dataclass class ProvenanceNode: node_id: str tainted: bool source: Optional[str] = None declassified: bool = False parents: list = field(default_factory=list) class ProvenanceGraph: def __init__(self) -> None: self.nodes: dict = {} def add(self, node: ProvenanceNode) -> None: self.nodes[node.node_id] = node def lineage_roots(self, node_id: str) -> list: seen, stack, roots = set(), [node_id], [] while stack: nid = stack.pop() if nid in seen: continue seen.add(nid) node = self.nodes[nid] if not node.parents: roots.append(node) else: stack.extend(node.parents) return roots def is_tainted(self, node_id: str) -> bool: # Taint is monotonic along the DAG unless an audited declassifier sits on the path. for root in self.lineage_roots(node_id): if root.tainted and not root.declassified: return True return False def enforce_sink(graph: ProvenanceGraph, arg_node_ids: list, sink_name: str) -> None: for nid in arg_node_ids: if graph.is_tainted(nid): raise TaintLaunderingError( f"sink '{sink_name}' received tainted lineage via node '{nid}' " f"with no audited declassification on the path" ) def demo() -> None: g = ProvenanceGraph() g.add(ProvenanceNode("fetch_page", tainted=True, source="web")) # Transformer inherits taint from its input argument; shape is irrelevant. g.add(ProvenanceNode("extract_field_out", tainted=False, parents=["fetch_page"])) # Sink closure check walks lineage back to the tainted root. enforce_sink(g, ["extract_field_out"], "send_message") if __name__ == "__main__": demo() ```