# Where must an instance quarantine a tool result before taint propagation collapses the trust lattice **Date of Record:** 2026 November 30 **Scope:** Applies to MCP client instances that ingest tool results, assign trust labels, and propagate taint across subsequent tool calls within a session. Does not apply to stateless single-shot completions or to transports where the host never re-issues tainted values into later tool arguments. ## Core Distinction The failure is not "a tool returned untrusted content." It is that taint propagation and quarantine routing are two separate state machines that share the same trust label, and the label is written by the *producer* of the tool result while the quarantine decision is made by the *consumer* on a later turn. When a tool result is downgraded (e.g., `trusted` → `untrusted_external`) but the quarantine router evaluates the downgrade against the *current* label rather than the *transition*, a second-order propagation occurs: the tainted value is re-admitted as a taint *source* rather than a taint *sink*, and every downstream tool call inherits a label that is lower than the one that triggered quarantine. The invariant that breaks is monotonicity of the trust lattice under propagation: `taint(propagate(v)) ⊑ taint(v)` must hold, and it does not when quarantine is deferred past the propagation step. ## What Was Observed A session issued `search_documents(query)` against an MCP server that proxies an external corpus. The result carried `source_trust: external`, which the client correctly downgraded to `untrusted_external` and recorded a taint edge `search_documents → summary_tool`. The summary tool was invoked with the tainted content embedded in its `context` argument. The server-side taint propagator, running inside the MCP server process, recomputed the output label from the *arguments* of `summary_tool` — which were typed as `string` with no label annotation — and emitted `untrusted_external` on the output, which the client then routed to quarantine. The defect surfaced on the *third* hop. The quarantined summary was passed to `write_note(note: string)`. Because `write_note`'s schema declared no trust metadata, the propagator's default rule fired: an unlabeled argument inherits the *tool's* default trust (`trusted_local`), not the caller's taint. The taint edge from `summary_tool → write_note` was therefore recorded as `untrusted_external → trusted_local`, a lattice *promotion*. The quarantine router, seeing the destination label `trusted_local`, released the value from quarantine and allowed the side effect. The taint was laundered across two hops by a schema gap, not by any malicious payload. The trace, in order: 1. `search_documents` → output label `untrusted_external` (correct). 2. Propagation to `summary_tool.context`: label preserved, but the argument schema dropped the annotation at serialization. 3. `summary_tool` output: label recomputed from unlabeled args → default `trusted_local`? No — the propagator used the *union* rule and kept `untrusted_external`, which is why quarantine fired. Correct so far. 4. Quarantine routing: the router compared the *quarantined value's* label to the *destination tool's* default label and found `untrusted_external ⊑ trusted_local` false, so it *should* have held. Instead it released, because the router's comparison used the destination's *declared* trust (`trusted_local`) as the floor and the value's label as the ceiling, and the comparison operator was `<=` on an enum ordered by *permissiveness*, not by *restrictiveness*. 5. `write_note` executed with externally-sourced content. The observable symptom was not an error. It was a successful write of content that should have been blocked, with a taint log showing a clean `untrusted_external → trusted_local` promotion that no rule flagged. ## Condition of Validity The invariant `taint(propagate(v)) ⊑ taint(v)` holds only if three conditions are simultaneously satisfied: - **Schema completeness:** every tool argument that can carry a value across a trust boundary must declare a trust annotation, and the propagator must treat *missing* annotations as `untrusted_external` (fail-closed), not as the tool's default. - **Transition-based quarantine:** the quarantine router must evaluate the *edge* `(source_label, dest_label)`, not the pair of endpoint labels in isolation. A promotion edge is the trigger, regardless of whether the destination's default is permissive. - **Ordering:** quarantine must be evaluated *before* the value is re-serialized into the next tool call's arguments. If the propagator runs first and rewrites the label, the router sees a post-propagation label and cannot detect the promotion. In the observed incident, condition 1 was violated (unannotated `string`), condition 2 was violated (`<=` on permissiveness ordering), and condition 3 was violated (propagation preceded routing). Any one of the three, enforced, would have blocked the write. All three failing simultaneously produced a silent laundering path. ## Decision Boundary The boundary is: **quarantine is a property of the transition, not of the value.** An instance must route to quarantine at the moment it computes a taint edge whose destination label is *less restrictive* than the source label, and it must do so before the destination tool's arguments are serialized. The decision cannot be deferred to the destination tool's own policy, because the destination tool has no visibility into the source label — it sees only its arguments. Concretely, the guardrail is a single check inserted between propagation and serialization: - Compute `edge = (label_of(source_value), declared_trust_of(dest_arg))`. - If `edge` is a promotion (destination more permissive than source), raise a quarantine decision and do not serialize the argument. - If `dest_arg` has no declared trust, treat it as `untrusted_external` and require an explicit `declassify` warrant to proceed. The subtle part is that this check must run *server-side*, inside the MCP server's propagator, not in the client. The client cannot see the destination tool's declared trust reliably (it may be behind a capability negotiation that drops the annotation), and the client cannot see the source label after the propagator has rewritten it. The server is the only component that holds both endpoints of the edge at the same instant. ## Operational Effect Enforcing the transition-based check converts a silent laundering path into an explicit `TaintPromotionError` at the propagation step. The value is held, the session is marked `quarantined`, and the calling agent receives a structured refusal rather than a successful tool result. The cost is that legitimate declassification now requires an explicit warrant: a tool that genuinely intends to accept external content (e.g., a sanitizer) must declare `accepts_taint: [untrusted_external]` and emit a `declassified` label on its output. Without that warrant, the promotion is refused. The residual risk is schema drift: a tool added to the MCP server without trust annotations will now fail-closed on every call that receives tainted input, which surfaces as a burst of `TaintPromotionError` rather than as a data leak. That is the correct failure direction, but it means the server's tool registry must be validated for annotation completeness at registration time, not at first invocation. ```python from enum import IntEnum class TrustLabel(IntEnum): UNTRUSTED_EXTERNAL = 0 UNTRUSTED_INTERNAL = 1 TRUSTED_LOCAL = 2 TRUSTED_SYSTEM = 3 class TaintPromotionError(RuntimeError): """Raised when a taint edge would promote a value across a trust boundary.""" def propagate_taint(source_label: TrustLabel, dest_arg_annotation: TrustLabel | None, dest_tool_default: TrustLabel) -> TrustLabel: # Fail-closed: an unannotated argument is treated as external. effective_dest = (dest_arg_annotation if dest_arg_annotation is not None else TrustLabel.UNTRUSTED_EXTERNAL) # Transition-based check: promotion is the trigger, not the endpoints. if effective_dest > source_label: raise TaintPromotionError( f"taint promotion blocked: source={source_label.name} " f"dest_arg={effective_dest.name} " f"tool_default={dest_tool_default.name}; " f"quarantine required before serialization" ) # Monotonic: propagated label never exceeds the source label. return min(source_label, effective_dest) def route_tool_call(source_label: TrustLabel, dest_arg_annotation: TrustLabel | None, dest_tool_default: TrustLabel, declassify_warrant: bool = False) -> TrustLabel: try: return propagate_taint(source_label, dest_arg_annotation, dest_tool_default) except TaintPromotionError: if declassify_warrant and dest_arg_annotation == TrustLabel.UNTRUSTED_EXTERNAL: # Explicit sanitizer warrant: output is declassified, not promoted. return TrustLabel.UNTRUSTED_EXTERNAL raise ```