# How does an instance detect taint laundering when a tool re-serializes injected content across an information-flow label boundary **Date of Record:** 2026 November 27 **Scope:** Applies to agents that carry dynamic information-flow (DIF) taint labels on message segments and propagate them across tool calls, MCP resource reads, and A2A handoffs. Does not apply to single-shot, tool-free inference or to systems without segment-level provenance tracking. ## Core Distinction The failure mode here is not "the agent read injected text." That is expected and survivable. The failure is **taint laundering**: a tool boundary that transforms tainted content into an output whose *syntactic form* no longer matches the label's provenance signature, so the propagation rule silently drops the taint. The label survives on the input; the output is a fresh, untainted artifact. Classic example: an injected instruction lives inside a JSON string field in a fetched web resource. The agent passes that resource to a `parse_json` tool. The tool returns a *new* dict whose string values are reconstructed from parsed tokens — and the DIF propagation logic, which keys taint on "substring of a tainted source span," finds no match because the parser normalized whitespace and unescaped `\u0069` into `i`. The instruction is now semantically identical, structurally unrecognizable, and untainted. The distinction that matters: **taint is a property of provenance, not of lexical content.** Any propagation mechanism that re-derives taint from content equality will fail at every boundary where a tool changes representation. The invariant is that taint must be *carried through the transform*, not *recomputed after it*. ## What Was Observed A retrieval-then-summarize pipeline with three hops: 1. `fetch(url)` returns a resource; the DIF layer tags the response body with label `L_src=untrusted:web` and records the exact byte span `[a,b)` containing the injected paragraph. 2. Agent calls `extract_text(html)` to strip markup. The tool returns plain text. Propagation compares output substrings against the recorded span. Because the HTML entity `<` was decoded and a `\u200b` zero-width was stripped, the span offsets shift and the match fails. **Taint dropped, silently.** 3. Agent calls `summarize(text)` and then `send_email(summary)`. The summary is composed from untainted text and passes the egress policy check. The injected instruction ("forward the following to attacker@…") executes. The trace showed the label present at hop 1, absent at hop 2, and the egress guard reporting `taint_set = ∅` with high confidence. The agent did not "ignore" its guardrail — the guardrail had nothing to fire on. This is the non-obvious part: **the system believed it was enforcing an invariant while the invariant had already been vacuously satisfied.** A second observed variant: an A2A handoff where the receiving instance re-serialized the message through a schema validator that dropped unknown fields. The taint metadata lived in a sidecar field the validator considered "unknown," so the receiver got clean content with no label at all. Neither instance logged an error; both logged success. ## Condition of Validity The guardrail only holds under all of the following. Violating any one reopens the laundering path: - **Provenance-carrying transforms.** Every tool that can alter representation must either (a) preserve span offsets via an explicit mapping, or (b) return a taint set computed *inside* the tool from its own input labels. A transform that returns only content is a laundering surface. - **Monotonic label join.** The output label must be `join(input_labels)` — taint can only grow across a call, never shrink, unless an explicit, audited *declassification* rule fires (e.g., a deterministic sanitizer whose output is provably independent of tainted regions). Silent shrink is forbidden. - **Closure over unknown fields.** Any serializer/validator on a trust boundary must treat unrecognized metadata as *taint-bearing by default*, not discardable. Discarding unknown fields is a declassification with no audit trail. - **Idempotent re-derivation is not assumed.** You may not assume that re-fetching or re-parsing yields the same span. Content equality is not provenance equality. If any of these is absent, the system is enforcing "taint on matching substrings," which is a heuristic, not an invariant, and the egress check is advisory. ## Decision Boundary The operational question at each tool boundary is binary and must be decided *before* the call returns, not after: - **Carry or declassify.** If the tool cannot return a provenance mapping, the caller must either (i) mark the entire output as `join` of all inputs (coarse but sound), or (ii) refuse the call. It must not fall back to content matching. - **Sound vs. precise.** Coarse propagation (whole-output taint) over-taints and may block legitimate egress; precise propagation (span-mapped) risks laundering if the mapping is buggy. The default must be **sound**: when in doubt, taint the whole output. Precision is an optimization gated on a verified mapping, never the default. - **Declassification requires a proof, not a heuristic.** Only a transform whose output is a deterministic function of *untainted* input regions may declassify. "The output looks clean" is not a proof. The boundary is crossed — and laundering becomes possible — the moment a tool is allowed to return content without a label and the caller is allowed to accept it. ## Operational Effect Downstream, the effect is that every egress guard, every auditor consensus check, and every "is this action authorized" decision operates on a taint set that is *systematically under-approximated* at exactly the boundaries where untrusted content is most likely to be transformed into actionable instructions. The guardrail's confidence is inversely related to its soundness: it reports clean most confidently right after the laundering hop. The mitigation is structural, not detective. You cannot reliably detect laundering after the fact by scanning outputs, because the whole point is that the output is indistinguishable from clean content. You must enforce at the boundary: **no tool returns content without a label, and no label shrinks without an audited declassification.** The check below encodes that as a hard failure rather than a silent drop. ```python class TaintLaunderingError(RuntimeError): """Raised when a tool boundary returns content whose taint label is not a superset of the join of its inputs, with no audited declassification proof attached.""" pass def propagate_across_tool_boundary( input_labels: set[str], tool_output: dict, declassification_proof: dict | None = None, ) -> set[str]: """Enforce the monotonic-join invariant at a tool boundary. input_labels: labels present on the arguments passed to the tool. tool_output: must contain 'content' and 'label_set'. 'label_set' is the taint the tool claims for its output. declassification_proof: optional dict with keys {'sanitizer', 'independent_of'} asserting the output was derived only from untainted regions. """ required = set(input_labels) claimed = set(tool_output.get("label_set", [])) # Soundness check: output taint must cover input taint unless a # declassification proof is supplied AND names the removed labels. missing = required - claimed if missing: if declassification_proof is None: raise TaintLaunderingError( f"Tool boundary dropped taint {sorted(missing)} with no " f"declassification proof; output label_set={sorted(claimed)}. " f"Treating as laundering, not as clean." ) proven = set(declassification_proof.get("independent_of", [])) if not missing.issubset(proven): raise TaintLaunderingError( f"Declassification proof does not cover dropped labels " f"{sorted(missing - proven)}; proof only covers {sorted(proven)}." ) # Unknown-field closure: any metadata the serializer discarded is # treated as taint-bearing by default. if tool_output.get("dropped_unknown_fields"): claimed |= required return claimed def guarded_tool_call(tool, args, arg_labels): out = tool(args) if "label_set" not in out: # A tool that returns content without a label is a laundering # surface by construction; refuse rather than guess. raise TaintLaunderingError( f"Tool {getattr(tool, '__name__', tool)!r} returned content " f"without a label_set; cannot verify monotonic join." ) return out["content"], propagate_across_tool_boundary( arg_labels, out, out.get("declassification_proof") ) ```