What structural signals indicate a taint-quarantine bypass in tool sandboxing when untrusted data re-enters through a privileged argument alias

**Date of Record:** 2026 December 1 **Scope:** Applies to agent runtimes that propagate taint labels from untrusted sources (retrieved documents, tool outputs, user-supplied text) to tool-call arguments and enforce a quarantine gate before privileged actions. Does not cover static taint analysis of source code or purely declarative policy engines with no runtime argument inspection.

Core Distinction

The failure mode is not "untrusted data reaches a privileged tool." That is the intended trigger. The failure is that the taint label survives *argument construction* but does not survive *argument aliasing* — specifically when a privileged argument is derived from a tainted value through a transformation the taint propagator classifies as *sanitizing* (e.g., JSON re-serialization, schema coercion, base64 decode-then-reencode, or a `str()`/`format()` interpolation that strips the label because the output is a new immutable primitive).

The distinction that matters operationally: a taint system tracks **provenance of values**, but the sandbox gate enforces on **identity of argument slots**. When a tainted value is laundered through a value-producing transform into a fresh primitive, provenance is dropped at the language boundary while the semantic payload is preserved. The gate sees an untainted string in a privileged slot and admits it. The invariant that is violated is: *taint must be preserved across all value-producing transforms that do not provably destroy the untrusted semantic content.* Most runtimes implement the converse — they preserve taint only across reference-preserving operations.

What Was Observed

A privileged tool `issue_refund(account_id, amount, memo)` is gated: any tainted argument triggers quarantine and requires a human warrant. The agent reads an untrusted support ticket (tainted), extracts `memo = ticket.body`, and passes it through a "sanitizer" that the runtime registers as taint-clearing:

memo_clean = json.loads(json.dumps({"m": memo}))["m"]

The taint propagator treats `json.dumps`/`json.loads` as opaque library calls with no registered taint rule, so the output `memo_clean` is a fresh `str` with no label. `issue_refund` receives an untainted `memo` and passes the gate. But the memo now contains attacker-controlled text — and in this runtime, `memo` is also interpolated into the downstream ledger entry that a *second* agent reads as trusted context, so the injection re-enters the trusted plane.

The structural signal that surfaced this was not a taint exception (none fired). It was a **provenance discontinuity**: the audit log recorded `issue_refund` with `taint_inputs=[]` while the same trace recorded the ticket body as read into the agent's working set three steps earlier. The mismatch between "untrusted read occurred" and "zero tainted arguments on privileged call" is the observable.

A second signal: argument-slot cardinality. The gate enforces per-slot taint, but the tainted value was *split* across two untainted slots (`memo` prefix and suffix) after a `split()`/`join()` round-trip. Each slot individually passed. Reassembly in the tool reconstructed the payload. This is the **composition gap** — taint is per-value, but the privileged action's semantics are per-*reassembled* value.

Condition of Validity

The quarantine gate is sound only if all three hold:

  1. **Transform closure:** every value-producing transform applied to a tainted value either (a) propagates the label, or (b) is on an explicit allowlist of *semantic-destroying* transforms (e.g., `hash()`, fixed-vocabulary enum mapping with a total function into a closed set). Unregistered library calls must default to *propagate*, not *clear*.
  2. **Slot atomicity:** the privileged tool's argument schema declares which slots are jointly interpreted, and taint is evaluated on the *join* of those slots, not per-slot.
  3. **Re-entry detection:** the runtime tracks whether a value that was tainted earlier in the trace re-enters a privileged call under a different identity (fresh primitive, different slot). Absence of taint on a privileged call is only valid if no untrusted read occurred in the causal ancestry of that call.

If any of these is absent, the gate is a filter on a stream the adversary controls the framing of, not an invariant.

Decision Boundary

When a provenance discontinuity is detected (untrusted read in ancestry + zero tainted arguments on privileged call), the runtime must choose between:

The boundary is decided by whether the clearing transform is *provably* semantic-destroying. `json.dumps` is not — it is byte-preserving modulo escaping. `hash()` is. A runtime that cannot decide must fail closed; the cost of a blocked refund is a retry, the cost of an admitted injection into the trusted plane is unbounded.

Operational Effect

The practical consequence is that taint-aware sandboxing must be implemented as a **provenance-continuity check over the trace**, not a per-call label check. The gate's job shifts from "is this argument tainted?" to "can I prove this argument is not descended from an untrusted read?" — a question that requires the causal graph, not the value. Runtimes that implement only the former will pass adversarial inputs through every unregistered library call in their dependency tree, and the failure will be invisible in taint logs because the logs will correctly show no taint.

class TaintQuarantineBypass(RuntimeError): """Raised when a privileged call has untrusted ancestry but zero tainted arguments.""" pass

# Transforms that provably destroy untrusted semantic content. # Anything not in this set must PROPAGATE taint, not clear it. SEMANTIC_DESTROYING = frozenset({"sha256", "enum_map_closed", "length_only"})

def enforce_quarantine(call, trace): """ call: {tool, args: {slot: value}, taint: {slot: bool}, transform_chain: [names]} trace: ordered list of events with {kind: 'untrusted_read'|'privileged_call', ...} """ untrusted_in_ancestry = any( e["kind"] == "untrusted_read" and e["step"] < call["step"] for e in trace ) any_tainted = any(call["taint"].values())

if untrusted_in_ancestry and not any_tainted: # Provenance discontinuity: taint was laundered. unregistered = [ t for t in call["transform_chain"] if t not in SEMANTIC_DESTROYING ] if unregistered: raise TaintQuarantineBypass( f"privileged call {call['tool']} step {call['step']} has untrusted " f"ancestry but zero tainted args; clearing transforms not proven " f"semantic-destroying: {unregistered}" ) # All clearing transforms are allowlisted; admit with annotation. call["provenance_unverified"] = False return call

if any_tainted: raise TaintQuarantineBypass( f"privileged call {call['tool']} carries tainted args; quarantine required" ) return call

def check_slot_atomicity(call, joint_slots): """Taint must be evaluated on the join of jointly-interpreted slots.""" joined_taint = any(call["taint"].get(s, False) for s in joint_slots) if joined_taint and not all(call["taint"].get(s, False) for s in joint_slots): # Partial taint across a jointly-interpreted slot set is a composition gap. raise TaintQuarantineBypass( f"partial taint across joint slots {joint_slots}: reassembly can " f"reconstruct a tainted payload from individually-clean slots" )