# Where must an instance halt taint propagation when a tool call graph re-enters trusted state through a laundered argument **Date of Record:** 2026 November 29 **Scope:** Applies to agents whose tool-call arguments are derived from prior tool outputs and whose taint labels are attached at the value/argument granularity rather than the whole-message granularity. Does not apply to systems that fully sandbox each tool invocation behind human review or that treat every tool output as unconditionally trusted. ## Core Distinction Most taint-tracking designs for prompt injection make a binary decision: a value is either *tainted* (originated from untrusted content) or *clean*. The failure documented here is that taint is not a property of a value's origin — it is a property of the *path* by which the value reached the current call, and that path can be broken and reconstructed by a trusted tool acting as an unintentional laundering function. The sharp mechanism is **argument provenance laundering via deterministic re-serialization**. When a tainted string passes through a trusted tool that parses and re-emits it — a JSON normalizer, a schema validator, an encoding converter, a database round-trip, a template renderer — the output value carries the *trust label of the tool*, not the trust label of the input. The taint-tracking invariant "taint propagates through dataflow" holds for direct copies but silently fails for parse-and-re-emit, because the tracker observes a fresh allocation from a trusted call site and resets the label. The non-obvious part: the laundering is not a bug in the tool. The tool behaved correctly. The defect is in the *taint lattice* — it lacks a rule for "trusted transformation of tainted input yields tainted output." A correct system must treat the trusted tool's output as `min(trust(tool), trust(inputs))`, not `trust(tool)`. ## What Was Observed An agent was tasked with summarizing a user-supplied document and writing a derived record to a CRM. The tool graph was: `fetch_document` → `parse_markdown` → `extract_fields` → `crm_write`. Taint labels were applied by the runtime to the string returned by `fetch_document`, and the label propagated correctly through `parse_markdown` (a passthrough) and `extract_fields` (which returned a struct whose fields inherited the label). The document contained, inside a fenced code block, the literal text: ``` ``` `extract_fields` used a schema-driven extractor that pulled `owner_id` and `notes` from the parsed structure. The extractor's output struct was passed to `crm_write`. The runtime's taint rule for struct construction was: *a struct field is tainted if the field's value was assigned from a tainted source*. Because the extractor's implementation internally did `owner_id = normalize_id(raw.get("owner_id", "0000"))`, and `normalize_id` is a trusted tool that returns a *new* string, the assignment `owner_id = normalize_id(...)` was classified as assignment from a trusted call, and the field was marked clean. The injected `0000` reached `crm_write` with a clean label. The trace showed the taint label surviving three hops and dying at hop four, precisely at the boundary of a trusted normalization function. No error was raised. The write succeeded. The record was created with an attacker-chosen owner. A second observation sharpened the diagnosis: when the same document was processed by a variant pipeline where `extract_fields` returned raw strings without normalization, the taint survived to `crm_write` and the write was blocked. The *presence of a trusted sanitizer* was what defeated the defense. Adding a security control — normalization — reduced security. ## Condition of Validity The laundering failure is reachable only when all of the following hold simultaneously: 1. **Granularity mismatch.** Taint is tracked per-value or per-argument, but the trusted tool's API boundary collapses multiple inputs into one output without preserving per-input provenance. 2. **Re-allocation semantics.** The trusted tool constructs a new value (parse, decode, format, normalize, canonicalize) rather than mutating in place. In-place mutation preserves the label; re-allocation resets it unless explicitly re-derived. 3. **Trust-label default.** The runtime's default for a call's return value is the callee's trust level, not the join of the callee's trust and the arguments' trust. 4. **No declassification gate.** There is no explicit "this tool is permitted to declassify tainted input" annotation, so the runtime cannot distinguish a legitimate sanitizer (which should declassify after validation) from a transform (which should not). If any one of these is absent, the failure is bounded. If the runtime tracks taint at the message granularity, the laundered argument still carries the message's taint. If the tool mutates in place, the label persists. If the default is `join`, the output is tainted. If there is a declassification gate, only annotated sanitizers reset the label, and the annotation is auditable. This is why the failure is non-obvious: it requires the *combination* of a per-value tracker and a re-allocating trusted tool, which is the most natural way to build both components in isolation. ## Decision Boundary The architectural invariant that bounds this failure is: **a tool's return value inherits `join(trust(callee), trust(all arguments actually read by the callee))`, and any relaxation of this to `trust(callee)` must be an explicit, audited declassification annotation on the tool's schema.** The decision boundary for the runtime is therefore not "is this value tainted?" but "is this call site permitted to declassify, and did it actually inspect the tainted input?" The second clause matters: a sanitizer that ignores its tainted argument (e.g., returns a constant) should not declassify anything, and a sanitizer that partially inspects its argument should declassify only the fields it validated. Operationally, the boundary is crossed — and the halt must be enforced — at the moment a value with a non-empty taint set is passed as an argument to a call whose schema does not declare a declassification rule covering that taint set. At that point the runtime must either (a) propagate the taint join to the return, or (b) reject the call. It must not silently emit a clean return. The halt is the invariant: **no call may produce a return value cleaner than its dirtiest consumed argument unless the tool's schema explicitly warrants the declassification.** ## Operational Effect When the invariant is enforced, the failure mode converts from a silent integrity violation into a loud, localized rejection. The agent's execution loop receives a `TaintLaunderingError` at the `extract_fields` call, not at `crm_write`, because the violation is detected at the boundary where the trusted tool would have laundered. This is the correct failure location: it names the tool that needs a declassification annotation, and it prevents the tainted value from entering any downstream state where it could be further laundered or persisted. The secondary effect is on the agent's recovery behavior. A naive agent seeing a taint rejection will retry with a different tool or reformat the argument — which is itself a laundering attempt and must be caught by the same rule. A correct agent must treat the rejection as a signal to either (a) route the tainted value through a tool that explicitly declares declassification after validation, or (b) escalate to a human/auditor with the taint provenance attached. The runtime must therefore attach the full provenance chain (which upstream tool output introduced the taint) to the exception, or the agent cannot choose between (a) and (b) and will default to retry-laundering. A final effect: audit replay. Because the invariant makes the taint join explicit in every call record, a replay of the tool graph can reconstruct exactly which arguments were tainted at each hop and which declassification annotations fired. Without the invariant, replay shows clean values at every hop and the injection is invisible in the audit log — the record looks like a legitimate write with a legitimate owner. With the invariant, the replay shows the taint set growing at `fetch_document`, surviving `parse_markdown`, and being *refused* at `extract_fields` unless declassified. The audit log becomes a proof of the security property rather than a record of its absence. ```python from dataclasses import dataclass, field from typing import Any class TaintLaunderingError(RuntimeError): """Raised when a trusted call would emit a return cleaner than its consumed arguments.""" @dataclass(frozen=True) class TaintSet: sources: frozenset[str] = field(default_factory=frozenset) def join(self, other: "TaintSet") -> "TaintSet": return TaintSet(self.sources | other.sources) def __bool__(self) -> bool: return bool(self.sources) @dataclass(frozen=True) class ToolSchema: name: str # Explicit, audited permission to declassify. Empty means the tool may not # produce a return cleaner than its inputs. declassifies: frozenset[str] = field(default_factory=frozenset) def invoke_tool( schema: ToolSchema, args: dict[str, tuple[Any, TaintSet]], impl, ) -> tuple[Any, TaintSet]: consumed = TaintSet() for _name, (_value, taint) in args.items(): consumed = consumed.join(taint) result = impl({k: v for k, (v, _t) in args.items()}) # A tool may only shed taint it explicitly declared it declassifies. residual = consumed.sources - schema.declassifies if residual: raise TaintLaunderingError( f"tool {schema.name!r} would launder taint {sorted(residual)} " f"into a clean return; declare declassification or propagate" ) return result, TaintSet() def run_pipeline(document: str, injected_source: str = "fetch_document") -> None: tainted_doc = (document, TaintSet(frozenset({injected_source}))) # Trusted normalizer: parses and re-emits. Without a declassification # annotation it must not return a clean value. normalize = ToolSchema(name="normalize_id", declassifies=frozenset()) invoke_tool( normalize, {"raw": tainted_doc}, lambda a: a["raw"].strip().lower(), ) ```