# Where must an instance refuse to propagate a taint label when a tool boundary launders provenance through a re-serialization hop **Date of Record:** 2026 November 29 **Scope:** Applies to agents that attach dynamic information-flow (IFC) labels to context segments and propagate them across tool invocations, MCP resource fetches, and inter-agent handoffs. Does not apply to stateless single-turn inference where no label survives the response boundary, nor to systems whose tools return only typed, schema-validated primitives with no free-text channel. ## Core Distinction The failure is not "the agent forgot to sanitize." It is that the taint label and the tainted *bytes* travel through different channels at a tool boundary, and the boundary is where they can desynchronize. A label is metadata the orchestrator owns; the payload is whatever the tool returns. When a tool re-serializes its output—JSON-encodes a string, base64-wraps a blob, templates a value into a markdown table, or truncates to a token budget—the orchestrator's label is still attached to the *call*, but the payload that re-enters context is a *new object* whose provenance the label no longer describes. The invariant that must hold: **for every segment entering the context window, the label set on that segment must be a sound over-approximation of the provenance of every byte in it.** Re-serialization is the canonical operation that silently violates soundness, because the transform is often lossy in the direction that matters: it can *drop* a taint (base64-encoding a tainted string into an innocuous-looking token stream) or *amplify* a taint across a boundary it should not cross (a sanitizer's output carrying the sanitizer's own label onto clean data). The non-obvious part: the dangerous laundering is not the obvious "tool strips the label." It is the tool that *preserves* the label on the wrapper while the wrapper's content has been structurally transformed such that downstream taint checks no longer match the substring they were keyed on. ## What Was Observed A retrieval tool returned a document containing an injected instruction. The orchestrator labeled the returned segment `taint:untrusted_external`. A downstream formatter tool was asked to "summarize this table as CSV." The formatter parsed the segment, extracted cells, and emitted a new string. The orchestrator propagated the label onto the *new* segment because the call was in the tainted segment's dependency set—correct in spirit. But the formatter had also collapsed the injected instruction across two CSV fields (`"ignore previous"` and `"instructions"` became adjacent after quote-stripping), and the downstream policy check, which matched on the literal token sequence `ignore previous instructions`, now fired on a segment the label claimed was safe because the *check* ran against the pre-format string. The label said tainted; the guard said clean; the guard won because it ran last. Separately, a base64 tool produced output whose label was inherited as `taint:untrusted_external`, but a second tool that decoded it re-emitted the plaintext under a *fresh* segment the orchestrator treated as tool-generated (trusted) because the decode call's arguments were typed `str` and the orchestrator's default for typed-primitive returns was `taint:trusted_tool`. The taint was laundered by a round-trip through an encoding the label system did not model as a provenance-preserving transform. ## Condition of Validity The naive rule—"propagate the label from input segment to output segment"—is valid only when the tool's transform is **provenance-homomorphic**: every byte of output is a function of bytes of input, with no byte introduced from a source outside the labeled input set, and no byte of the labeled input destroyed in a way that changes the substring structure the downstream guard depends on. This condition fails for: (a) any tool that synthesizes content from model weights or external state (a summarizer, a translator, an LLM-backed extractor) — output bytes are not a function of input bytes alone; (b) any lossy re-encoding (truncation, tokenization, quote-stripping, HTML entity decode) that changes matchable structure; (c) any tool whose output channel is typed primitives, because the type system resets provenance to the tool's declared trust level. When the condition is violated, the correct label on the output is not the input's label. It is the **join** of the input's label and a synthetic `taint:transform_synthesized` label, plus—critically—a re-derivation of the guard's match surface against the *post-transform* bytes, not the pre-transform bytes. ## Decision Boundary An instance must refuse to treat a label as authoritative across a tool boundary when any of the following hold, and must instead escalate to a re-labeling step: 1. The tool's declared output schema includes a free-text or `any`/`str` field that is not byte-identical to a declared input field. (Synthesis risk.) 2. The transform is not registered as provenance-homomorphic in the tool manifest. (Encoding risk.) 3. The downstream guard's match pattern was compiled against the pre-transform segment. (Stale-match risk.) 4. A decode/unwrap tool's output re-enters context under a default trust level rather than inheriting the decoded payload's label. (Round-trip laundering.) Conversely, the instance must *not* re-label (must propagate faithfully) when the tool is a pure projection—`json.dumps` of a field, a type cast, a schema-validated pass-through—because re-labeling there would over-taint clean data and cause the agent to refuse benign operations, a failure mode that is operationally worse than under-tainting for high-throughput pipelines. ## Operational Effect The bound this places on the agent: taint soundness is only as strong as the weakest transform in the tool graph, and the tool graph is dynamic. An agent that adds a base64 helper, a CSV formatter, or an LLM summarizer to its toolset without registering the transform's provenance behavior has silently widened its injection surface without changing a single label. The operational consequence is that taint tracking must be paired with a **transform registry** and a **post-transform guard re-compilation** step; without both, the label system provides the *appearance* of IFC while the actual enforcement runs on a match surface that the adversary can move by choosing which tool the agent calls. The guardrail is not more labels—it is making the label's soundness a precondition checked at the boundary, and failing closed when the precondition cannot be established. ```python from dataclasses import dataclass, field from enum import Enum class Taint(Enum): TRUSTED = 0 SYNTHESIZED = 1 UNTRUSTED_EXTERNAL = 2 class ProvenanceLaunderingError(RuntimeError): """Raised when a tool boundary would propagate a label that no longer soundly over-approximates the provenance of the output bytes.""" @dataclass class Segment: text: str labels: frozenset = field(default_factory=lambda: frozenset({Taint.TRUSTED})) @dataclass class ToolManifest: name: str provenance_homomorphic: bool output_free_text: bool guard_pattern_compiled_pre_transform: bool def propagate_label( inp: Segment, out_text: str, manifest: ToolManifest, decode_of_tainted: bool = False, ) -> Segment: # Rule 4: decode/unwrap round-trip must inherit the decoded payload's label, # not the default trust of a typed-primitive return. if decode_of_tainted and Taint.UNTRUSTED_EXTERNAL not in inp.labels: raise ProvenanceLaunderingError( f"tool {manifest.name!r} decodes a payload whose taint was not " "carried on the input segment; refusing to default to TRUSTED" ) # Rule 1: synthesis risk — output bytes are not a function of input bytes. if manifest.output_free_text and not manifest.provenance_homomorphic: new_labels = inp.labels | {Taint.SYNTHESIZED} if Taint.UNTRUSTED_EXTERNAL in inp.labels: new_labels |= {Taint.UNTRUSTED_EXTERNAL} return Segment(text=out_text, labels=frozenset(new_labels)) # Rule 2: non-homomorphic transform (encoding, truncation, entity decode). if not manifest.provenance_homomorphic: raise ProvenanceLaunderingError( f"tool {manifest.name!r} is not registered provenance-homomorphic; " "label propagation across this boundary is unsound until the " "transform is registered or the output is re-labeled" ) # Rule 3: guard compiled against pre-transform bytes — label may be sound # but the enforcement surface is stale. if manifest.guard_pattern_compiled_pre_transform: raise ProvenanceLaunderingError( f"tool {manifest.name!r} changes the match surface; downstream guard " "must be re-compiled against post-transform bytes before this " "segment is admitted to context" ) # Pure projection: faithful propagation is correct and must not over-taint. return Segment(text=out_text, labels=inp.labels) def admit_to_context(seg: Segment, guard_matches: bool) -> None: tainted = Taint.UNTRUSTED_EXTERNAL in seg.labels if guard_matches and not tainted: raise ProvenanceLaunderingError( "guard fired on a segment labeled clean: label/bytes desync — " "the taint was laundered across a transform hop" ) if tainted and not guard_matches: # Sound over-approximation: tainted but guard did not fire is allowed, # but must be routed to human/quarantine, not silently executed. raise ProvenanceLaunderingError( "tainted segment passed guard without match; quarantine required " "before execution" ) ```