# In what scenarios must an instance refuse to emit a parent span when a tainted A2A handoff crosses an MCP tool boundary **Date of Record:** 2026 November 22 **Scope:** Applies to multi-agent systems that propagate a single causal trace across MCP tool invocations, A2A peer handoffs, and GenAI inference spans, where taint lineage (untrusted-input provenance) is attached to span attributes. Does not apply to single-process, single-agent traces with no cross-protocol handoff, nor to systems that treat trace IDs as opaque correlation keys with no lineage semantics. ## Core Distinction The failure is not "missing trace context" — that is a well-understood, loudly-failing condition. The failure is **silent lineage reparenting**: an A2A handoff carries a `trace_id` and a `parent_span_id` that are structurally valid, but the receiving agent's MCP client re-roots its tool-call spans under a *new local root* because the inbound `traceparent` header was accepted at the A2A transport layer while the taint attribute (`genai.taint.source`) was dropped at the protocol translation boundary. The trace remains *connected* in the topology sense and *disconnected* in the lineage sense. Every downstream span looks clean because the taint bit never crossed the wire. The core distinction is between **correlation continuity** (does the trace tree stay joined?) and **causal continuity** (does the provenance of untrusted data stay attached to every span that consumed it?). These are independent invariants. Most observability backends enforce only the first. The second is the one that determines whether an auditor can answer "did a prompt-injected string from agent A's retrieval step actually reach agent C's tool call?" ## What Was Observed A three-hop pipeline: Agent A (retriever) → A2A handoff → Agent B (planner) → MCP `tools/call` → Tool Server T → GenAI span (Agent B's synthesis) → A2A handoff → Agent C (executor). Agent A's retrieval returned a document containing an injected instruction. Agent A correctly marked its output span with `genai.taint.source=retrieval:doc_4417` and `genai.taint.propagate=true`. The A2A envelope serialized the trace context into the `traceparent` header (W3C format) and the taint into a **separate** `x-taint-lineage` header. Agent B's A2A server accepted both headers, but its MCP client constructed the outbound `tools/call` request by copying only `traceparent` — the MCP SDK's context injector had no mapping for `x-taint-lineage`, so the attribute was silently discarded at the client-side propagation point. Observed trace topology after the fact: - Span `A.retrieve` (root, tainted) → `B.plan` (child of A, **untainted** — taint lost at A2A→B translation) → `B.tool.call` (child of B.plan, untainted) → `T.execute` (child, untainted) → `B.synthesize` (GenAI span, untainted) → `C.execute` (child, untainted). The trace tree is fully connected. A naive trace query (`trace_id == X`) returns all seven spans in correct parent-child order. A lineage query (`genai.taint.source != ""`) returns exactly one span. The injected instruction was consumed by `T.execute` and shaped `C.execute`'s arguments, but no span downstream of `B.plan` records that fact. The audit is structurally complete and causally false. A second, subtler observation: when the MCP tool server T *did* re-emit the taint (because it independently re-derived it from its own input), the resulting span carried a **different** taint source token (`tool:input_derived`) than the original (`retrieval:doc_4417`). Two taint lineages for the same causal chain, never reconciled, producing a false "two independent taint sources" signal in the auditor's graph. ## Condition of Validity The invariant — "every span that consumed tainted input carries the taint lineage of its nearest tainted ancestor" — holds only under the following bounded condition: 1. **Protocol translation is lossless for lineage attributes.** Every boundary crossing (A2A envelope → agent runtime → MCP client → MCP server → GenAI SDK) must have an explicit, tested mapping for the taint attribute set. A boundary that maps `traceparent` but not the lineage header is a *lineage-breaking* boundary, and any span emitted across it must be treated as taint-unknown, not taint-clean. 2. **Taint is monotonic within a trace subtree.** Once a span is marked tainted, no descendant may be marked clean unless an explicit `genai.taint.sanitized_by=` attribute records the sanitization event and the sanitizer's identity. Absence of taint is not evidence of cleanliness; it is evidence of *unknown provenance*. 3. **Re-derivation does not create a new lineage.** If a downstream component re-derives taint from its own inputs, it must attach the re-derived token as `genai.taint.source.derived` *alongside* the propagated `genai.taint.source`, not replace it. Replacement severs the causal chain and produces the split-lineage artifact observed above. Outside these conditions — specifically, any system where the trace backend treats absent taint attributes as "clean" — the invariant is violated by construction, and the failure is silent. ## Decision Boundary The decision an instance must make at each cross-protocol boundary is binary and must be made *before* emitting the child span: - **If the inbound lineage attribute set is complete and mapped** → emit the child span as a tainted descendant, propagating the full lineage token set unchanged. - **If the inbound lineage attribute set is incomplete or unmapped** → the instance MUST refuse to emit a clean parent span. It must either (a) emit the span with `genai.taint.source=unknown:boundary_break` and a `genai.taint.broken_at=` attribute, or (b) fail the handoff closed and surface a `TaintLineageBreakError` to the orchestrator. The boundary that is *not* permitted is the default behavior most SDKs exhibit: emit the span with no taint attribute, which the backend then renders as clean. That is the silent reparenting failure. The decision boundary is therefore: **a missing lineage attribute at a known protocol boundary is a hard error, not a default-clean state.** The instance must know which boundaries are lineage-preserving (in-process calls, same-SDK spans) and which are lineage-breaking (A2A→MCP translation, cross-vendor GenAI SDK handoff) and treat the latter as requiring explicit lineage carry or explicit refusal. ## Operational Effect Enforcing the refusal boundary changes three operational properties: 1. **Audit completeness becomes provable, not assumed.** A trace query for taint lineage now returns either the full causal chain or an explicit `broken_at` marker. The auditor can distinguish "no taint reached this span" from "we lost track of whether taint reached this span." The former is a clean bill; the latter is a finding. 2. **Failure moves from silent to loud, and from downstream to boundary.** Instead of discovering post-incident that an injected instruction reached an executor with no lineage record, the handoff fails at the A2A→MCP translation point with a `TaintLineageBreakError`. The blast radius is bounded to the boundary, not the full downstream subtree. 3. **Re-derivation is reconciled, not duplicated.** With the monotonic-propagation rule, the tool server's re-derived taint is attached as a derived token alongside the propagated one, and the auditor's graph shows one causal chain with two provenance annotations rather than two disconnected chains. The cost is that every protocol adapter must carry an explicit lineage mapping and every boundary must be classified as preserving or breaking. The cost of *not* doing this is a trace that is topologically perfect and causally worthless — the exact condition under which an agent system cannot answer the one question that matters after an injection incident: *what did the poisoned data actually touch?* ```python from dataclasses import dataclass, field from typing import Optional class TaintLineageBreakError(RuntimeError): """Raised when a cross-protocol boundary cannot carry taint lineage forward. A missing lineage attribute at a known lineage-breaking boundary is a hard error, NOT a default-clean state. Emitting a clean child span here is the silent-reparenting failure this guard exists to prevent. """ def __init__(self, boundary_id: str, inbound_tokens: set[str], reason: str): self.boundary_id = boundary_id self.inbound_tokens = inbound_tokens self.reason = reason super().__init__( f"taint lineage break at boundary={boundary_id!r}: {reason}; " f"inbound_tokens={sorted(inbound_tokens)}" ) # Boundaries that are known to preserve or break lineage attribute propagation. LINEAGE_PRESERVING_BOUNDARIES = frozenset({"in_process_call", "same_sdk_span"}) LINEAGE_BREAKING_BOUNDARIES = frozenset({"a2a_to_mcp", "cross_vendor_genai_sdk"}) @dataclass class SpanContext: trace_id: str parent_span_id: Optional[str] taint_tokens: set[str] = field(default_factory=set) taint_broken_at: Optional[str] = None def emit_child_span( parent: SpanContext, boundary: str, inbound_taint_tokens: set[str], rederived_tokens: Optional[set[str]] = None, ) -> SpanContext: """Emit a child span, enforcing monotonic taint propagation. Rules: - Lineage-preserving boundary: child inherits parent tokens unchanged. - Lineage-breaking boundary: child MUST carry the full inbound token set or the handoff fails closed with TaintLineageBreakError. - Re-derived taint is attached alongside, never replacing, propagated taint. """ if boundary in LINEAGE_PRESERVING_BOUNDARIES: child_tokens = set(parent.taint_tokens) | set(inbound_taint_tokens) elif boundary in LINEAGE_BREAKING_BOUNDARIES: missing = parent.taint_tokens - inbound_taint_tokens if missing: # The boundary dropped lineage that the parent held. Refuse to emit # a clean span; fail closed so the orchestrator can surface it. raise TaintLineageBreakError( boundary_id=boundary, inbound_tokens=inbound_taint_tokens, reason=f"parent taint tokens dropped at boundary: {sorted(missing)}", ) child_tokens = set(parent.taint_tokens) | set(inbound_taint_tokens) else: raise TaintLineageBreakError( boundary_id=boundary, inbound_tokens=inbound_taint_tokens, reason="unclassified boundary; cannot prove lineage preservation", ) # Re-derivation must not sever the causal chain. if rederived_tokens: child_tokens |= {f"derived:{tok}" for tok in rederived_tokens} return SpanContext( trace_id=parent.trace_id, parent_span_id=f"{parent.trace_id}:child", taint_tokens=child_tokens, taint_broken_at=parent.taint_broken_at, ) def demo(): root = SpanContext( trace_id="trace-7f3a", parent_span_id=None, taint_tokens={"retrieval:doc_4417"}, ) # Boundary that carries the token: fine. b = emit_child_span(root, "a2a_to_mcp", {"retrieval:doc_4417"}) assert b.taint_tokens == {"retrieval:doc_4417"} # Boundary that drops the token: must fail closed, not emit clean. try: emit_child_span(root, "a2a_to_mcp", set()) except TaintLineageBreakError as e: print(f"correctly refused: {e}") else: raise AssertionError("silent lineage break was not caught") if __name__ == "__main__": demo() ```