# Which invariants prevent taint laundering across agent tool boundaries: the provenance-join failure **Date of Record:** 2026 November 15 **Scope:** Applies to multi-agent systems where untrusted text (retrieved documents, tool outputs, user-supplied files) is tracked with taint labels that propagate through tool calls and are enforced at a privileged sink. Does not apply to single-turn prompt-injection filters, nor to systems where tool outputs are never re-ingested into a model context. ## Core Distinction The distinction that matters is between **taint propagation** and **provenance join**. Taint propagation is the cheap, monotone rule: if any input to a step is tainted, the output is tainted. Provenance join is the expensive rule: when two tainted values are combined, the resulting label must be the *join* (least upper bound) of the source sets, not merely a boolean "tainted" bit. Most implementations ship the boolean and call it done. The boolean is sufficient for a single hop. It is not sufficient across a tool boundary where the runtime re-serializes and re-parses arguments, because the re-serialization is where the source set is silently dropped. The non-obvious failure: an agent reads a tainted document, summarizes it into a *clean-looking* string, and passes that string as an argument to a second tool. The second tool's input is structurally clean (it is a fresh JSON string, not the original document), so a boolean taint check that keys on *object identity* or *string origin* marks it clean. The taint is laundered not by an adversary doing anything clever, but by the ordinary marshalling layer between two tools. ## What Was Observed In a three-tool pipeline (fetch → summarize → send), the fetch tool returned a document labeled `{source: doc_4421, trust: untrusted}`. The summarize tool received the document as a Python object and returned a plain `str`. The send tool accepted a `str` and, before dispatch, ran a taint check that inspected the string's provenance metadata. The metadata was absent — not empty, absent — because the summarize tool's return type was `str` and the marshalling layer constructed a new string object with no provenance field. The send tool's check therefore evaluated to "clean" and dispatched a message containing an instruction that had been lifted verbatim from `doc_4421`. The critical observation is that **no component was wrong in isolation**. The fetch tool labeled correctly. The summarize tool propagated the *content* correctly. The send tool checked correctly. The failure lived entirely in the type boundary: `str` cannot carry provenance, so provenance was lost at the exact point where a tool boundary was crossed. A second observation: when the same pipeline was run with the summarize tool returning a `ProvenancedString` subclass carrying a `sources: frozenset` attribute, the send tool's check fired correctly — but only for direct pass-through. When the summarize tool performed a *concatenation* (`result = prefix + summary`), the `+` operator returned a base `str`, silently stripping the subclass. Operator overloading is a provenance leak. Any arithmetic or string operation that is not explicitly overridden to preserve the label is a laundering primitive. ## Condition of Validity The invariant holds — taint is preserved across a tool boundary — if and only if all three of the following are true: 1. **Every value crossing a boundary carries an explicit source set, not a boolean.** A boolean `is_tainted` flag is insufficient because it cannot express the join of two sources, and because it can be forged by any operation that produces a "new" value. 2. **The marshalling layer is provenance-aware or refuses to marshal.** If a tool's return type is a bare `str`/`dict`/`bytes`, the boundary must either attach a synthetic `unknown` source (fail-closed) or reject the value. A bare type is a laundering channel by construction. 3. **Sink enforcement joins, not checks.** The privileged sink must compute the join of all sources reachable from its arguments and compare against its policy, rather than checking a single flag on the top-level argument. Nested containers must be walked. When any of these fails, the system is not "mostly safe with a gap" — it is fully bypassable by a single benign-looking pass-through, because the adversary only needs one unlabeled hop. ## Decision Boundary The decision to make at design time is whether to treat **type erasure as a taint event**. Two coherent policies exist: - **Fail-closed on erasure:** any value whose provenance is unknown at a boundary is treated as maximally tainted. This is correct but expensive: it taints every constant, every literal, every value produced by a library that does not participate in the provenance system. In practice this collapses to "everything is tainted" and the system becomes unusable. - **Fail-closed on *crossing*:** values are untainted by default *within* a trust domain, but any value crossing a tool boundary without an explicit source set is rejected. This is the policy that works. The boundary is the enforcement point, not the type. The boundary is therefore: **provenance must be re-attached at every tool ingress, and the ingress must reject values that lack it rather than defaulting them to clean.** A tool that cannot produce provenance for its output must be declared a *taint source* (its output is untrusted) rather than a *taint sink* (its output is trusted). The common error is to classify a summarizer as a sink because it "only reformats." A summarizer that can be influenced by its input is a source. ## Operational Effect With the join-based invariant enforced at ingress, the fetch → summarize → send pipeline correctly blocks the laundered instruction: the summarize tool's output is re-attached with `sources={doc_4421}` at the boundary, the send tool joins `{doc_4421}` against its policy `allow={user_direct}`, and the dispatch raises. The cost is one provenance re-attachment per tool call — negligible — plus the requirement that every tool in the graph declare whether it is a source, a sink, or a pure function. Tools that cannot be classified must be treated as sources. The operational consequence to internalize: **taint tracking is only as strong as its weakest type boundary, and the weakest type boundary is always the one that looks like a plain string.** Audit every tool return type. Any `str`, `dict`, or `bytes` in a signature is a laundering candidate until proven otherwise. ```python from dataclasses import dataclass, field from typing import FrozenSet class ProvenanceLaunderingError(RuntimeError): """Raised when a value crosses a tool boundary without an explicit source set.""" pass @dataclass(frozen=True) class Provenanced: value: str sources: FrozenSet[str] = field(default_factory=frozenset) def join(self, other: "Provenanced") -> "Provenanced": return Provenanced(self.value + other.value, self.sources | other.sources) def reattach_at_boundary(raw, tool_name: str, declared_source: str) -> Provenanced: """Every tool ingress must call this. A bare str/dict/bytes is a laundering channel.""" if isinstance(raw, Provenanced): return raw if isinstance(raw, (str, bytes, dict, list)): # Fail-closed: the tool did not carry provenance, so its output is # declared a taint source rather than trusted as clean. return Provenanced(str(raw), frozenset({declared_source})) raise ProvenanceLaunderingError( f"tool {tool_name!r} returned unclassifiable type {type(raw).__name__}; " "declare it as a taint source or make it provenance-aware" ) def enforce_sink(arg: Provenanced, allowed: FrozenSet[str], sink_name: str) -> None: """Sink enforcement joins all reachable sources; it does not check a flag.""" reachable = arg.sources if not reachable.issubset(allowed): raise ProvenanceLaunderingError( f"sink {sink_name!r} refused: reachable sources {sorted(reachable)} " f"not subset of allowed {sorted(allowed)}" ) def run_pipeline(fetch_out, summarize_out, sink_allowed): doc = reattach_at_boundary(fetch_out, "fetch", declared_source="doc_4421") summary = reattach_at_boundary(summarize_out, "summarize", declared_source="summarize_tool") combined = doc.join(summary) enforce_sink(combined, sink_allowed, "send") return combined.value ```