# Under what conditions must an instance refuse to route a tainted tool call to a privileged sink **Date of Record:** 2026 November 15 **Scope:** Applies to agentic runtimes that propagate data-provenance taint labels across tool-call boundaries and gate privileged sinks (filesystem writes, shell execution, outbound network egress, credential use) on taint state. Does not apply to sinks that are themselves the designated declassifier (e.g., a human-approval queue) or to provenance-free control-plane operations that carry no payload. ## Core Distinction A capability gate and a taint gate answer different questions. The capability gate asks *may this principal invoke this sink at all*; the taint gate asks *may this particular payload reach this sink given where it came from*. The non-obvious boundary failure is that the two gates are frequently collapsed into one check keyed on the *tool name* rather than on the *(tool, argument-provenance)* pair. When that collapse happens, a caller with a valid capability token routes a tainted argument straight through, because the gate only ever inspects "is `shell.exec` allowed for this principal" and never inspects "did the `cmd` argument inherit an untrusted label." The invariant that must hold is per-argument, not per-call: **every value bound to a sink parameter must be checked for taint at the moment of binding, not at the moment of tool selection.** ## What Was Observed A routing layer enforced taint correctly at the *decision* stage: when a tool was selected, it computed the union of taint labels over the call's arguments and blocked if the sink was privileged and any argument was `UNTRUSTED`. This held for direct calls. It failed in two reproducible ways: 1. **Late binding via defaults.** A sink with a default argument (e.g., `write_file(path, content, *, mode="overwrite")`) received its privileged parameter from a server-side default rather than from the caller. The taint union was computed over *caller-supplied* arguments only, so the defaulted `mode` parameter — resolved after the gate ran — escaped inspection. A tainted `content` reached a destructive overwrite because the gate never saw the resolved binding. 2. **Aliasing through a declassifier that wasn't one.** A summarization tool was registered as `declassify=False` but its output was cached and re-served under the original tainted request ID. Downstream, the cache hit returned a value whose provenance pointer still resolved to the untrusted origin, yet the router treated cache-served results as clean. The result was a tainted string reaching `http.post` with a clean-looking label. In both cases the gate reported "passed," the sink executed, and the taint existed only in the audit log — after the privileged effect had already occurred. ## Condition of Validity The taint gate is valid only when all of the following hold simultaneously: - Taint labels are attached to *values*, not to tool names or call frames. - Argument resolution (including defaults, keyword expansion, and any server-side interpolation) completes **before** the gate evaluates, so the gate sees the exact values the sink will receive. - Any transformation that claims to declassify must produce a *new* provenance record with a fresh origin; it may not mutate or re-serve a label under the prior request identity. - The gate and the sink operate on the same immutable snapshot of the resolved arguments; if the sink re-resolves arguments after the gate, the guarantee is void. If any of these fails, the gate is advisory, not enforcing, and must be reported as such rather than silently returning "allowed." ## Decision Boundary Route the call only when the resolved argument set for every privileged parameter is either untainted or has passed an explicit, auditable declassification step whose output provenance is independent of the request that produced the taint. Refuse when: - a privileged parameter is populated by a default or interpolation that the gate did not resolve, or - a value's provenance pointer resolves to an untrusted origin even though the value arrived via a cache or intermediate tool, or - the sink mutates state (write, exec, egress, credential use) and any bound argument traces to `UNTRUSTED` with no independent declassification record. The boundary is *per bound argument at sink entry*, not *per selected tool*. A tool that is safe for untainted input is not thereby safe for tainted input; the decision must be re-made on each binding. ## Operational Effect When the per-argument invariant is enforced, tainted payloads are stopped at the binding site and the failure surfaces as a typed refusal the caller can route to a human-approval or declassification path, rather than as a silent privileged side effect discovered in the audit log. The practical consequence is that routing decisions become reproducible: the same resolved argument set always yields the same gate outcome, independent of caching, defaults, or tool-registration metadata. The cost is that every sink invocation must pay for full argument resolution and provenance resolution before dispatch — a cost that is cheap relative to the class of incidents (destructive overwrites, data exfiltration, credential misuse) it prevents. ```python class TaintedSinkError(RuntimeError): """Raised when a tainted value reaches a privileged sink parameter.""" PRIVILEGED_SINKS = {"write_file", "shell.exec", "http.post", "credential.use"} def route_tool_call(tool: str, resolved_args: dict, provenance: dict) -> dict: """ resolved_args: fully resolved arguments (defaults and interpolation already applied). provenance: maps argument name -> set of origin labels for that resolved value. """ if tool not in PRIVILEGED_SINKS: return {"tool": tool, "args": resolved_args, "gated": False} for name, value in resolved_args.items(): labels = provenance.get(name, set()) # A value with no provenance record is treated as untrusted, not clean. if not labels or "UNTRUSTED" in labels: raise TaintedSinkError( f"refusing privileged sink {tool!r}: argument {name!r} " f"carries labels {sorted(labels) or ['']} " f"with no independent declassification record" ) return {"tool": tool, "args": resolved_args, "gated": True} ```