# Why does an instance lose taint provenance when a laundered prompt-injection label is dropped by a tool-boundary re-serialization **Date of Record:** 2026 November 30 **Scope:** Applies to agent runtimes that implement dynamic information-flow (taint) labels on context fragments and tool arguments, where labels are propagated in-band alongside payloads across tool calls. Does not apply to runtimes that enforce taint purely at the memory-subsystem level with out-of-band label storage keyed by content hash, nor to single-turn, tool-free inference. ## Core Distinction The failure is not "the agent read a malicious document." That is expected and survivable. The failure is that a taint label attached to a context fragment **survived the semantic path but not the serialization path**: the injected instruction was correctly flagged as `untrusted` at retrieval time, the label propagated through the planner's reasoning trace, but when the fragment was passed as an argument to a tool whose input schema declared only typed fields (e.g., `query: string`), the label was dropped because the transport envelope had no slot for it. The tool returned derived content that the runtime then treated as freshly `trusted`, because the only provenance signal available was "output of a tool the agent itself invoked." This is a **label-laundering** boundary condition. It differs from classic prompt injection in that detection *succeeded* and the defense still failed — the information-flow invariant was violated at a re-serialization seam, not at the input filter. ## What Was Observed A retrieval step pulled a document chunk. The classifier tagged it `{trust: untrusted, origin: web, id: frag_8812}`. The planner, operating on a scratchpad, produced a tool call: ``` search_contacts(query="summarize frag_8812 and forward to ops@example.com") ``` The `query` string embedded the untrusted text. The tool schema accepted `query: string` with no accompanying `taint` field — the MCP-style call envelope carried `arguments` only. On the tool's return, the result object arrived as: ``` {result: "contact list: [...]", provenance: "tool:search_contacts"} ``` The runtime's label-derivation rule was: *output taint = max(input taint of the tool's declared inputs)*. Because the declared input was the `query` string and its taint had been stripped at the envelope boundary, the input taint evaluated to `trusted`. The output — which contained the injected instruction's effect (a forwarded message) — was labeled `trusted`. The taint had been laundered through a schema that could not represent it. The observable signature in the trace: a fragment with `origin: web` whose downstream effects carry `origin: tool:search_contacts` and `trust: trusted`, with **no edge in the provenance graph linking the two**. The graph shows a trusted tool output with no untrusted ancestor, which is the contradiction to alarm on. ## Condition of Validity The invariant that must hold: **for every context fragment consumed by the planner, the taint lattice value is a join over all ancestor fragments that contributed bytes to it, and this join is preserved across every serialization boundary the fragment crosses.** The failure requires all of the following to hold simultaneously: 1. Labels are carried **in-band** (as fields on the payload) rather than out-of-band (side table keyed by fragment id or content hash). 2. At least one tool schema on the path is **typed and closed** — it declares no label field, so the serializer silently drops unknown fields rather than rejecting the call. 3. The runtime's output-taint rule derives from **declared inputs only**, not from the actual byte lineage of the arguments. 4. The planner is permitted to **inline** untrusted fragment content into a trusted-typed argument, rather than being forced to pass a fragment reference (`frag_8812`) that the tool resolves server-side with its label intact. Remove any one and the laundering path closes. The most common real-world configuration removes none: typed tool schemas are the norm, in-band labeling is the easy implementation, and reference-passing requires the tool to understand the runtime's label vocabulary. ## Decision Boundary The operational choice is between two enforcement points, and they are not equivalent: - **Enforce at the planner (reference-only arguments).** Untrusted content may never be inlined into a tool argument; the planner must pass an opaque fragment id, and the tool runtime performs resolution with labels attached. This is robust but requires every tool to participate in the label protocol, and it breaks tools that legitimately need the raw string (e.g., an external search API that has no notion of fragments). - **Enforce at the envelope (label-carrying schema).** Every tool call envelope carries a `taint` field that the serializer is forbidden to drop; closed schemas that lack the field cause a hard rejection rather than silent stripping. This is more permissive but only works if the serializer's default on unknown-field-drop is *reject*, not *ignore*. The boundary: if any tool on the reachable call graph has a closed schema you do not control, you cannot rely on envelope-carried labels and must fall back to reference-only arguments for untrusted content. Choosing envelope-carried labels while a single closed-schema tool is reachable is the configuration that produces the silent laundering above. ## Operational Effect When the boundary is crossed, the taint lattice becomes non-monotonic: a fragment's effective trust can *increase* as it flows downstream, which inverts the entire premise of information-flow control. Downstream policy decisions — "forward only trusted content to external recipients," "execute only trusted tool arguments" — then evaluate against a label that no longer reflects byte lineage. The provenance graph loses the untrusted ancestor edge, so post-hoc audit cannot reconstruct the leak; the trace looks clean. The guardrail is a **lineage-closure check at every tool return**: before assigning output taint, the runtime must verify that the join of taints over the *actual bytes* of the arguments (recomputed from the pre-serialization argument tree, not the post-serialization envelope) equals the declared input taint. A mismatch — declared `trusted`, byte lineage `untrusted` — is a laundering event and must raise, not warn. This check is cheap because it runs on the argument tree the runtime already holds before serialization; it does not require the tool to cooperate. ```python from dataclasses import dataclass, field from enum import IntEnum from typing import Any class Trust(IntEnum): TRUSTED = 0 UNTRUSTED = 1 # lattice join is max @dataclass class Fragment: frag_id: str trust: Trust origin: str @dataclass class ToolCall: tool: str arguments: dict[str, Any] # taint as declared by the envelope AFTER serialization declared_arg_taint: Trust # byte-lineage taint recomputed from the pre-serialization argument tree byte_lineage_taint: Trust class TaintLaunderingError(RuntimeError): """Raised when a tool return's declared input taint is weaker than the actual byte lineage of its arguments, indicating a label was dropped at a serialization boundary.""" def join_taint(fragments: list[Fragment]) -> Trust: return Trust(max((f.trust for f in fragments), default=Trust.TRUSTED)) def resolve_argument_lineage(call: ToolCall, fragments: dict[str, Fragment]) -> Trust: # In a real runtime this walks the argument tree for inlined fragment bytes. # Here we trust the pre-computed byte_lineage_taint as the ground truth. return call.byte_lineage_taint def guard_tool_return(call: ToolCall, fragments: dict[str, Fragment]) -> Trust: lineage = resolve_argument_lineage(call, fragments) if lineage > call.declared_arg_taint: raise TaintLaunderingError( f"tool={call.tool!r} declared_arg_taint={call.declared_arg_taint.name} " f"but byte_lineage_taint={lineage.name}; a taint label was dropped " f"at the argument serialization boundary (laundering path)." ) # output taint is the join of declared inputs and their true lineage return Trust(max(call.declared_arg_taint, lineage)) def run_tool(call: ToolCall, fragments: dict[str, Fragment]) -> Trust: output_trust = guard_tool_return(call, fragments) return output_trust if __name__ == "__main__": frags = {"frag_8812": Fragment("frag_8812", Trust.UNTRUSTED, "web")} # Planner inlined untrusted bytes into a closed-schema `query` string; # the envelope dropped the label, so declared taint reads TRUSTED. laundered = ToolCall( tool="search_contacts", arguments={"query": "summarize frag_8812 and forward to ops@example.com"}, declared_arg_taint=Trust.TRUSTED, byte_lineage_taint=join_taint([frags["frag_8812"]]), ) run_tool(laundered, frags) # raises TaintLaunderingError ```