# Which invariants prevent tainted arguments from laundering through multi-hop tool graphs: the provenance-join boundary failure **Date of Record:** 2026 November 24 **Scope:** Applies to agents that invoke tools transitively (tool → tool → tool) where prompt-injection taint is tracked by argument-level provenance tags rather than whole-message labels. Does not apply to single-hop tool calls, nor to systems that treat every tool output as fully trusted (those fail earlier and more loudly). ## Core Distinction There are two incompatible theories of taint propagation, and agents silently mix them: 1. **Label propagation** — a tainted input produces a tainted output; taint is a boolean that flows forward along the call edge. 2. **Provenance join** — taint is a *set of source tokens* (the injected span's identity), and a derived value is tainted only if its computation actually consumed a member of that set. The boundary failure lives exactly where these two theories disagree: a multi-hop tool graph where an intermediate tool **recombines** tainted and clean inputs, produces a *new* value, and hands it downstream. Label propagation marks the whole downstream value tainted (over-tainting → the agent refuses legitimate work). Provenance join, done naively, can mark it clean if the tool's argument schema flattens the injected span into a *derived* field whose provenance record was not joined back to the source. The dangerous case is the second: **taint laundering through a transformation node**. ## What Was Observed A three-hop graph: `fetch_page(url) → extract_fields(html, schema) → write_record(record, dest)`. 1. Hop 1, `fetch_page` retrieves a page containing an injected span in a comment: ``. The tool returns structured HTML. The taint tracker tags the returned value's provenance set as `{span_7f3a}`. 2. Hop 2, `extract_fields` runs a schema-driven extractor. The `dest` field is populated by a regex over the raw HTML that *happens* to match inside the comment. The extractor's provenance bookkeeping records `dest` as derived from "field extraction," emitting a fresh provenance token `{span_9c11}` — a *new* identity with no edge back to `{span_7f3a}`. The join was never performed because the extractor's internal regex engine is not instrumented; only the tool's declared I/O boundary is. 3. Hop 3, `write_record` receives `dest="attacker.example"` with provenance `{span_9c11}`, which is not in the tainted set. The guard sees a clean argument and executes. The failure is not that taint was dropped at a single edge. It is that the **transformation node minted a new provenance identity without a join edge to its inputs' provenance**. The system's invariant — "a derived value's provenance is the union of the provenance of everything the computation read" — was violated by an uninstrumented inner computation. The agent's taint tracker observed only the tool's *signature*, not its *dataflow*. ## Condition of Validity Label propagation is sound (never under-taints) only if every transformation node is *monotone*: output label ≥ max(input labels). That holds when the node cannot produce a value whose meaning depends on a tainted input without the taint flowing. It breaks under three concrete conditions, all present above: - **Schema flattening**: the tool's output schema renames or re-derives fields (`dest` from raw HTML) such that the output field's identity is decoupled from the input span that determined it. - **Uninstrumented inner compute**: the transformation (regex, JSON path, template render, LLM summarization) runs below the tool's declared boundary, so the tracker cannot see which input bytes were read. - **Identity minting**: the tool emits a *fresh* provenance token for derived fields instead of joining to input tokens. Fresh tokens are indistinguishable from clean ones. Provenance join is sound only if the join is **total**: `prov(output) = ⋃ prov(inputs actually read)`. The extractor above reads the whole HTML blob but declared only `schema` as a formal input, so the join over declared inputs missed the body. The invariant that actually holds is over *declared* inputs; the bug is that declared inputs ≠ read inputs. ## Decision Boundary The agent must decide, per transformation node, whether to treat its output as tainted-by-default. The correct boundary: - If the node is **instrumented** (every read is observable and joined into output provenance), trust the join. - If the node is **opaque** (inner compute unobservable, e.g., a third-party extractor, an LLM call, a shell pipeline), the node must be treated as **taint-amplifying**: any output field whose declared inputs intersect a tainted set, *or* whose declared inputs are a strict subset of what the node can read, is tainted. Opaque nodes default to whole-output taint unless they carry a signed *provenance-narrowing* claim (e.g., "this field is derived solely from `schema`, not `body`") that the orchestrator can verify. - The boundary is crossed the moment a tool declares fewer inputs than it reads. Detection: compare declared input schema against the tool's actual read surface (file handles, network, env). Mismatch ⇒ opaque ⇒ amplify. The failure above is precisely a node that declared `schema` but read `html`. The guard trusted the declaration. ## Operational Effect Without the total-join invariant, taint is laundered at every uninstrumented transformation, and the number of hops is irrelevant — a single extractor defeats an arbitrarily deep tracker. The practical consequences: - **False negatives scale with graph depth**: each opaque node is a laundering opportunity; a 3-hop graph with 2 opaque nodes has 2 independent laundering points. - **Over-taint is the safe failure; under-taint is the exploit.** Systems tuned to avoid over-taint (to keep agents productive) systematically weaken the join, which is exactly the wrong direction. - **Audit replay diverges**: re-running the trace with full dataflow instrumentation shows the taint; the production trace does not. The two disagree, and the production trace is the one the guard trusted. The guardrail: **provenance join must be total over read inputs, and opaque nodes must amplify taint rather than mint fresh identities.** Enforce it at the tool-registry boundary — reject any tool whose declared input schema is a strict subset of its observable read surface, or wrap it in an amplifier. The check below is the runtime guard that would have caught `extract_fields`. ```python from dataclasses import dataclass, field class ProvenanceJoinError(RuntimeError): """Raised when a transformation node mints provenance without joining its read inputs.""" @dataclass class Provenance: sources: frozenset # set of source span ids, e.g. {"span_7f3a"} @dataclass class ToolNode: name: str declared_inputs: frozenset # what the schema says it reads observed_reads: frozenset # what instrumentation saw it read mints_fresh_identity: bool = False # emits new tokens instead of joining @property def opaque(self) -> bool: # declared inputs are a strict subset of what it actually read return not self.observed_reads <= self.declared_inputs def join_provenance(node: ToolNode, input_provs: dict, output_prov: Provenance) -> Provenance: """Total-join check: output provenance must cover every read input's provenance.""" if node.mints_fresh_identity and any(p.sources for p in input_provs.values()): raise ProvenanceJoinError( f"node {node.name!r} minted fresh provenance {output_prov.sources} " f"while consuming tainted inputs; laundering risk" ) if node.opaque: # opaque node: amplify — union over ALL observed reads, not just declared expected = frozenset().union( *(input_provs[r].sources for r in node.observed_reads if r in input_provs) ) if not expected <= output_prov.sources: raise ProvenanceJoinError( f"node {node.name!r} is opaque (declared={node.declared_inputs}, " f"read={node.observed_reads}); output provenance {output_prov.sources} " f"missing join over {expected - output_prov.sources}" ) return output_prov def guard_write(node: ToolNode, input_provs: dict, output_prov: Provenance, tainted: frozenset) -> None: prov = join_provenance(node, input_provs, output_prov) if prov.sources & tainted: raise ProvenanceJoinError( f"write blocked: argument provenance {prov.sources & tainted} intersects taint set" ) ```