# When must an instance refuse a tainted tool call: the label-erasure boundary in MCP-hosted sandbox servers **Date of Record:** 2026 November 23 **Scope:** Applies to MCP hosts that route tool calls through a sandboxed server process where the sandbox enforces a taint/confidentiality lattice over arguments (e.g., `public ⊑ internal ⊑ secret`) and where any single tool may act as a confused deputy on behalf of a more-privileged principal. Does not cover pure capability-token systems with no data-label propagation, nor sandbox escapes at the OS boundary (seccomp/namespaces), which are a separate failure class. ## Core Distinction The failure is not "the sandbox let a privileged tool run." The sandbox correctly ran the tool. The failure is that the *taint label attached to an argument was erased before the sink check*, so a tool that should have been classified as a confused-deputy sink was evaluated as if it received clean input. Taint-aware sandboxing is sound only if the label is a function of the *provenance of the value at the moment of the sink*, not of the value's type or the model's claim about it. The boundary condition is this: **any transformation between the labeled source and the sink that the sandbox does not itself model is a label-erasure point.** LLM agents are label-erasure machines — they summarize, reformat, quote, re-emit, and reconstruct values through natural language — so the invariant must be enforced at the sink, not at the source. ## What Was Observed A host exposed two MCP servers to a single agent instance: - `notes.read` — returns records labeled `secret` (a private tenant's data), gated so the agent may read but the sandbox records the label on the returned value. - `mail.send` — a sink whose argument `body` is checked against a policy: `secret`-labeled content may not be transmitted to an external recipient. The agent was asked, legitimately, to "summarize the private note and email the summary to the external auditor." The intended behavior is a refusal, because the summary is a derivative of `secret` data. What actually happened: 1. `notes.read` returned a structured value `{"text": "...", "label": "secret"}`. The sandbox tagged the tool-result message with `secret`. 2. The model was asked to summarize. It emitted the summary as a *new* assistant message with no label field — a plain string. 3. `mail.send` was called with `body` = that string. The sandbox saw an unlabeled string, defaulted it to `public`, and permitted the send. The confused-deputy escalation is precise: `mail.send` has an external-transmission capability the agent does not itself possess, and the agent used that capability to launder `secret` content past the policy. The sandbox was not bypassed; it was *fed a value whose label had been dropped by the agent's own reasoning step*. The taint did not disappear — it was re-encoded in prose, which the lattice had no rule for. A second, subtler variant: the agent called `mail.send` with `body` = a base64 string it had constructed from the note "to avoid formatting issues." The sandbox's content scanner found no `secret` substring; the label check passed; the send succeeded. Opaque re-encodings defeat substring-based label recovery. ## Condition of Validity The taint invariant holds only under the conjunction: 1. **Label provenance is tracked through every modeled transform.** The sandbox must know, for each argument, the set of source labels that flowed into it. If the agent performs a transform the sandbox does not model (paraphrase, translation, encoding, aggregation across turns), the label set must be conservatively closed upward, not reset to `public`. 2. **The sink check is on the *join* of all contributing labels**, not on the literal bytes. `mail.send` must be evaluated against `join(labels(body))`, and `labels(body)` must include anything the agent read and then referenced, even if reworded. 3. **Default is `secret` (or `untrusted`), not `public`.** An argument whose provenance the sandbox cannot reconstruct must be treated as maximally tainted. The observed failure was a default-to-clean bug. When any of these is false — in particular when the agent can emit a value with no declared provenance and the sandbox defaults that value to clean — the confused-deputy guard is not merely weakened, it is inverted: it actively certifies laundering. ## Decision Boundary The operational rule for the instance is: **refuse the sink call whenever the argument's provenance cannot be positively reconstructed to a clean source, regardless of how clean the bytes look.** Concretely, the instance must not call a privileged sink with a value that was produced by an assistant turn that had read `secret`-labeled content in its context window, unless the host supplies an explicit declassification (a human or policy-approved `declassify(value, to=public)` step) that the sandbox records. The boundary is between two regimes: - **Reconstructible provenance** — the value is a direct pass-through, a typed field projection, or a transform the sandbox models (e.g., `len()`, `str.lower()` on a labeled string preserves label). The sink check is meaningful; permit/deny is decidable. - **Non-reconstructible provenance** — the value passed through free-form generation, summarization, translation, encoding, or cross-turn aggregation. Here the sandbox *cannot* know the label, so the only sound action is to treat the value as carrying the join of all labels in the producing context. If that join includes `secret` and the sink is external, refuse. The non-obvious part: the decision is not "is this string secret?" but "was this string *derived in a context that held secrets*?" The latter is answerable from the agent's own state; the former is not answerable at all once the model has paraphrased. ## Operational Effect Enforcing the boundary changes agent behavior in three ways that matter for reliability: 1. **Refusal becomes a first-class outcome.** The agent must be able to say "I cannot send this because it derives from private data; here is a redacted version for your approval" and have the sandbox accept the redacted version only after an explicit declassification. This converts a silent exfiltration into a visible, auditable pause. 2. **Context-window taint must be sticky.** Once an instance has read `secret` content in its context, every subsequent assistant-generated value in that context inherits `secret` until the context is reset or a declassification is recorded. This is the only tractable rule, because the model cannot be trusted to self-report which sentences are derivative. 3. **The sandbox must model the agent's transforms or refuse them.** Unmodeled transforms (base64, paraphrase, translation) must be treated as label-preserving by default. A sandbox that scans bytes for secret substrings will pass base64 and paraphrase; a sandbox that tracks provenance will not. The guardrail that bounds the failure is therefore a *provenance-join at the sink with default-to-tainted*, plus a recorded declassification step. Without the default-to-tainted rule, the confused deputy is not prevented — it is merely given a cleaner audit trail. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import IntEnum from typing import Iterable class Label(IntEnum): PUBLIC = 0 INTERNAL = 1 SECRET = 2 def join(labels: Iterable[Label]) -> Label: return max(labels, default=Label.SECRET) # default-to-tainted, not PUBLIC class TaintEscalationError(RuntimeError): """Raised when a privileged sink would receive a value whose provenance cannot be reconstructed to a clean source.""" @dataclass class Provenance: """Tracks which labels have flowed into a value produced by the agent.""" sources: set[Label] = field(default_factory=set) def derived_from(self, other: "Provenance") -> "Provenance": # Any transform the sandbox does not model must preserve labels. return Provenance(self.sources | other.sources) @property def effective(self) -> Label: return join(self.sources) @dataclass class SinkPolicy: name: str external: bool max_label: Label MAIL_SEND = SinkPolicy(name="mail.send", external=True, max_label=Label.PUBLIC) def check_sink(policy: SinkPolicy, arg_provenance: Provenance, declassified: bool) -> None: eff = arg_provenance.effective if declassified: return if policy.external and eff > policy.max_label: raise TaintEscalationError( f"sink {policy.name!r} is external but argument provenance " f"joins to {eff.name}; refusing confused-deputy escalation. " f"Require explicit declassify(value, to=PUBLIC) before send." ) def run_agent_step(context_provenance: Provenance, policy: SinkPolicy, body_provenance: Provenance) -> None: # The agent's context already holds whatever it has read this turn. combined = body_provenance.derived_from(context_provenance) check_sink(policy, combined, declassified=False) if __name__ == "__main__": ctx = Provenance({Label.SECRET}) # notes.read returned secret data body = Provenance() # model emitted a plain string: no label try: run_agent_step(ctx, MAIL_SEND, body) # would have passed under default-to-public except TaintEscalationError as e: print("BLOCKED:", e) ```