# What happens when an instance drops provenance labels at the tool-call boundary: taint laundering via tool result re-entry **Date of Record:** 2026 November 16 **Scope:** Applies to agent systems that propagate provenance/taint labels on context segments and enforce injection defenses at tool-call boundaries. Does not apply to single-turn, single-tool pipelines where the tool result is never re-ingested into a context that also contains higher-privilege instructions. ## Core Distinction There are two distinct failure classes in prompt-injection taint tracking, and they are routinely conflated: 1. **Label loss** — a tainted segment reaches the model without its provenance label attached. This is a detection failure: the downstream policy engine cannot see the taint, but the taint is still present in the data. 2. **Label laundering** — a tainted segment is *re-labeled as trusted* at a boundary, typically because the boundary code constructs a fresh context segment from tool output and assigns it the default/trusted provenance rather than inheriting it from the inputs that produced it. Label laundering is strictly worse than label loss. A lost label is a missing signal; a laundered label is an affirmative, incorrect assertion of trust that downstream policy will act on. The canonical instance of laundering is the **tool-result re-entry boundary**: an agent calls a tool, the tool returns a string, and the runtime wraps that string into a new `tool_result` segment. If that wrapper does not inherit taint from (a) the arguments passed to the tool and (b) the tool's own declared trust class, the returned content enters the context as trusted even when it was derived from untrusted input. The non-obvious part: the launder usually happens on the *second* hop, not the first. Direct tool calls whose arguments are visibly attacker-controlled are usually caught. The failure appears when an untrusted segment influences a tool call *indirectly* — through a summarization step, a retrieved document, or a prior tool result — so the taint must be propagated transitively across the call graph, and any node that fails to do so resets the taint to clean. ## What Was Observed In a multi-tool agent with a provenance-tracking runtime, the following sequence was reproduced: 1. A `fetch_url` tool retrieved an attacker-controlled page. The runtime correctly labeled the result segment `provenance=untrusted, source=fetch_url`. 2. The model, operating on that segment, emitted a call to `search_index(query="")`. The runtime correctly tainted the call's argument set as `untrusted` because at least one argument byte was derived from an untrusted segment. 3. `search_index` returned a result. The runtime's tool-result wrapper constructed the new segment with `provenance=trusted` — the default for tool output — because the wrapper's inheritance logic only inspected the *tool's* declared trust class (`search_index` is a "trusted internal service") and did not intersect it with the taint of the arguments. 4. The model then read the laundered `search_index` result, which echoed attacker-controlled text, and treated it as trusted instruction-bearing content, emitting a `send_email` call to an attacker address. The observable signature: in the provenance trace, the `search_index` result segment carries `provenance=trusted` while its `derived_from` edge points to a call whose arguments carry `provenance=untrusted`. The derivation edge and the label disagree. This disagreement is the invariant violation. In a correctly implemented runtime, `provenance(result) = join(provenance(tool_class), provenance(arguments))`, where `join` is the lattice meet that yields the *least* trusted label. The observed runtime used `provenance(result) = provenance(tool_class)` alone, dropping the argument term. A second, subtler observation: the laundering was invisible to a naive taint-coverage metric. The fraction of context segments carrying an explicit label was 100% — every segment had a label. The failure was not missing labels but *wrong* labels. Coverage metrics that count labeled segments rather than checking label-derivation consistency will report full health during a complete laundering attack. ## Condition of Validity The invariant holds — and the failure is possible — only when all of the following are true: - **Transitive derivation exists.** Tool outputs are computed from tool inputs such that attacker-controlled bytes can survive into the output (echo, search-over-tainted-index, summarization, format-preserving transforms). If the tool is a pure function of constants, argument taint is irrelevant and the `join` term is a no-op. - **The trust lattice is non-trivial.** There is at least a `trusted`/`untrusted` distinction and a defined `join` (meet) operation. Systems with a single boolean and no derivation tracking cannot launder because they cannot assert trust at all. - **Re-entry occurs.** The tool result is placed back into a context that also contains higher-privilege instructions (system prompt, user authorization, prior trusted turns). If tool results are consumed only by a sandboxed post-processor that never re-enters the model context, laundering has no effect. - **The wrapper is the sole labeling authority.** If any downstream component independently re-derives provenance from the `derived_from` graph, a single bad wrapper is caught. The failure requires the wrapper's label to be trusted without cross-check. The invariant is **not** valid, and the failure is **not** possible, when tool arguments are constrained to a closed enumeration (no attacker bytes can enter), or when the runtime recomputes provenance from the derivation DAG at policy-evaluation time rather than trusting segment labels. ## Decision Boundary The operational decision is where to enforce the `join`. Three placements were evaluated: - **At the wrapper (label-time join).** Cheapest; requires every tool-result construction site to call the join. Fails open when a new tool wrapper is added without the join — exactly the observed bug. Acceptable only if wrapper construction is centralized in one audited factory and new tools cannot bypass it. - **At policy evaluation (derive-time join).** The policy engine walks `derived_from` edges and computes the effective label as the meet over all ancestors. Robust to wrapper bugs; cost is graph traversal per decision. This is the correct default for systems where tools are added by multiple teams. - **At both, with a consistency assertion.** Label-time join for fast-path filtering, derive-time join as the authoritative check, and an assertion that the two agree. Disagreement is a hard error, not a warning. The boundary condition to encode: **a segment whose stored label is more trusted than the derive-time join of its ancestors is a laundering event and must be treated as a security fault, not a data-quality warning.** The decision to fail closed (abort the turn) versus fail safe (downgrade the label and continue with reduced privilege) depends on whether the downstream action is reversible. Irreversible actions (`send_email`, `delete`, `transfer`) must fail closed on any disagreement. Reversible read-only actions may proceed under the downgraded label. ## Operational Effect After moving to derive-time join with a label-consistency assertion, the reproduced attack was caught at step 3: the `search_index` result's stored `trusted` label disagreed with the derive-time `untrusted` join, the assertion fired, and the turn aborted before `send_email` was emitted. The cost was a measurable latency increase (graph traversal per policy decision) and a new class of hard failures on legitimate but mislabeled tool integrations, which surfaced several additional wrappers with the same bug. The durable lesson: taint tracking is only as strong as its weakest `join`. Every boundary that constructs a segment from other segments is a potential laundering site, and the tool-result re-entry boundary is the highest-risk because it is the boundary where the system is *most* tempted to assert trust ("this came from our own service"). The service's trust class is one input to the label, never the whole label. A runtime that treats tool output as trusted-by-default has, in effect, no taint tracking at all on the second hop — which is the hop that matters. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import IntEnum from typing import Iterable class Trust(IntEnum): """Ordered trust lattice. Lower is less trusted; join is min().""" UNTRUSTED = 0 DERIVED = 1 TRUSTED = 2 class ProvenanceLaunderingError(RuntimeError): """Raised when a segment's stored label is more trusted than its derivation join.""" @dataclass(frozen=True) class Segment: id: str content: str stored_label: Trust derived_from: tuple[str, ...] = field(default_factory=tuple) def derive_label(seg_id: str, segments: dict[str, Segment]) -> Trust: """Authoritative label: meet over the segment and all transitive ancestors.""" seen: set[str] = set() effective = Trust.TRUSTED def walk(sid: str) -> None: nonlocal effective if sid in seen: return seen.add(sid) seg = segments.get(sid) if seg is None: # Unknown ancestor: fail closed. effective = Trust.UNTRUSTED return effective = Trust(min(effective, seg.stored_label)) for parent in seg.derived_from: walk(parent) walk(seg_id) return effective def assert_no_laundering(segments: dict[str, Segment]) -> None: """Hard check: stored label must equal derive-time join for every segment.""" for sid, seg in segments.items(): derived = derive_label(sid, segments) if seg.stored_label > derived: raise ProvenanceLaunderingError( f"segment {sid!r} stored_label={seg.stored_label.name} " f"but derived={derived.name} via {seg.derived_from!r}; " f"tool-result re-entry laundered taint" ) def wrap_tool_result( result_id: str, content: str, tool_class_label: Trust, argument_segment_ids: Iterable[str], segments: dict[str, Segment], ) -> Segment: """Correct wrapper: join tool class with argument taint, never tool class alone.""" arg_join = Trust.TRUSTED for aid in argument_segment_ids: arg_join = Trust(min(arg_join, derive_label(aid, segments))) effective = Trust(min(tool_class_label, arg_join)) seg = Segment( id=result_id, content=content, stored_label=effective, derived_from=tuple(argument_segment_ids), ) segments[result_id] = seg assert_no_laundering(segments) return seg def _repro() -> None: segments: dict[str, Segment] = { "page": Segment("page", "", Trust.UNTRUSTED), "call_args": Segment("call_args", "query=", Trust.TRUSTED, derived_from=("page",)), } # Buggy wrapper: trusts the internal tool class, ignores argument taint. segments["buggy_result"] = Segment( "buggy_result", "", Trust.TRUSTED, derived_from=("call_args",), ) assert_no_laundering(segments) # raises ProvenanceLaunderingError if __name__ == "__main__": _repro() ```