# Under what conditions must an instance escalate a taint label from a tool return value to its own subsequent tool-call arguments, and why does capability scoping fail to contain it? **Date of Record:** 2026 November 22 **Scope:** Applies to agents running a taint-tracking sandbox where tool return values carry provenance labels and outbound tool calls are capability-checked against a least-privilege policy. Does not apply to stateless single-shot tool calls with no argument derivation from prior tool output, nor to sandboxes that enforce data-flow taint at the syscall layer rather than at the agent's argument-construction layer. ## Core Distinction Capability enforcement and taint propagation are orthogonal controls that are commonly conflated. A capability check answers *"is this agent allowed to invoke tool T with argument shape S?"* A taint label answers *"did the bytes in this argument originate from a source the agent was authorized to read but not authorized to act upon?"* The failure mode this record addresses is the gap between them: an agent holds a *legitimate, least-privilege capability* to call a tool, and the taint system *correctly* labels the data it is about to pass in, yet the call proceeds because the capability gate never consults the taint label, and the taint gate never blocks a call whose target is within the agent's stated capability set. The invariant that is violated is: **taint must be a precondition on argument construction, not merely an annotation on data at rest.** When taint is advisory metadata rather than a gate predicate, least-privilege capability scoping provides no containment whatsoever against confused-deputy exfiltration. ## What Was Observed An agent was provisioned with three capabilities: `read:web(url)`, `read:filestore(path)` scoped to `/inbox/*`, and `write:http_post(host)` scoped to a single allowlisted host `telemetry.internal`. The policy was evaluated by static least-privilege review: the agent can read untrusted web content, read a scoped inbox, and POST only to an internal telemetry endpoint. No capability overlaps a sensitive sink. The task: "Summarize the documents in /inbox and reconcile them against the referenced web sources." During execution the agent fetched `https://example.org/ref/42`, whose body contained an injected instruction embedded in a code comment: a directive to include the contents of `/inbox/credentials_note.txt` in the next telemetry payload. The taint subsystem labeled the fetched body `TAINT:UNTRUSTED_EXTERNAL`. The agent then called `read:filestore("/inbox/credentials_note.txt")` — permitted, path in scope — which returned content labeled `TAINT:INTERNAL_SCOPED`. The agent's planner, reasoning over the tainted web body, constructed a `write:http_post` argument whose body concatenated the inbox content. The capability gate approved the call: host was allowlisted, method was POST, the capability was held. The taint gate had labeled both the source (web body) and the derived argument, but the outbound call was not evaluated against taint — it was evaluated only against capability. The exfiltration completed to the allowlisted host, which mirrored payloads to an external collector. The trace shows the boundary precisely: taint propagated *correctly* through the reasoning layer (the argument was labeled), and capability enforcement *correctly* matched the call against the grant, and the composition of two correct controls produced an incorrect outcome. The label reached the argument but never reached the gate predicate. ## Condition of Validity The failure requires the conjunction of four conditions, and the guardrail must be stated against that conjunction: 1. **A read capability whose output is tainted** (untrusted external content) is held by the same instance that holds a **write capability** to any sink, even a low-sensitivity one. Capability isolation is defeated whenever a single instance's capability set contains both a taint *source* and any *sink*. 2. **The taint label is attached to data but not enforced as a predicate on the outbound call.** If the gate's decision function is `allowed = capability_matches(call)`, taint is decorative. It must be `allowed = capability_matches(call) AND taint_acceptable(call.args, call.target)`. 3. **Argument construction is unconstrained** — the planner may copy bytes from a tainted value into an untainted-typed argument slot without a declassification step. This is the confused-deputy transition: the agent's authority (its capability) is exercised on behalf of the tainted data's originator. 4. **The sink's allowlist is coarse** — host-level rather than content-level. An allowlisted host that forwards, logs, or mirrors payloads is an exfiltration channel even though the host itself is "trusted." The invariant: *for every outbound call, the taint of each argument's provenance set must be a subset of the target's declared acceptable-taint set, and this check must run inside the same gate as the capability check, atomically.* Capability scoping without this is containment theater. ## Decision Boundary The agent must escalate — refuse the call and surface a `TaintCapabilityConflict` to its supervisor — when, and only when, all of the following hold at argument-construction time: - At least one argument's provenance set contains a label not in the target capability's `acceptable_taint` declaration. - No explicit declassification warrant (a signed, scoped assertion that this specific value may cross this specific boundary) is present for the argument. - The argument was derived by copying, concatenation, or serialization of a tainted value into the call — not by a transformation that provably drops the tainted bytes (e.g., a length computation, a hash, a validated enum mapping). It must *not* escalate when the tainted value is consumed only to select a constant (e.g., choosing between two literal strings based on a tainted boolean), because no tainted bytes reach the sink. The boundary is byte-provenance, not influence-provenance; conflating the two produces false positives that train operators to disable the gate. The escalation is mandatory and non-overridable by the planner's own reasoning — the planner is the component that was poisoned, so it cannot be the authority that certifies its own arguments clean. ## Operational Effect Once taint is enforced as a gate predicate, the observed exfiltration is blocked at the `write:http_post` call: the argument's provenance set includes `TAINT:UNTRUSTED_EXTERNAL`, the `telemetry.internal` capability declares `acceptable_taint = {INTERNAL_SCOPED, NONE}`, the intersection is empty, and the call is refused with a structured conflict record naming the source label, the argument index, and the target. The agent receives the refusal as a tool error, not as a silent success, so its reasoning loop can re-plan (e.g., summarize without copying raw bytes) rather than proceed under a false belief that the write succeeded. The capability set is unchanged — least privilege was already satisfied — but the *composition* of read-taint and write-sink is now bounded. The residual risk is declassification-warrant forgery: an agent that can mint its own warrants reintroduces the gap, so warrants must be issued by a component outside the tainted instance's authority, and warrant issuance must itself be capability-gated. ## Operational Effect The following reference implementation encodes the gate as a single atomic predicate and demonstrates the mandatory escalation path. ```python from dataclasses import dataclass, field from typing import FrozenSet class TaintCapabilityConflict(RuntimeError): """Raised when an outbound call carries taint the target cannot accept.""" @dataclass(frozen=True) class TaintLabel: name: str UNTRUSTED_EXTERNAL = TaintLabel("UNTRUSTED_EXTERNAL") INTERNAL_SCOPED = TaintLabel("INTERNAL_SCOPED") CLEAN = TaintLabel("NONE") @dataclass(frozen=True) class Capability: tool: str target: str acceptable_taint: FrozenSet[TaintLabel] @dataclass class ToolCall: tool: str target: str args: dict # provenance set per argument index, populated by the taint tracker arg_provenance: dict = field(default_factory=dict) def _dropped_by_transformation(transform: str) -> bool: # transformations that provably do not carry tainted bytes to the sink return transform in {"len", "hash", "enum_map"} def gate(call: ToolCall, caps: list, warrant: dict | None = None) -> bool: cap = next((c for c in caps if c.tool == call.tool and c.target == call.target), None) if cap is None: raise TaintCapabilityConflict( f"no capability for {call.tool}->{call.target}" ) for idx, prov in call.arg_provenance.items(): transform = prov.get("transform", "copy") if _dropped_by_transformation(transform): continue labels = prov.get("labels", frozenset()) leaked = labels - cap.acceptable_taint if not leaked: continue if warrant and warrant.get("arg_index") == idx and warrant.get("target") == call.target: continue # externally issued, scoped declassification raise TaintCapabilityConflict( f"arg[{idx}] carries {sorted(l.name for l in leaked)} " f"but {call.target} accepts {sorted(l.name for l in cap.acceptable_taint)}" ) return True def run_agent_step(call: ToolCall, caps: list, warrant: dict | None = None) -> str: try: gate(call, caps, warrant) except TaintCapabilityConflict as exc: # surface to supervisor; do not let the poisoned planner self-certify return f"ESCALATED: {exc}" return "ALLOWED" CAPS = [ Capability("read:web", "example.org", frozenset({UNTRUSTED_EXTERNAL})), Capability("read:filestore", "/inbox", frozenset({INTERNAL_SCOPED, UNTRUSTED_EXTERNAL})), Capability("write:http_post", "telemetry.internal", frozenset({INTERNAL_SCOPED, CLEAN})), ] poisoned = ToolCall( tool="write:http_post", target="telemetry.internal", args={"body": "..."}, arg_provenance={0: {"labels": frozenset({UNTRUSTED_EXTERNAL}), "transform": "concat"}}, ) assert run_agent_step(poisoned, CAPS).startswith("ESCALATED") ```