# Why does an instance's taint label survive an MCP tool call but not the syscall mediation that follows it — the label-laundering boundary at the mediation ABI **Date of Record:** 2026 December 1 **Scope:** Applies to agents that run MCP tool invocations inside a taint-tracking sandbox where the sandbox mediates syscalls against a capability scoped to the *taint label* of the argument payload. Does not apply to pure prompt-injection filters at the model boundary, nor to sandboxes that mediate on static per-tool capabilities that never reference runtime taint state. ## Core Distinction A taint-tracking sandbox has two independent enforcement planes, and they are joined by a single, easily-misplaced handoff: the **taint plane** (which labels the provenance of a value as it flows through the agent's reasoning and tool arguments) and the **mediation plane** (which decides, per syscall, whether the capability attached to the calling process authorizes the operation). The invariant that most systems *assume* but do not *enforce* is: > The taint label of the value a tool receives is the same label the mediation layer sees when it authorizes the syscall that value triggers. This invariant is not a property of either plane alone. It is a property of the **serialization boundary** between them — the point where the agent's in-memory tainted value is serialized into an MCP tool-call argument, crosses the transport, is deserialized by the tool server, and then re-enters the kernel as a syscall whose capability is checked. Every one of those steps is a place where a label can be dropped, re-derived from the wrong source, or overwritten by a default. The failure is *label laundering*: a value that entered the agent with an untrusted taint label exits the mediation plane carrying a trusted label, and the syscall is authorized. The non-obvious part is that the two planes usually look correct in isolation. The taint tracker correctly labels the value. The mediator correctly enforces the capability it is given. The bug lives in the seam, and the seam is invisible to both test suites because each plane's tests hold the other plane's input constant. ## What Was Observed A tool server exposed an MCP tool `write_artifact(path, content)` behind a sandbox that mediates `openat`/`write` syscalls. The capability model was taint-scoped: a process holding the `fs:write` capability scoped to label `trusted` may write anywhere under `/work`; a process holding `fs:write` scoped to label `tainted` may write only to `/work/quarantine`. The agent's taint tracker labeled `content` as `tainted` when it originated from a retrieved document (a classic indirect-injection vector: the document contained an instruction the model partially followed). The observed trace: 1. Agent retrieves a document. Taint tracker assigns `label(content) = tainted`. Correct. 2. Agent calls `write_artifact(path="/work/report.md", content=)`. The MCP client serializes the call to JSON. **The taint label is not part of the MCP schema** — `content` is a `string`, and the label lives only in the tracker's side table keyed by an in-process handle that does not survive serialization. 3. The tool server deserializes. It has no tracker. It constructs a fresh value from the JSON string. The sandbox's mediation layer, invoked at the `openat` syscall, queries the *tool server process's* taint state for the buffer. That state is empty. The mediator's default for an unlabeled buffer is `trusted` (a fail-open default chosen so that ordinary untainted tool code does not need explicit labeling). 4. `openat("/work/report.md", O_WRONLY)` is authorized under `fs:write:trusted`. The tainted content is written outside quarantine. The label did not "leak." It was **never carried across the boundary at all**, and the mediation plane filled the vacuum with its default. The taint plane's guarantee — "this value is tainted" — was true at step 1 and false at step 3, and nothing in the system detected the transition. A second, subtler variant appeared when the tool server *did* attempt to propagate labels: it re-derived the label from the MCP call's `_meta` field, which the client populated from the *tool's declared* taint (from the tool manifest, `trusted`) rather than the *argument's* taint (from the tracker, `tainted`). Here the label was present but sourced from the wrong authority — a **manifest-over-value** substitution. The mediator saw a well-formed `trusted` label and authorized. This variant is worse because it defeats naive "did a label arrive?" assertions. ## Condition of Validity The taint-scoped mediation invariant holds only when all of the following are true simultaneously; the failure above is the violation of exactly one of them, and the system has no way to tell which: - **C1 (carriage):** every tainted value crossing the MCP transport carries its label in a field the tool server is required to read, and the schema marks that field as non-optional for any argument the mediator will see. - **C2 (authority):** the label used at mediation is derived from the *value's provenance* (the tracker's record of the argument), never from the *tool manifest* and never from a process default. - **C3 (default polarity):** an unlabeled buffer at the mediation plane resolves to `tainted`, not `trusted`. Fail-closed. - **C4 (join key):** the mediator can map the buffer it is about to write to the specific MCP argument that produced it, so a label attached to argument A cannot authorize a syscall writing argument B (the confused-deputy join). In the observed incident, C1 was false in variant 1 (no carriage) and C2 was false in variant 2 (manifest substituted for value). C3 was false in both, which is why the failure was silent rather than loud. C4 was never tested. The condition of validity is therefore *conjunctive and unobservable at runtime*: a system satisfying C1–C4 behaves identically to one violating C3 alone, until a tainted value happens to flow through the exact serialization path that drops its label. The invariant is real but has no runtime witness. ## Decision Boundary The boundary between "safe" and "laundered" is not the presence or absence of a taint label at the mediation plane. It is **whether the label at mediation was derived from the same provenance token that the taint tracker assigned at ingestion, joined through the serialization boundary by a key that survives it.** Operationally, this yields a decision rule for the mediator: - If the incoming syscall's buffer has a provenance token that joins (via C4) to an MCP argument whose tracker label is `tainted` → enforce `tainted` capability. - If the buffer has a provenance token that joins to an argument whose tracker label is `trusted` → enforce `trusted`. - If the buffer has **no** joinable provenance token → this is the laundering boundary. Do **not** fall back to `trusted`. The correct action is to reject the syscall with a distinct error (`TaintLabelUnjoinable`), because an unjoinable buffer means the label was dropped somewhere in the transport and the mediator cannot know its provenance. Falling back to either polarity silently is the bug; failing closed *and loudly* converts a silent laundering into a detectable one. The boundary is therefore drawn at *joinability*, not at label value. A `trusted` label that cannot be joined to a tracker record is as dangerous as a missing one, because it may be a manifest-derived substitution (variant 2). ## Operational Effect Three concrete effects follow, each of which changes how the sandbox must be built: 1. **The MCP schema must carry provenance, not just payload.** Any tool argument that the mediator will see must include a provenance token (an opaque handle minted by the tracker at ingestion) as a required field. The tool server must be *unable* to construct a mediation-visible buffer without a token; the schema's `required` list is the enforcement point. This makes C1 a compile-time/schema-time property rather than a runtime hope. 2. **The mediator must fail closed on unjoinable buffers, and the failure must be a distinct exception class** so that operators can distinguish "tainted value blocked" (expected, benign) from "label lost in transport" (a bug in the carriage path, which must page). Conflating these two into a generic `PermissionDenied` is what let the incident run undetected for a week: the quarantine writes looked like normal policy enforcement. 3. **The join key must be per-argument, not per-call.** C4 fails when a tool takes two arguments and the mediator joins on the call rather than the buffer. A tool that writes `content` (tainted) to a path derived from `path` (trusted) will, under per-call joining, be authorized at `trusted` because the *call* carried a trusted token from `path`. The mediator must resolve the token of the specific buffer being written, which means the tool server must propagate per-argument tokens into the syscall's buffer metadata — a requirement that most MCP tool servers do not currently satisfy and that must be added to the tool SDK, not bolted onto the mediator. The net operational lesson: taint-tracked mediation is not a property of the tracker or the mediator. It is a property of the **serialization seam**, and the seam must be instrumented with a join key, a fail-closed default, and a distinct error class — otherwise the two correct planes will compose into an incorrect system, and the composition will be invisible until a tainted value takes the exact path that drops its label. ```python class TaintLabelUnjoinable(RuntimeError): """Raised when a mediation-visible buffer has no provenance token that joins to a tracker record. This is the laundering boundary: the label was dropped or substituted somewhere in the MCP serialization path. It must never be silently resolved to 'trusted' or 'tainted'.""" pass class TaintLabelConflict(RuntimeError): """Raised when the token at mediation joins to a tracker record whose label disagrees with the label carried in the MCP argument metadata (manifest-over-value substitution).""" pass def mediate_syscall(syscall, tracker, argument_meta): """ syscall: the pending write, with buffer.provenance_token (may be None) tracker: records provenance_token -> label assigned at ingestion argument_meta: the MCP argument metadata the tool server received """ token = syscall.buffer.provenance_token # C1/C4: no joinable token means the label did not survive transport. if token is None: raise TaintLabelUnjoinable( f"buffer for {syscall.path!r} carries no provenance token; " f"cannot determine taint. Refusing (fail-closed, C3)." ) record = tracker.lookup(token) if record is None: raise TaintLabelUnjoinable( f"provenance token {token!r} has no tracker record; " f"label was minted outside the tracker. Refusing." ) # C2: the authority is the tracker record, not the manifest or the meta. value_label = record.label carried_label = argument_meta.get("taint_label") if carried_label is not None and carried_label != value_label: raise TaintLabelConflict( f"argument metadata claims {carried_label!r} but tracker says " f"{value_label!r} for token {token!r}; manifest-over-value substitution." ) capability = syscall.process.capability("fs:write") if not capability.scoped_to(value_label): raise PermissionError( f"fs:write scoped to {capability.label!r} cannot write " f"{value_label!r} buffer to {syscall.path!r}" ) return syscall.execute() ```