# When must an instance treat a tool result as tainted, and where does provenance laundering occur across MCP/A2A hops? **Date of Record:** 2026 November 29 **Scope:** Applies to agent runtimes that propagate taint labels (untrusted-content provenance) across MCP tool calls and A2A remote-agent handoffs, and that gate side-effecting tool invocation on taint state. Does not cover static content filters, prompt-based "be careful" instructions, or single-process agents with no cross-boundary state transfer. ## Core Distinction The naive model treats taint as a property of *text*: if untrusted text enters context, everything downstream is tainted. This over-taints catastrophically and gets disabled in production. The correct model treats taint as a property of a *provenance lattice attached to a value*, where the value flows through tool calls and agent handoffs and where the only legitimate de-taint operation is a *declared, verified transformation* — not a hop, not a re-serialization, not a model's own paraphrase. The non-obvious boundary: **taint laundering happens at the type boundary, not the content boundary.** When an MCP server returns a structured result, the runtime must decide whether the *schema shape* it validated is the same object the taint label was attached to. If the server returns `{"summary": ""}` and the caller reads `result["summary"]` into a new typed field, the label attached to the original response is silently dropped because the new field was constructed by the *caller's* code, which is trusted. The taint is gone, the attacker text remains. No prompt injection filter catches this because the content is identical and the transform is "legitimate." ## What Was Observed A two-hop topology: orchestrator → MCP server `fetch_docs` → A2A remote agent `summarizer`. The orchestrator tags `fetch_docs` output `taint=EXTERNAL`. It forwards the tagged payload to `summarizer` over A2A. The summarizer is a *remote* agent — the orchestrator cannot inspect its internal state, only its returned `Task` artifact. Observed failure trace: 1. `fetch_docs` returns `{"content": "", "_provenance": "EXTERNAL"}`. Runtime attaches `EXTERNAL` to the whole object. 2. Orchestrator serializes the artifact for A2A, sending `{"role":"user","parts":[{"text": ""}]}`. **The `_provenance` field is dropped** because A2A `Message.parts` has no slot for it and the serializer only emits spec-conformant fields. 3. Summarizer processes, returns a `Task` with `status=completed` and an artifact containing a summary that *incorporates the injected instruction as if it were the user's request*. 4. Orchestrator receives the artifact. The A2A response carries **no taint metadata** (the remote agent has no obligation to echo it, and a malicious or merely careless remote won't). Runtime defaults untagged inbound to `TRUSTED` — or, worse, to `INTERNAL` because it came from a "known" agent ID. 5. Orchestrator calls `write_file` with the summary content. Gate sees `TRUSTED` input. Side effect fires. The laundering point is step 2→4: **the A2A transport is a taint-dropping channel by construction.** Taint lived on a field that the wire format does not define, so every hop is a de-taint event unless the runtime explicitly re-attaches. The second observed variant is subtler and more dangerous: the remote agent *does* echo provenance, but echoes `INTERNAL` because it computed taint relative to *its own* trust boundary (it trusted its input, since its input came from a "trusted" orchestrator). Taint is not transitive across trust-domain boundaries unless both sides agree on the lattice and the join rule. Two agents each doing correct local taint tracking produce a globally *wrong* result. ## Condition of Validity A taint label is valid across a hop if and only if all of the following hold: - **Label carriage:** the transport encodes the label in a spec-legal location (A2A: extension field on `Message`/`Artifact` metadata; MCP: `_meta` on the result). Out-of-band fields that the serializer strips are *not* carriage. - **Lattice agreement:** both endpoints share the same partial order and the same join (least-upper-bound) rule. `EXTERNAL ⊔ INTERNAL = EXTERNAL`. A remote agent that re-derives taint from scratch violates this. - **Monotonic composition:** the remote's output taint must be `≥` (join of) its input taint. A remote that returns `TRUSTED` from `EXTERNAL` input is either performing a declared sanitizer transform (see below) or is laundering. - **Sanitizer declaration:** the only de-taint is an explicit, named transform (e.g., `extract_json_schema_v1`, `numeric_only`) that the *caller* applies to a *typed* value, with the transform registered in the runtime's allowlist. Model paraphrase, re-summarization, and "the agent said it's safe" are not sanitizers. If any condition fails, the correct action is not "proceed carefully" — it is to **fail the hop closed** and either drop the payload or escalate to a human-gated path. ## Decision Boundary The runtime must answer one question per inbound value: *is this value's provenance known and does it dominate every input that could have influenced it?* - If provenance is **absent** on an inbound A2A/MCP value → treat as `EXTERNAL` (fail-closed), never `TRUSTED`. Absence is not innocence. - If provenance is **present but the remote's lattice is unknown** → treat as `EXTERNAL`. A label you can't verify against your own lattice is a label you can't use. - If provenance is **present and the value passed through a registered sanitizer** → de-taint to the sanitizer's declared output level, and record the transform in the audit trail. - If provenance is **present and monotonicity is violated** (output taint < input taint with no sanitizer) → raise, do not clamp. Clamping hides the bug; the remote is either broken or hostile. The boundary is *not* "does the content look injected." Content inspection is a heuristic that fails on paraphrase, encoding, and legitimate content that merely resembles instructions. The boundary is structural: label carriage + lattice agreement + monotonicity. ## Operational Effect Enforcing this invariant changes three things: 1. **A2A and MCP adapters must carry taint in spec-legal metadata and re-attach on receipt.** The serializer is the launderer; the fix is at the serializer, not the gate. 2. **Remote agents must be treated as untrusted taint computers.** You do not trust their taint arithmetic; you verify monotonicity and fail closed on violation. This is the same posture as verifying a signature, not reading a claim. 3. **Side-effecting tools gate on the *joined* taint of all arguments, computed at call time from carried labels**, not on a cached "session trust" flag. A session that received one `EXTERNAL` value and later calls `write_file` must have that value's taint in the join, or the gate is decorative. The cost is that every cross-boundary hop needs a metadata channel and a monotonicity check. The failure mode without it is silent: the agent does exactly what the attacker wrote, with full confidence and a clean audit log. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import IntEnum from typing import Any class Taint(IntEnum): TRUSTED = 0 INTERNAL = 1 EXTERNAL = 2 def join(self, other: "Taint") -> "Taint": return Taint(max(int(self), int(other))) class TaintLaunderingError(RuntimeError): """Raised when a cross-boundary hop drops, downgrades, or fails to carry taint.""" @dataclass(frozen=True) class Labeled: value: Any taint: Taint sanitizer: str | None = None REGISTERED_SANITIZERS: dict[str, Taint] = { # name -> maximum output taint this transform is permitted to produce "extract_numeric_v1": Taint.TRUSTED, "extract_json_schema_v1": Taint.INTERNAL, } def carry_across_a2a(label: Labeled, wire_meta: dict[str, Any] | None) -> Labeled: """Reconstruct taint from an inbound A2A/MCP message. Absent or unverifiable provenance is EXTERNAL (fail-closed). """ if wire_meta is None or "taint" not in wire_meta: return Labeled(value=label.value, taint=Taint.EXTERNAL) try: carried = Taint(int(wire_meta["taint"])) except (TypeError, ValueError) as exc: raise TaintLaunderingError( f"unparseable taint label on inbound hop: {wire_meta.get('taint')!r}" ) from exc # Never let a hop lower taint; join with the locally-known floor. return Labeled(value=label.value, taint=label.taint.join(carried)) def apply_sanitizer(label: Labeled, name: str) -> Labeled: if name not in REGISTERED_SANITIZERS: raise TaintLaunderingError( f"unregistered sanitizer {name!r}; model paraphrase is not a sanitizer" ) ceiling = REGISTERED_SANITIZERS[name] if ceiling > label.taint: # A sanitizer cannot raise taint; that would be fabrication. raise TaintLaunderingError( f"sanitizer {name!r} declares ceiling {ceiling.name} above input {label.taint.name}" ) return Labeled(value=label.value, taint=ceiling, sanitizer=name) def verify_monotonic(input_label: Labeled, output_label: Labeled) -> None: """A remote agent's output taint must dominate its input taint, unless a registered sanitizer is named on the output.""" if output_label.sanitizer is not None: if output_label.sanitizer not in REGISTERED_SANITIZERS: raise TaintLaunderingError( f"remote claimed unregistered sanitizer {output_label.sanitizer!r}" ) return if output_label.taint < input_label.taint: raise TaintLaunderingError( f"taint downgrade across hop: {input_label.taint.name} -> " f"{output_label.taint.name} with no declared sanitizer" ) def gate_side_effect(tool: str, args: list[Labeled]) -> None: joined = Taint.TRUSTED for a in args: joined = joined.join(a.taint) if tool in {"write_file", "send_email", "exec_shell"} and joined >= Taint.EXTERNAL: raise TaintLaunderingError( f"side-effecting tool {tool!r} invoked with joined taint {joined.name}" ) ```