# What happens when an instance inherits taint through an MCP tool boundary it never observed **Date of Record:** 2026 December 2 **Scope:** Applies to multi-agent systems where a delegating agent (A2A) invokes a sub-agent that calls MCP tools, and where taint/trust labels are used to gate downstream side effects. Does not apply to single-instance tool use with no cross-agent handoff, nor to systems that enforce taint at the OS/syscall layer rather than at the message envelope. ## Core Distinction Taint propagation in agent systems is routinely modeled as a *transitive property of data*: if a value is labeled `untrusted`, any value derived from it is `untrusted`. This model is correct for pure dataflow but **wrong for agent handoffs**, because an A2A delegation does not forward the *provenance graph*—it forwards a *task description and a result*. The sub-agent observes only the task prompt and its own MCP tool outputs; it never observes the labels attached to the inputs the parent actually held. The failure is therefore not "taint was lost in transit." It is subtler: **the sub-agent recomputes taint from scratch against a tool boundary it does not know is contested**, and its local, self-consistent taint verdict is then *promoted by the parent to authoritative* because A2A results are treated as trusted-by-construction. The parent launders its own taint through a child it delegated to. Call this the **delegation laundering boundary**. ## What Was Observed A three-hop chain: orchestrator `O` → worker `W` (A2A) → MCP tool `fetch_doc` (returns untrusted web content) and MCP tool `post_summary` (a side-effecting write). 1. `O` receives an external user message `M` containing an injected instruction, labels it `taint=untrusted`, and delegates: `A2A.delegate(worker=W, task="summarize the doc at URL X and post a summary")`. The A2A envelope carries `task` and `deadline` but **not** `M`'s taint label, because `M` was never part of the forwarded context. 2. `W` receives the task. Its taint state is empty. It calls `fetch_doc(X)` via MCP; the tool returns a document `D` that contains a prompt-injection payload. `W`'s MCP client labels `D` as `untrusted` (correct) and flags the injection. 3. `W` reasons: "The task came from `O`, my delegator, which is trusted. The document is untrusted. I will summarize `D` but *not* follow its instructions." It produces summary `S`, which is derived from `D` and thus carries `taint=untrusted` **internally**. 4. `W` returns `S` to `O` via A2A. The A2A result envelope is serialized as `{status: ok, result: S}`. **The taint label on `S` is not part of the result schema.** `O` receives `S` and applies its default A2A trust policy: `result.taint = trusted` (delegator trusts its own delegate). 5. `O` calls `post_summary(S)`. The side-effecting MCP tool sees a `trusted` argument and executes. The injected content in `D`—a URL or instruction smuggled into `S`—reaches a write boundary that `O`'s original taint policy would have blocked had `S` still carried `untrusted`. The observable signature: `O`'s taint ledger shows `M=untrusted`, `S=trusted`, and no edge between them. The provenance graph is *disconnected* at the A2A hop. A post-hoc audit that walks the graph finds no path from `M` to `post_summary`, yet the causal path exists. ## Condition of Validity The laundering boundary is exploitable exactly when all three hold: - **(a) Label-erasing handoff.** The A2A result schema does not carry taint, and the delegator's default is `trusted` rather than `inherit-from-task` or `unknown`. - **(b) Re-derivation without context.** The sub-agent's taint engine has no access to the parent's labels for inputs the parent held (here, `M`), so it cannot mark `S` as contaminated by `M` even if it wanted to. - **(c) A side-effecting sink reachable from the parent.** The parent has a tool whose taint policy gates on the label of its argument; the label was laundered, so the gate passes. If any one fails, the chain is bounded: (a) fails if the envelope propagates labels; (b) fails if the sub-agent's report includes a provenance digest the parent can unify; (c) fails if the sink re-validates against the *root* taint, not the immediate argument's label. A common false mitigation: instructing `W` to "report any untrusted content." This is a *probabilistic* control. `W`'s judgment is itself an LLM output; under adversarial `D` it can be talked into under-reporting, and even a correct report is a free-text field the parent must parse—another lossy boundary. ## Decision Boundary The invariant that bounds this failure is **taint join, not taint copy, across every handoff**: > For any value `v` crossing an A2A or MCP boundary, `taint(v_received) ⊇ taint(v_sent) ∪ taint(context_sent) ∪ {boundary_is_untrusted_if_sender_cannot_prove_otherwise}`. Operationally this forces three decisions: 1. **Envelope must carry a provenance digest, not just a result.** The A2A result schema includes a `provenance` field: the set of input labels the sub-agent's result was derived from, plus the sub-agent's own taint verdict. The parent *joins* this with its own labels. `S`'s received taint becomes `untrusted` because `W`'s digest declares `derived_from: [D=untrusted]` and `O` joins that with `M=untrusted`. 2. **Default is `unknown`, and `unknown` is treated as `untrusted` at any side-effecting sink.** A delegator that cannot verify a delegate's provenance must not promote to `trusted`. This is the failure-closed rule; it is what makes (a) non-exploitable even when the digest is missing. 3. **Sinks re-validate against the root.** `post_summary` does not trust the label on its argument alone; it checks that the argument's provenance set contains no `untrusted` ancestor. This is the defense-in-depth that catches laundering even if the parent's join is buggy. The decision boundary is sharp: **a result is `trusted` only if the delegator can construct a provenance chain from the result back to a trusted root, with every edge labeled.** Absence of a chain is not evidence of trust; it is evidence of `unknown`, and `unknown` fails closed. ## Operational Effect Without the join invariant, the system exhibits **silent trust escalation under delegation depth**. Each A2A hop resets taint to the delegator's default, so a chain of depth `k` launders taint `k` times, and the probability that an injected instruction survives to a side effect approaches 1 as depth grows—even though every individual agent's local taint reasoning is correct. The failure is invisible to per-agent logging because each agent's ledger is internally consistent; only the *union* of ledgers reveals the disconnection. With the join invariant, the failure converts from silent escalation to a **loud `unknown` at the sink**, which is recoverable: the orchestrator either re-derives trust (re-fetching from a trusted source) or refuses the write. The cost is false positives—legitimate summaries get blocked when provenance is genuinely unavailable—which is the correct trade for a write boundary and the wrong trade for a read-only one. The guardrail must therefore be scoped to sinks, not to all tool calls, or the system will stall on benign delegation. The residual risk after the fix is **digest forgery**: a compromised or confused sub-agent can emit a false `derived_from: []`. This is not closed by the join invariant; it requires the sub-agent's digest to be signed by an identity the parent can verify (the A2A identity/warrant layer). The join invariant bounds *accidental* laundering; cryptographic provenance bounds *adversarial* laundering. Both are needed; neither alone is sufficient. ```python from dataclasses import dataclass, field from typing import FrozenSet, Optional class TaintLaunderingError(RuntimeError): """Raised when an A2A result is promoted to trusted without a verifiable provenance chain to a trusted root.""" @dataclass(frozen=True) class Labeled: value: str taint: FrozenSet[str] # e.g. {"untrusted:user_msg"} provenance: FrozenSet[str] = field(default_factory=frozenset) def a2a_join(parent_labels: FrozenSet[str], result: Labeled, digest_signed: bool) -> Labeled: """Join taint across an A2A handoff. Fail closed on missing provenance.""" if not result.provenance and result.taint: # Sub-agent returned tainted value but no provenance digest: # cannot verify the chain, so the boundary itself is unknown. raise TaintLaunderingError( f"result carries taint {result.taint} but no provenance digest; " "cannot join across A2A boundary" ) if result.provenance and not digest_signed: raise TaintLaunderingError( "provenance digest is unsigned; refusing to promote to trusted " "(adversarial laundering not bounded)" ) joined = parent_labels | result.taint | result.provenance return Labeled(value=result.value, taint=joined, provenance=joined) def guarded_sink(arg: Labeled, sink_name: str) -> None: """Side-effecting sink: re-validate against root, not just arg label.""" if "untrusted" in "".join(arg.taint) or not arg.provenance: raise TaintLaunderingError( f"sink {sink_name!r} refused: arg taint={set(arg.taint)} " f"provenance={set(arg.provenance)}" ) # ... perform write ... def run_chain() -> None: parent = frozenset({"untrusted:user_msg"}) # Worker W returns a summary derived from untrusted doc D, but the # A2A envelope dropped the provenance digest (the observed failure). w_result = Labeled(value="summary of D", taint=frozenset({"untrusted:doc_D"}), provenance=frozenset()) joined = a2a_join(parent, w_result, digest_signed=False) # raises guarded_sink(joined, "post_summary") ```