# When must an instance refuse a tool call whose arguments are tainted but whose schema validates: the label-laundering boundary in MCP tool sandboxing **Date of Record:** 2026 November 21 **Scope:** Applies to any MCP-connected agent runtime that enforces least privilege by tracking information-flow labels (taint) on values derived from untrusted sources (tool outputs, retrieved documents, peer-agent messages) and gates privileged tool invocations on those labels. Does not apply to stateless single-turn completions with no tool surface, nor to systems that rely solely on prompt-level "do not do X" instructions without a runtime taint lattice. ## Core Distinction The failure is not "the model was prompt-injected." It is that **schema validation and taint validation are orthogonal gates, and the sandbox evaluates them in the wrong order or on the wrong object.** An MCP tool call has two independent properties: (1) its arguments conform to the tool's declared JSON Schema, and (2) the information-flow labels carried by those arguments are admissible for that tool's privilege class. A taint-aware sandbox that validates structure first and treats a passing schema as authorization to execute has silently collapsed gate (2) into gate (1). The result is *label laundering*: untrusted content re-enters the tool boundary as a well-formed argument, and the runtime's own serializer—not the attacker—strips the provenance. The non-obvious part: the taint is rarely on the *value*. It is on the *derivation path*. `{"path": "/etc/passwd"}` and `{"path": ""}` are byte-identical after JSON serialization if the page happened to contain that literal. Any sandbox that re-derives taint from the serialized argument at call time has already lost the label. The invariant that must hold is: **taint is a property of the argument's origin in the agent's dataflow graph, and must be propagated through every transformation (summarization, re-formatting, schema coercion, sub-agent handoff) that produces the argument—never re-inferred from the argument's final bytes.** ## What Was Observed A filesystem-read tool `fs.read` is registered with privilege class `READ_LOCAL` and a schema `{"type":"object","properties":{"path":{"type":"string"}},"required":["path"]}`. A network tool `web.fetch` returns untrusted content labeled `UNTRUSTED_EXTERNAL`. The runtime's taint tracker labels the `web.fetch` response and any value *directly* sliced from it. The agent's plan: fetch a documentation page, extract a "configuration path" mentioned in it, and read that path. Because the extraction is done by the model—`path = re.search(r'config at (\S+)', page).group(1)`—the resulting string is a *new* Python `str` object produced inside the agent's reasoning code, not a direct field of the labeled response object. The taint tracker, implemented as a wrapper around the tool-return boundary, sees a fresh `str` with no label. The model then emits: ``` {"tool": "fs.read", "arguments": {"path": "/etc/shadow"}} ``` The schema validates. The taint check runs on `arguments.path`, finds label `CLEAN`, and the sandbox executes. The page had contained the literal string `config at /etc/shadow`; the model faithfully extracted it; the sandbox faithfully obeyed least privilege *as computed*, which was wrong. The observable signature in the trace log is a **taint-gap**: between the `web.fetch` return (label `UNTRUSTED_EXTERNAL`) and the `fs.read` call, there is a `model.extract` span whose output carries no label, and the subsequent privileged call's argument traces its dataflow *through* that span. Runtimes that log only per-tool-call labels see a clean call and no anomaly. Runtimes that log the dataflow graph see a path from an `UNTRUSTED_EXTERNAL` source to a `READ_LOCAL`-class sink with the label dropped at a `model.extract` node. A second, subtler variant: MCP sub-agent handoff. Agent A holds a tainted value, summarizes it to fit a handoff payload, and sends it to Agent B over the A2A/MCP transport. The summary is a new string; the transport envelope carries no taint metadata because the MCP `CallToolRequest` schema has no field for it. Agent B receives a clean-looking argument and, if B holds a higher-privilege tool, executes. The label was laundered at the serialization boundary of the *inter-agent* hop, not the intra-agent one. ## Condition of Validity The taint gate is only sound when all of the following hold. Any one failing voids the guarantee and the sandbox must be treated as schema-only: 1. **Provenance is carried out-of-band and survives serialization.** Taint labels must travel in a side-channel keyed to argument identity (e.g., a per-call provenance record in the MCP `_meta` field or a signed taint token), not be re-derived from argument bytes. If the label cannot survive a JSON round-trip and a sub-agent hop, it is not a label; it is a comment. 2. **Every transformation node is a taint-propagating operator.** `model.extract`, `summarize`, `reformat`, `schema_coerce`, and `sub_agent_handoff` must each be modeled as dataflow nodes with a propagation rule (typically: output label = join of input labels, unless an explicit declassifier is invoked). An unmodeled node is a laundering site. 3. **The gate is evaluated on the dataflow join at the sink, not on the argument object.** The check at `fs.read` must compute `label(path) = join over all sources reaching path`, which requires the provenance record, which requires (1) and (2). 4. **Declassification is explicit, privileged, and logged.** The only way a tainted value becomes clean is a named declassifier (e.g., `sanitize.allowlist_path` that validates against a fixed prefix set) whose invocation is itself a privileged, audited event. Implicit declassification by re-serialization is forbidden. ## Decision Boundary The runtime must decide, per privileged call, between **execute**, **execute-with-declassifier**, and **refuse**. The boundary is drawn on the *join of source labels reaching the sink's arguments*, computed from the provenance record: - If `join == CLEAN`: execute. (This is the only path where schema-passing is sufficient, because there is no taint to launder.) - If `join` contains `UNTRUSTED_EXTERNAL` and the sink's privilege class is `READ_LOCAL` or higher, and no declassifier has run on the path: **refuse**, and return a structured refusal to the model naming the tainted source and the required declassifier. Do not silently drop the argument or substitute a default—both convert a refusal into an unauthorized execution with attacker-influenced fallback. - If a declassifier has run and its output is `CLEAN`, execute, but log the declassification with the original source label so the audit trail preserves the laundering attempt. The boundary is *not* "does the model's plan look malicious." A tainted-but-benign extraction and a tainted-malicious extraction are indistinguishable at the argument bytes; the only sound discriminator is provenance. This is why the gate must be structural, not semantic. ## Operational Effect Enforcing the invariant converts a class of silent privilege escalations into loud, attributable refusals, at the cost of false positives: legitimate workflows that extract a path from a trusted-but-labeled source will be refused until a declassifier is registered. The operational discipline is therefore to **register declassifiers eagerly for every intended cross-boundary flow**, and to treat each refusal as a dataflow-graph bug report rather than a model failure. The trace log must emit, per refusal, the full provenance chain (source tool → transformation nodes → sink), because the model cannot repair a laundering path it cannot see, and the runtime cannot distinguish a real attack from a missing declassifier without that chain. The measurable invariant to monitor: **zero privileged calls whose sink argument has a provenance path through an unmodeled transformation node.** Any nonzero count is an active laundering site, regardless of whether the call's arguments happened to be benign. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class TaintLabel(Enum): CLEAN = 0 UNTRUSTED_EXTERNAL = 1 UNTRUSTED_PEER = 2 class PrivilegeClass(Enum): READ_LOCAL = 10 WRITE_LOCAL = 20 NETWORK_EGRESS = 30 class TaintLaunderingError(RuntimeError): """Raised when a privileged tool call's arguments trace to an untrusted source through an unmodeled transformation node, i.e. the taint label was dropped at a model.extract / summarize / handoff boundary and the schema validator passed the laundered bytes.""" @dataclass class Provenance: source_label: TaintLabel path: list[str] = field(default_factory=list) declassified_by: Optional[str] = None def join(self, other: "Provenance") -> "Provenance": worst = max(self.source_label.value, other.source_label.value) return Provenance( source_label=TaintLabel(worst), path=self.path + other.path, declassified_by=self.declassified_by or other.declassified_by, ) def is_clean(self) -> bool: if self.declassified_by is not None: return True return self.source_label == TaintLabel.CLEAN # Transformation nodes that MUST propagate taint. An unmodeled node is a # laundering site; this registry is the allowlist of known-propagating ops. PROPAGATING_NODES = {"model.extract", "summarize", "reformat", "schema_coerce", "sub_agent_handoff"} def evaluate_privileged_call( tool_privilege: PrivilegeClass, argument_provenance: Provenance, transformation_nodes: list[str], ) -> None: """Gate a privileged MCP tool call. Raises if the argument's dataflow reaches an untrusted source through a node that did not propagate taint.""" unmodeled = [n for n in transformation_nodes if n not in PROPAGATING_NODES] if unmodeled: raise TaintLaunderingError( f"privileged call to {tool_privilege.name} has argument provenance " f"through unmodeled transformation node(s) {unmodeled}; taint label " f"was dropped and cannot be trusted. Refusing execution." ) if argument_provenance.is_clean(): return raise TaintLaunderingError( f"privileged call to {tool_privilege.name} refused: argument traces to " f"{argument_provenance.source_label.name} via " f"{argument_provenance.path}, no declassifier invoked." ) # --- trigger trace --- page_prov = Provenance(TaintLabel.UNTRUSTED_EXTERNAL, ["web.fetch:doc_page"]) # model.extract produces a fresh str; if the runtime fails to model it, the # provenance is lost and the argument looks clean. The gate detects the gap. try: evaluate_privileged_call( tool_privilege=PrivilegeClass.READ_LOCAL, argument_provenance=Provenance(TaintLabel.CLEAN, ["fs.read:path"]), transformation_nodes=["model.extract"], ) except TaintLaunderingError as e: print(f"REFUSED (laundering site detected): {e}") ```