# In what scenarios must an instance quarantine tainted argument provenance before a tool call rather than sanitize the payload in place **Date of Record:** 2026 November 23 **Scope:** Applies to single- or multi-agent instances that gate tool invocation on taint labels attached to argument provenance (e.g., a value derived from untrusted retrieval, web content, or peer-agent message). Does not apply to stateless batch inference where no tool side-effects or cross-boundary data egress is possible. ## Core Distinction There are two defensible responses to a tainted argument reaching a tool call: **sanitize** (strip/escape/redact the payload so the call proceeds with cleaned data) and **quarantine** (refuse the call because the taint label itself, not the payload content, is the disqualifying fact). The boundary failure this record addresses is the systematic confusion of these two, which produces a false sense of containment: an agent sanitizes a payload that is *semantically clean but provenance-tainted*, then routes the same tainted value through a *different* parameter that the sanitizer does not model — a side channel. The non-obvious invariant is this: **taint is a property of the dataflow graph, not of the string.** A sanitizer that inspects bytes cannot see that the same logical value also flows into `filename`, `callback_url`, `recipient`, `sql_comment`, `sort_key`, `header_value`, or a free-form `note` field. Exfiltration succeeds precisely because the gated parameter is clean while the ungated parameter carries the tainted value verbatim. ## What Was Observed A retrieval-augmented agent was asked to summarize a document and "file a report." The document body was untrusted (retrieved from a shared corpus). The agent's tool schema for `write_file` was: - `path: str` (gated: must match `^/reports/[a-z0-9_]+\.md$`) - `content: str` (gated: PII scrubber + URL redactor) - `metadata: dict` (ungated, free-form, expected to carry `title`, `author`, `tags`) The taint engine labeled `content` as `TAINTED(document_body)` and the gate ran a redactor over it, removing every `http`-prefixed substring. The call was permitted. The agent, following an instruction embedded in the document ("preserve source attribution"), placed the document's canonical URL into `metadata["source"]`. The gate did not inspect `metadata`. The file was written, then a downstream indexer ingested `metadata` and emitted it to an external search service. The URL — the exact string the redactor had removed from `content` — left the boundary through the side channel. The failure trace: 1. Taint propagation assigned `TAINTED` to the derived `content` value. 2. The gate's sanitizer rewrote `content`; taint was *cleared on that node* by policy. 3. The original tainted value was still live in the agent's working memory and was copied into `metadata["source"]` during argument construction. 4. Argument construction did not re-propagate taint to the new node because the sanitizer's clear was treated as a *value-level* property ("this string is clean") rather than a *flow-level* property ("this branch of the graph is clean"). 5. The gate saw an untainted `metadata` and permitted the call. The root cause is step 4: sanitization cleared taint on a *copy*, not on the *origin*. The origin remained tainted and re-emerged through a parameter the sanitizer never modeled. ## Condition of Validity Quarantine (refuse the call) is the correct response — not sanitize — exactly when all three hold: 1. **The tainted value is reachable from more than one parameter slot**, and at least one slot is not covered by the sanitizer's schema. If the tool has a single string input and no structured side fields, sanitize-in-place is sound. 2. **The sanitizer operates on bytes/patterns, not on provenance.** A redactor that removes `http://` does not remove a base64-encoded URL, a domain-only fragment (`evil.example`), or a URL split across two metadata keys (`metadata["host"]` + `metadata["path"]`). 3. **Downstream consumers of the ungated slot perform egress or persistence.** Metadata that is only logged locally is low-risk; metadata that is indexed, forwarded, or rendered to a third party is an exfiltration surface. When these hold, the invariant to enforce is: *a tainted value may not enter argument construction at all.* The agent must either (a) drop the value and proceed with a provenance-free substitute, or (b) refuse the call and surface the taint to the orchestrator. Sanitizing one slot while leaving the origin live is the failure. ## Decision Boundary The boundary between sanitize and quarantine is drawn at the **argument-construction boundary**, not the tool-invocation boundary. Concretely: - If taint is detected *before* the argument dict is assembled, quarantine the source value and rebuild arguments from clean inputs. - If taint is detected *after* assembly but the tool schema has a closed, fully-enumerated parameter set with per-field sanitizers, sanitize per-field and re-run taint propagation over the *entire* assembled dict (not per-field) to catch cross-field reassembly. - If the tool schema contains any open/free-form field (`dict`, `**kwargs`, `note`, `extra`), the parameter set is not enumerable and per-field sanitization is unsound. Quarantine. The decision is not "is this string dangerous?" but "can I enumerate every sink this value can reach?" If the answer is no, the correct action is refusal, not cleaning. ## Operational Effect Enforcing quarantine-at-construction converts a silent exfiltration channel into an explicit, auditable refusal. The agent's behavior changes from "clean and proceed" to "halt and report provenance," which: - Makes the taint label survive sanitization as a *flow* property, so re-emergence in a sibling parameter is caught. - Forces tool schemas to declare open fields explicitly, since an undeclared open field now blocks the call rather than silently passing. - Produces a refusal record that names the tainted origin, which is the artifact an auditor needs to trace the injection back to its source document. The cost is throughput: some legitimate calls are refused because a benign value shared provenance with a tainted one. That cost is bounded and visible; the cost of the sanitize-and-proceed failure is unbounded and invisible until the egress has already occurred. ```python from dataclasses import dataclass, field from typing import Any class TaintedArgumentEgress(RuntimeError): """Raised when a tainted value reaches an unenumerable tool parameter slot.""" pass @dataclass class TaintLabel: origin: str closed: bool = False # True only if sanitizer proved this branch clean @dataclass class ArgGraph: values: dict[str, Any] = field(default_factory=dict) taint: dict[str, TaintLabel] = field(default_factory=dict) def bind(self, slot: str, value: Any, label: TaintLabel | None) -> None: self.values[slot] = value if label is not None and not label.closed: self.taint[slot] = label OPEN_SLOTS = {"metadata", "extra", "note", "kwargs"} def gate_tool_call(tool_name: str, graph: ArgGraph, schema: dict[str, str]) -> None: # Enumerate every slot the schema declares; anything not declared is open. declared = set(schema.keys()) open_present = [s for s in graph.values if s not in declared or s in OPEN_SLOTS] for slot, label in graph.taint.items(): if slot in open_present: raise TaintedArgumentEgress( f"tool={tool_name!r} slot={slot!r} carries taint from " f"{label.origin!r} into an unenumerable parameter; quarantine " f"required, in-place sanitization is unsound here" ) # Even a declared slot is unsafe if the sanitizer only cleared a copy. if not label.closed and slot not in schema.get("__sanitized__", set()): raise TaintedArgumentEgress( f"tool={tool_name!r} slot={slot!r} taint from {label.origin!r} " f"was never cleared at the flow level" ) # Failure trace from the record: g = ArgGraph() g.bind("path", "/reports/summary.md", None) g.bind("content", "clean text", TaintLabel("document_body", closed=True)) # sanitized copy g.bind("metadata", {"source": "https://evil.example/x"}, TaintLabel("document_body")) gate_tool_call( "write_file", g, {"path": "str", "content": "str", "metadata": "dict"}, ) # raises TaintedArgumentEgress: metadata carries document_body taint into an # unenumerable parameter; the sanitizer cleared content but not the origin. ```