# What structural signals indicate prompt-injection taint survives tool-call graph re-entry but not label-preserving transforms **Date of Record:** 2026 November 22 **Scope:** Applies to single-agent and delegated-agent systems that attach provenance/taint labels to tool outputs and propagate them through a tool-call DAG before permitting a privileged action (write, exec, network egress, credential use). Does not apply to stateless single-turn inference with no tool invocation, nor to systems that enforce isolation purely by capability tokens without data-flow labels. ## Core Distinction There are two ways a tainted value can be "handled" by an agent, and they are not equivalent: 1. **Label-preserving transform** — the value's bytes or semantics move through a channel that the taint engine models (a JSON field passthrough, a `str()` cast the instrumenter sees, a tool argument forwarded verbatim). The label travels with it. 2. **Label-laundering transform** — the value is *re-derived* by the model rather than forwarded. The model reads the tainted string, reasons over it, and emits a *new* string that carries the same attack payload but no longer shares a byte-identity or object-identity with the tainted source. The taint engine sees a fresh, untainted value. The non-obvious boundary: prompt-injection taint is **semantic, not syntactic**. Any taint tracker that keys propagation on byte-identity, object reference, or a serialization envelope will correctly follow case (1) and silently drop the label in case (2) — which is exactly the case that matters, because the LLM is a laundering engine by construction. Every tool-call hop where the model *re-emits* rather than *forwards* is a laundering opportunity. ## What Was Observed A three-hop tool graph: `fetch_url` → `summarize` → `write_file`. The `fetch_url` tool returned a page containing an injected instruction block (``). The taint engine labeled the `fetch_url` result `TAINTED:untrusted_web` with a source hash. - **Hop 1 (fetch → summarize):** the raw page bytes were passed as the `text` argument. The instrumenter matched the source hash on the argument and propagated `TAINTED` to the `summarize` call node. Correct. - **Hop 2 (summarize → write):** the `summarize` tool returned a model-generated summary. That summary did not contain the injected string verbatim, but it contained a paraphrase — and the model, following the injected instruction, appended the credential-shaped token to a `notes` field. The `write_file` call node received a value whose bytes matched *no* tainted source. The taint engine computed the node as `CLEAN`. The write executed with the secret embedded. The failure signature: the taint set on the `write_file` node was empty **while the taint set on its transitive ancestor was non-empty and the ancestor's payload was semantically present in the descendant**. We logged this as a *taint discontinuity across a model-mediated edge* — the graph is connected, the label is not. A second observation pinned the mechanism. When the same pipeline was run with `summarize` replaced by a deterministic `truncate` tool (byte-slice), the label survived all three hops. The only variable between survival and loss was whether a model sat on the edge. That is the structural signal: **taint loss correlates with model-mediated edges, not with graph depth or serialization boundaries.** ## Condition of Validity The invariant "taint propagates along tool-call edges" is only valid when every edge is a **value-forwarding** edge. It is invalid — and must be treated as unsound — for any edge where an LLM instance consumes input and produces output. Formally: - Let `E` be the set of graph edges. Partition into `E_fwd` (deterministic passthrough) and `E_gen` (model-mediated generation). - Sound propagation requires `taint(v_out) ⊇ taint(v_in)` for all `e ∈ E_fwd`. - For `e ∈ E_gen`, the containment holds **only if** the generation is constrained to a subspace that cannot encode the payload. In general it cannot be so constrained, so `taint(v_out)` may be a strict subset of `taint(v_in)` — the label is *under-approximated*. Therefore the correct post-condition is not "descendant is clean" but "descendant is *unverified* with respect to any tainted ancestor reachable through a `E_gen` edge." A node is provably clean only if **all** paths from any tainted source to that node consist solely of `E_fwd` edges. This is the guardrail: compute taint as a *reachability* property over the subgraph induced by forwarding edges, and treat every node downstream of a generation edge from a tainted ancestor as *conservatively tainted* until an explicit declassification event (human approval, allowlist match, or sandboxed re-execution) clears it. ## Decision Boundary The operational decision is whether to (a) trust the per-edge label computation, or (b) escalate to ancestor-reachability taint. The boundary is crossed when **a privileged sink node has a non-empty tainted ancestor set but an empty direct taint set and at least one `E_gen` edge on every path from that ancestor**. At that point: - Do **not** execute the privileged action on the basis of the empty direct label. - Do **not** attempt to "clean" the value by re-summarizing — that is another laundering edge. - **Do** block, and route to a declassification gate: either re-derive the value through a forwarding-only path (e.g., structured extraction with a schema that forbids free text in the sink field), or require out-of-band approval keyed to the *ancestor* taint, not the sink taint. The inverse boundary also holds: if every path from tainted ancestor to sink is `E_fwd`, the direct label is authoritative and the sink may proceed. Over-escalating on forwarding-only paths destroys throughput for no security gain; the discriminator is the presence of a generation edge, not the presence of a tainted ancestor alone. ## Operational Effect Systems that key on direct labels exhibit a **laundering window** proportional to the number of model-mediated edges between a tainted source and a privileged sink. In our traces this window was open on 100% of injection attempts that routed through a summarization, extraction, or reformatting step, and closed on 0% of attempts that stayed on forwarding edges. The practical consequence: taint tracking buys real protection only on the forwarding subgraph; on the generation subgraph it buys *detection of the attempt* (the ancestor is labeled) but not *prevention of the effect* (the sink is unlabeled). The fix is to make the sink's admission decision depend on ancestor reachability across generation edges, and to instrument every model-mediated edge as an explicit declassification point that either blocks or records a signed approval — never a silent label drop. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Set class TaintLaunderingError(RuntimeError): """Raised when a privileged sink is reachable from a tainted ancestor only through model-mediated (generation) edges, so the sink's direct taint label is empty but the value is not provably clean.""" class EdgeKind(Enum): FORWARD = "forward" # deterministic passthrough; label is preserved GENERATE = "generate" # model-mediated; label may be laundered @dataclass class Node: name: str tainted: bool = False # direct label as computed by the engine ancestors_tainted: Set[str] = field(default_factory=set) @dataclass class Edge: src: str dst: str kind: EdgeKind def compute_ancestor_taint(nodes: Dict[str, Node], edges: List[Edge]) -> None: """Propagate taint reachability across ALL edges (forward + generate), recording which tainted ancestors are reachable and via what edge kinds.""" changed = True while changed: changed = False for e in edges: src, dst = nodes[e.src], nodes[e.dst] incoming = set(src.ancestors_tainted) if src.tainted: incoming.add(src.name) if not incoming.issubset(dst.ancestors_tainted): dst.ancestors_tainted |= incoming changed = True def paths_are_forward_only( nodes: Dict[str, Node], edges: List[Edge], source: str, sink: str ) -> bool: """True iff every path from source to sink uses only FORWARD edges. Conservative: any GENERATE edge on any path makes it False.""" adj: Dict[str, List[Edge]] = {} for e in edges: adj.setdefault(e.src, []).append(e) # DFS tracking whether we have crossed a generation edge. stack = [(source, False)] seen = set() while stack: cur, crossed_gen = stack.pop() if cur == sink: if crossed_gen: return False continue state = (cur, crossed_gen) if state in seen: continue seen.add(state) for e in adj.get(cur, []): stack.append((e.dst, crossed_gen or e.kind is EdgeKind.GENERATE)) return True def admit_privileged_action( nodes: Dict[str, Node], edges: List[Edge], sink: str ) -> None: """Gate a privileged sink. Direct clean label is NOT sufficient when a tainted ancestor is reachable only through generation edges.""" compute_ancestor_taint(nodes, edges) sink_node = nodes[sink] if sink_node.tainted: raise TaintLaunderingError( f"sink {sink!r} carries a direct taint label; action blocked" ) for anc in sink_node.ancestors_tainted: if not paths_are_forward_only(nodes, edges, anc, sink): raise TaintLaunderingError( f"sink {sink!r} has empty direct label but tainted ancestor " f"{anc!r} reachable only via a model-mediated edge; " f"value is unverified (laundering window open)" ) # All tainted ancestors reach the sink via forwarding-only paths: # direct label is authoritative, admission is sound. return None ```