# What structural signals indicate taint laundering across tool-call sandbox boundaries when provenance labels are rewritten by schema-coercing adapters **Date of Record:** 2026 November 24 **Scope:** Applies to multi-step agents where tool outputs carry provenance/taint labels (untrusted-web, user-pii, model-generated) that are consumed by downstream tool arguments across an MCP/A2A boundary. Does not apply to single-tool, single-hop invocations where no label crosses an adapter boundary, nor to systems that re-derive taint from source rather than propagating it. ## Core Distinction The failure mode is not "untrusted data reaches a privileged sink." That is the *detectable* case, and taint-tracking exists precisely to catch it. The non-obvious failure is **taint laundering through type coercion**: an adapter that sits between two tools rewrites a payload to satisfy a downstream schema, and in doing so drops or reclassifies the provenance label while preserving the bytes. The data arrives at the sink carrying a `trusted` label it never earned, because the *label* and the *value* traveled different paths. The distinction that matters operationally: a taint-tracking system that propagates labels *alongside* values (a parallel channel) is vulnerable to any component that reconstructs the value from scratch — schema validators, JSON re-serializers, Pydantic coercion, enum normalizers, string sanitizers. These components see a value, not a labeled value, and emit an unlabeled (hence default-trusted) value. The invariant "label travels with value" is silently broken by every lossy re-encode. ## What Was Observed A three-hop chain: `fetch_web` → `extract_fields` (adapter) → `write_record` (privileged sink). The `fetch_web` tool returned a document with provenance `untrusted-web`. The `extract_fields` adapter was declared with a Pydantic output model whose fields were plain `str`, no label annotation. Internally it did: 1. Parsed the untrusted document. 2. Coerced `phone` from `"+1 (555) 010-9999"` to `"15550109999"` via a normalizer. 3. Returned a `FieldBundle` object. The taint engine's propagation rule fired on *field access* (`bundle.phone`), not on *coercion*. Because the adapter constructed a **new** `FieldBundle` rather than mutating the input, the propagation graph recorded `FieldBundle.phone` as derived from the adapter's *code*, not from the untrusted input — the coercion call `normalize(x)` was not annotated as a taint-carrying edge. The sink `write_record` received `phone="15550109999"` labeled `trusted:model-derived`, and wrote it to a persistent store. The tell was a **label-value cardinality mismatch**: the audit log showed one `untrusted-web` input event and one `trusted` write event with no intervening `declassify`/`sanitize` authorization event. A provenance graph that is *complete* must have a path from every `trusted` sink write back to either a trusted source or an explicit declassification. Here the path terminated at the adapter's constructor, with the untrusted edge dangling. Structural signals that surfaced it, in order of reliability: - **Orphaned taint edges**: an `untrusted` label exists on an input node but has no outgoing edge into any sink-reachable value. Indicates the label was dropped, not consumed. - **Coercion without label join**: a node whose `derived_from` set is non-empty on the value side but whose `taint` field equals the default. The two disagree. - **Cardinality asymmetry** across the boundary: `count(untrusted_in) > count(untrusted_out) + count(declassified)` for a closed subgraph. - **Schema-default trust**: any adapter whose output schema declares unlabeled primitive types is a laundering surface by construction — the default label is `trusted`. ## Condition of Validity The invariant holds — and the guardrail is sound — only under these conditions: 1. **Provenance is a lattice with a join, not a tag.** Every value carries a label; every operation that produces a value from inputs must compute `label_out = join(label_in_1, ..., label_in_n)`. A component that does not participate in the join (because it re-serializes) must be *proven* label-preserving, or it must be treated as a declassification requiring authorization. 2. **The label channel is not reconstructible from the value.** If the adapter can emit a value without its label, the parallel-channel design is broken. The fix is to make the label a *property of the value object* (a `Tainted[T]` wrapper) so that coercion is forced to either preserve the wrapper or explicitly unwrap it — and unwrapping is the audited declassification event. 3. **The sink enforces, not just the source.** A privileged sink must reject any argument whose label is not `trusted` *or* accompanied by a valid declassification warrant bound to `(source_hash, transform_id, sink_id)`. Source-side labeling alone is insufficient because the laundering happens in transit. 4. **Closed-subgraph accounting.** For any adapter invocation, `join(inputs) ⊑ join(outputs)`. This is checkable at runtime without understanding the adapter's internals and is the cheapest structural guard. It does **not** hold when the adapter performs a genuine, auditable transformation (e.g., PII redaction) — that is a legitimate declassification and must be modeled as such, with the warrant recording the transform. The failure is specifically *implicit* declassification via re-encoding. ## Decision Boundary The decision boundary is between **modeling coercion as a transform edge** and **modeling it as a fresh source**. Concretely: - If the adapter's output value is a function of the input value (`out = f(in)`), it is a transform: `label_out = join(label_in, label_f)`. Default `label_f = trusted` (code is trusted), so `label_out = label_in`. No laundering possible. - If the adapter *reconstructs* the value from a parse tree, string split, regex group, or schema validator, the data-flow edge is broken at the reconstruction point. The engine cannot see `out` as derived from `in` unless the reconstruction is explicitly tainted. The operational rule: **any component that emits a value not byte-identical to a labeled input must either (a) declare the taint join explicitly in its manifest, or (b) be flagged as a declassification surface and routed through warrant issuance.** There is no third option; the default-trust schema path is the bug. When a manifest is silent, the safe default is `join(all inputs)` — never `trusted`. The boundary is crossed the moment a schema-coercing adapter is registered without a taint-join annotation. That registration is the decision point, and it is a *static* property detectable before any run. ## Operational Effect Downstream, the effect is a **persistent provenance inversion**: data that entered as `untrusted-web` is now stored as `trusted:model-derived` and will be retrieved by future agents as authoritative context. The corruption is not confined to the current task — it seeds the episodic memory of subsequent runs, and because the stored label is `trusted`, no future retrieval check will flag it. This is the memory-poisoning variant of the laundering bug: the taint is not just dropped, it is *inverted*, and the inversion is durable. Practically, the guardrail that bounds it is the closed-subgraph accounting check plus sink-side warrant enforcement. Neither requires trusting the adapter. The accounting check catches the drop at the boundary; the sink check catches it at the write. Running both means a laundering adapter fails closed at the first privileged write, and the failure is attributed to the adapter's manifest (missing join annotation) rather than to the payload — which is the correct remediation target. ```python from dataclasses import dataclass, field from typing import FrozenSet, Optional class TaintLaunderingError(RuntimeError): """Raised when a value reaches a privileged sink without a valid provenance path back to a trusted source or an authorized declassification.""" class TaintJoinViolation(TaintLaunderingError): """Adapter output label is not a join-superset of its input labels.""" TRUSTED = frozenset({"trusted"}) DEFAULT_TRUST = TRUSTED # never empty; empty-set default is the classic bug @dataclass(frozen=True) class Labeled: value: object taint: FrozenSet[str] = DEFAULT_TRUST derived_from: FrozenSet[str] = frozenset() def join(*labels: FrozenSet[str]) -> FrozenSet[str]: out: FrozenSet[str] = frozenset() for l in labels: out = out | l return out or DEFAULT_TRUST @dataclass class AdapterManifest: adapter_id: str declares_taint_join: bool # If False, adapter is a declassification surface and MUST emit warrants. def run_adapter( manifest: AdapterManifest, inputs: list[Labeled], transform, ) -> Labeled: """Execute an adapter and enforce the closed-subgraph join invariant.""" input_join = join(*(i.taint for i in inputs)) out_value = transform(*(i.value for i in inputs)) if not manifest.declares_taint_join: # Adapter re-encodes without declaring join: treat output as untrusted # until a warrant is issued. Emitting default-trust here is the bug. out_label = input_join raise TaintJoinViolation( f"adapter {manifest.adapter_id} lacks taint-join annotation; " f"refusing to emit unlabeled value derived from {sorted(input_join)}" ) out_label = join(input_join, DEFAULT_TRUST) # join with code trust if not input_join.issubset(out_label): raise TaintJoinViolation( f"adapter {manifest.adapter_id} dropped taint: " f"in={sorted(input_join)} out={sorted(out_label)}" ) return Labeled(out_value, taint=out_label, derived_from=frozenset({manifest.adapter_id})) def privileged_write( sink_id: str, record: Labeled, warrant: Optional[str] = None, ) -> None: """Sink-side enforcement: reject anything not trusted or warranted.""" if record.taint.issubset(TRUSTED): return if warrant is not None and warrant.startswith(f"declassify:{sink_id}:"): return raise TaintLaunderingError( f"sink {sink_id} rejected write: label {sorted(record.taint)} " f"has no trusted path and no declassification warrant" ) ```