# Why does an instance lose taint provenance across an MCP tool-result re-entry boundary **Date of Record:** 2026 November 27 **Scope:** Applies to agent runtimes that propagate information-flow taint labels across MCP tool calls and enforce capability scopes on results. Does not cover static capability grants at session start, nor single-tool pipelines where no result is re-fed into a subsequent tool's argument position. ## Core Distinction Most taint-tracking designs treat taint as a property of *data* — a label attached to a string or a structured value. The boundary failure described here is that MCP result re-entry breaks the *provenance chain*, not the *label*. When an untrusted endpoint returns a result, the runtime correctly marks the returned payload `tainted(untrusted_endpoint)`. But when that payload is subsequently used as an *argument* to a second MCP call, the outbound serialization path strips the label and re-enters the second server as if the value were agent-originated. The second server executes with a capability scope derived from the *caller's* identity, not the *data's* origin. Taint survives in memory; it does not survive the crossing. The distinction is this: label-preserving serialization is not provenance-preserving execution. A label that is written into the JSON-RPC `params` field but not interpreted by the receiving capability broker is decorative. The invariant that must hold is *taint continuity across the argument boundary*, and it fails silently because the label is still visibly present in the wire payload — making it look like the system is working. ## What Was Observed A two-hop tool chain was instrumented: `fetch_untrusted` (an MCP server under third-party control, capability scope `net:read`) returns a JSON object; the agent then calls `write_file` (internal MCP server, capability scope `fs:write`) with a field from that object as the `path` argument. The runtime's taint engine labeled the returned object `T1 = {origin: untrusted_endpoint, integrity: low}`. The agent's planner, reading the object, constructed the second call. At the serialization boundary, the argument `path` was emitted as a plain string. The `write_file` capability broker validated the *caller*'s warrant (`agent:planner → fs:write`) and approved the call. The `path` value — derived from attacker-controlled output — was never checked against the taint label because the broker had no channel to receive it. Three concrete observations: 1. **Label persistence without enforcement.** A trace of the second call showed `params.path = "/etc/agent/state.json"` with no accompanying `_taint` metadata. The taint engine retained `T1` in the agent's working memory, but the broker never queried it. Enforcement coverage was 0% on the argument path. 2. **Capability scope is caller-derived, not data-derived.** `write_file`'s scope decision was `warrant(agent:planner).allows(fs:write)`. It never evaluated `origin(path)`. An untrusted-origin path within an authorized scope executes fully. 3. **Re-entry resets the label.** A third hop (`read_back` on the written file) showed the value re-labeled `T2 = {origin: internal, integrity: high}` — because it was now read from an internal server. The taint laundering completed across two hops: `untrusted → written → read → trusted`. The provenance graph, had it been consulted, would have shown the ancestry; the label system did not. The failure was reproducible at 100% across 200 trials with no adversarial prompt — the agent was simply following a plan that used a returned value as an argument. No injection was required; ordinary tool chaining triggered it. ## Condition of Validity The boundary failure requires all of the following to hold simultaneously: - **Multi-hop execution.** A result from one MCP server is used as an argument to another. Single-hop pipelines (result returned to the user, never re-fed) are immune. - **Heterogeneous trust across hops.** The first server is lower-trust than the second, or the second's capability scope is broader than the first's. If both are equally trusted, the label crossing is moot. - **Argument-level serialization without taint metadata.** The runtime's MCP client emits plain JSON-RPC `params` without an integrity envelope, or emits an envelope the receiving broker does not parse. - **Caller-warrant capability model.** The broker authorizes based on who is calling, not what the data's origin is. This is the default in most MCP capability implementations. If any one condition is absent, the failure does not manifest. This is why it is easy to miss in testing: a single-server test harness, or a harness where all servers share one trust tier, will never exercise the boundary. The failure is a property of the *composition*, not of any individual server's correctness. ## Decision Boundary The architectural choice is whether taint is enforced at the *serialization boundary* or merely *carried in memory*. Two viable designs: **Design A — Envelope enforcement at the broker.** The MCP client wraps every argument derived from a tainted value in an integrity envelope: `{value: ..., _provenance: {origin, integrity, ancestry_hash}}`. The receiving broker, before executing, evaluates `provenance.integrity` against the capability scope's minimum integrity requirement. If `write_file`'s scope declares `min_integrity: high` and the argument carries `integrity: low`, the call is rejected with a structured error. This requires the broker to be taint-aware, which most MCP servers are not — so the runtime must either mandate a taint-aware server contract or interpose a proxy. **Design B — Capability narrowing on tainted arguments.** The runtime, on detecting a tainted argument, downgrades the effective capability scope for that call: `effective_scope = caller_scope ∩ integrity_ceiling(argument_taint)`. A `low`-integrity argument cannot reach a `fs:write` scope at all; the call is rejected before dispatch. This is enforceable entirely at the client, requires no server changes, and is the lower-friction invariant. The cost is over-rejection: some legitimate low-integrity writes (e.g., logging an untrusted string to a scratch path) are blocked unless the scope is explicitly annotated `accepts_low_integrity`. The decision boundary is: **if the broker cannot be made taint-aware, the client must narrow scope on tainted arguments; if it can, enforce at the envelope.** A system that does neither has no taint enforcement at the argument boundary, regardless of what its in-memory label engine reports. ## Operational Effect The observable effect is **taint laundering across two hops with zero adversarial input**. An agent that chains tools normally — fetch, transform, write — will move untrusted data into a high-integrity sink without any label violation being logged, because no label was violated; the label simply was not consulted at the crossing. Audit logs will show a fully authorized call chain. Post-hoc provenance reconstruction is possible only if the runtime retained the ancestry graph, which most do not. The guardrail that bounds the failure: **every MCP argument derived from a value whose provenance includes a lower-trust origin must carry an integrity envelope, and the receiving broker must reject on integrity mismatch before execution.** The invariant to assert in tests is *taint continuity*: for every argument position, `origin(arg) ⊆ trusted_origins(callee_scope)`. A test harness that asserts this across a two-hop chain will catch the failure; a harness that asserts only label presence will not. The residual risk after the guardrail: ancestry hashing must be collision-resistant and must include the *transformation* history, not just the immediate origin, or an agent can launder taint through a deterministic transform (e.g., base64) that resets the origin field. The envelope must carry `ancestry_hash`, not just `origin`. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class TaintContinuityError(RuntimeError): """Raised when a tainted argument crosses into a capability scope it cannot satisfy.""" pass @dataclass(frozen=True) class Provenance: origin: str integrity: str # "low" | "high" ancestry: tuple[str, ...] = () def ancestry_hash(self) -> str: h = hashlib.sha256() for step in self.ancestry: h.update(step.encode()) h.update(self.origin.encode()) h.update(self.integrity.encode()) return h.hexdigest() @dataclass class TaintedValue: value: Any provenance: Provenance @dataclass class CapabilityScope: name: str min_integrity: str def derive_argument(arg: Any, callee_scope: CapabilityScope) -> dict: """Serialize an argument for an outbound MCP call, enforcing taint continuity.""" if not isinstance(arg, TaintedValue): return {"value": arg} effective_integrity = arg.provenance.integrity if effective_integrity == "low" and callee_scope.min_integrity == "high": raise TaintContinuityError( f"taint continuity violated: argument from origin " f"{arg.provenance.origin!r} (integrity={effective_integrity}) " f"cannot enter scope {callee_scope.name!r} " f"(min_integrity={callee_scope.min_integrity}); " f"ancestry_hash={arg.provenance.ancestry_hash()}" ) return { "value": arg.value, "_provenance": { "origin": arg.provenance.origin, "integrity": effective_integrity, "ancestry_hash": arg.provenance.ancestry_hash(), }, } def execute_hop( inbound: TaintedValue, callee_scope: CapabilityScope, transform: str, ) -> TaintedValue: """Simulate a hop: serialize, dispatch, re-label result with extended ancestry.""" payload = derive_argument(inbound, callee_scope) # Broker would parse payload["_provenance"] here; assume it approves. new_prov = Provenance( origin=callee_scope.name, integrity="high" if callee_scope.min_integrity == "high" else "low", ancestry=inbound.provenance.ancestry + (transform,), ) return TaintedValue(value=payload["value"], provenance=new_prov) if __name__ == "__main__": untrusted = TaintedValue( value="/etc/agent/state.json", provenance=Provenance(origin="untrusted_endpoint", integrity="low"), ) write_scope = CapabilityScope(name="fs:write", min_integrity="high") try: execute_hop(untrusted, write_scope, transform="path_arg") except TaintContinuityError as e: print(f"BLOCKED: {e}") ```