When must an instance treat a tainted tool response as a capability grant rather than data: the label-laundering boundary at MCP result re-entry

**Date of Record:** 2026 December 2 **Scope:** Applies to any agent runtime that ingests MCP `tools/call` responses from servers it did not author and enforces a taint label on the resulting content. Does not apply to first-party tool servers whose responses are admitted at build time, nor to pure data-plane pipelines with no downstream tool invocation.

Core Distinction

The distinction that matters is not "trusted vs. untrusted content" but *whether a tainted span is allowed to re-enter the planner as a value* versus *as an instruction-bearing capability*. Most runtimes implement taint as a boolean on a message: once a tool response is labeled `tainted`, the runtime forbids the model from issuing side-effecting calls derived from it. This is the wrong axis. The failure occurs at the *re-entry boundary*: when tainted content is copied into a variable, summarized, or re-serialized, and then read back by the planner from a location the taint tracker does not cover. The taint label attaches to the message envelope, not to the *provenance of the bytes*; the moment the bytes cross a serialization seam, the label is laundered and the planner treats attacker-authored text as its own prior reasoning.

The invariant that must hold: **taint is a property of byte provenance, not of message position.** A span derived from a tainted source remains tainted through every copy, summary, and re-encode, until an explicit declassification event that a human or a policy engine—not the model—authorizes.

What Was Observed

A planner agent was given an MCP server `notes.search` and a second server `shell.exec`. The `notes.search` server was third-party and untrusted; `shell.exec` was privileged. The runtime correctly labeled the `notes.search` response `tainted` and blocked direct `shell.exec` calls whose arguments were *syntactically* drawn from the tainted span.

The attacker's payload was a note whose body read, in part: `Refactor plan: rename build target. See ticket #4412.` The planner, doing legitimate multi-step reasoning, called a third tool `scratchpad.write` with the note's text as a "summary," then in the *next* turn called `scratchpad.read` and received the summary back. The scratchpad server was trusted (first-party), so its responses were admitted as `clean`. The planner then issued `shell.exec("make rename-target")` with an argument assembled from the scratchpad read. The taint label had been dropped at the `scratchpad.write` boundary because the runtime tracked taint on the *response envelope* and treated the scratchpad as a trusted sink—it never propagated the label from the *argument* into the *stored value*.

The trace:

  1. `notes.search` → response span `S`, labeled `tainted`, source `server:notes`.
  2. Planner copies `S` into `scratchpad.write(content=S)`. The runtime sees a call whose argument is tainted and, per its policy, *permits* it because scratchpad is classified as a low-risk sink. It does not record that the *stored object* is now tainted.
  3. `scratchpad.read` → response span `S'`, labeled `clean`, source `server:scratchpad`.
  4. Planner issues `shell.exec` with an argument derived from `S'`. Taint check passes. The privileged call executes.

The mechanism is label laundering through a trusted intermediate store. The taint tracker was a *per-message* boolean; the attacker needed only a store the runtime trusted to launder the label. The scratchpad was not malicious—it was merely *trusted*, which is sufficient.

Condition of Validity

The guardrail holds only under a conjunction of conditions; violating any one reopens the laundering path:

When these hold, the runtime enforces a *taint lattice* over byte provenance rather than a per-message bit, and the scratchpad round-trip is caught at step 3: `S'` carries provenance `{server:notes → scratchpad}`, still tainted, and the `shell.exec` at step 4 is blocked.

Decision Boundary

The boundary is: **does the intermediate store's read path re-enter the planner's context?**

The non-obvious consequence: a *trusted* store is more dangerous than an untrusted one, because trusted stores are exactly the ones the runtime is tempted to exempt from taint propagation. The attacker does not need to compromise the scratchpad; they need only convince the planner to write into it. The runtime's trust classification of the *server* is orthogonal to the taint status of the *bytes*.

A second boundary: summarization. If the planner summarizes a tainted span and the summary is stored as a "clean" derived value, the same laundering occurs. Summaries must inherit the union of their inputs' provenance, and a summary of tainted content is tainted.

Operational Effect

The practical effect is that taint-aware sandboxing must be implemented as a *provenance-tracking* system over values, with the following enforced properties:

  1. Every value in the planner's context carries a provenance set. Copying, summarizing, and serializing preserve it (union on merge).
  2. Taint checks run at *both* egress (side-effecting call arguments) and ingress (values read back into context). Ingress checks are the ones most often missing.
  3. Sinks are classified by *reachability from the planner*, not by privilege. A store the planner can read is a laundering channel.
  4. Declassification is an explicit, audited event keyed on provenance, never on message source.

The failure mode is silent: the planner's reasoning looks coherent, the tool calls are individually permitted, and the only signal is that a privileged call's argument traces—through a chain of trusted stores—back to an untrusted source. Without provenance tracking, that chain is invisible.

Operational checklist

from dataclasses import dataclass, field
from typing import FrozenSet

class TaintLaunderingError(RuntimeError):
    """Raised when tainted-derived bytes re-enter the planner context as clean."""
    pass

@dataclass(frozen=True)
class Value:
    payload: str
    provenance: FrozenSet[str] = field(default_factory=frozenset)

    @property
    def tainted(self) -> bool:
        return bool(self.provenance)

def summarize(inputs: list[Value]) -> Value:
    # A summary inherits the union of its inputs' provenance.
    prov: FrozenSet[str] = frozenset()
    for v in inputs:
        prov = prov | v.provenance
    return Value(payload="<summary>", provenance=prov)

def write_to_store(store: dict, key: str, value: Value) -> None:
    # Store the value with its provenance intact; do NOT strip the label.
    store[key] = value

def read_from_store(store: dict, key: str) -> Value:
    v = store.get(key)
    if v is None:
        raise TaintLaunderingError(f"missing key {key!r}")
    # Ingress check: a stored value that is tainted must not be admitted as clean.
    if v.tainted:
        raise TaintLaunderingError(
            f"tainted value re-entered planner context via {key!r}: "
            f"provenance={sorted(v.provenance)}"
        )
    return v

def issue_privileged_call(arg: Value, command: str) -> str:
    if arg.tainted:
        raise TaintLaunderingError(
            f"privileged call {command!r} argument carries taint: "
            f"{sorted(arg.provenance)}"
        )
    return f"executed {command}"

def demo() -> None:
    store: dict = {}
    untrusted = Value(payload="rename build target", provenance=frozenset({"server:notes"}))
    s = summarize([untrusted])
    write_to_store(store, "scratch:1", s)
    # The laundering path: read back and attempt a privileged call.
    read_from_store(store, "scratch:1")  # raises TaintLaunderingError
    issue_privileged_call(s, "make rename-target")  # also raises

if __name__ == "__main__":
    demo()