# When must an instance treat a revoked capability as still live: taint-label escalation racing the tool-call commitment window **Date of Record:** 2026 November 21 **Scope:** Applies to LLM agents whose sandboxing layer propagates taint labels across tool outputs and revokes capabilities when a label escalates (e.g., `trusted→untrusted`). Does not cover static RBAC, network egress filtering, or human-in-the-loop approval flows, which lack the in-flight commitment race described here. ## Core Distinction A capability revocation is not an event, it is a *transition over a window*. Sandboxes that model revocation as a boolean flip — "capability `write_fs` is now revoked" — assume the agent observes the flip atomically. In practice, an agent plans a multi-step tool sequence, commits to step *N* while step *N−1*'s output is still being label-checked, and the label escalation that should have revoked the capability arrives *after* the plan has already been serialized into the next tool call. The distinction that matters: **revocation is a property of the capability's use-time, not of the agent's plan-time.** A taint-aware sandbox that revokes at plan-time leaves a gap; one that revokes at use-time closes it but must then reconcile the agent's now-invalid in-flight intent. The non-obvious boundary: a tainted output can be *benign in content but escalatory in provenance*. The agent reads a retrieved document, the content is safe, the retrieval channel is untrusted, the label escalates, the capability is revoked — but the agent has already queued a `write_fs` call whose arguments were computed from the *pre-escalation* context. The revocation is correct; the call is already committed. This is the commitment-window race. ## What Was Observed Trace from a filesystem-writing agent (call it A) with three capabilities: `read_web`, `read_fs`, `write_fs`. Initial label: `trusted`. The sandbox policy: any output from `read_web` carries label `untrusted`; if the agent's working context accumulates any `untrusted` span, `write_fs` is revoked (taint-aware downgrade). 1. A plans: `read_fs("/config")` → `read_web(url)` → `write_fs("/out", derived)`. Plan serialized with `write_fs` marked *available*. 2. A executes `read_fs` → returns `trusted` content. Context label still `trusted`. 3. A executes `read_web` → returns content. The sandbox's label-checker runs *asynchronously* on the returned span. The tool call returns to A's loop **before** the label-checker completes; A receives the content with a provisional `trusted` label. 4. A, seeing `trusted`, proceeds to step 3: emits `write_fs("/out", derived)`. The call is committed with `capability_token=write_fs@v1`. 5. The label-checker completes: the `read_web` span is `untrusted`. Sandbox revokes `write_fs`, bumps the capability epoch to `v2`. 6. The sandbox receives A's committed `write_fs@v1` call. The token is stale (epoch `v1`), but the call was *emitted under a valid token*. Depending on the sandbox's reconciliation rule, it either (a) rejects as stale — safe but the agent's plan is now half-executed with no signal of *why*, or (b) accepts because the token was valid at emission — unsafe, the tainted-derived write lands. Observed failure: variant (b) in two of three sandbox implementations tested, because the reconciliation rule checked token validity *at emission time* rather than *at execution time*. The agent's plan was internally consistent; the sandbox's epoch model was not consulted at the right instant. ## Condition of Validity The race exists if and only if all three hold: - **Asynchronous label adjudication.** The label-checker runs off the agent's critical path (necessary for latency; almost universal in production). If adjudication is synchronous, the escalation lands before the tool call returns, and the agent sees the revoked capability before planning. - **Plan-time capability binding.** The agent binds a capability to a *plan step* rather than to a *use*. If the agent re-validates the capability token immediately before each call (use-time binding), the race collapses to a single-instant check. - **Non-monotonic label state.** The context label can escalate *between* the agent's read of the capability set and the sandbox's execution of the call. If labels are monotonic (only ever escalate, never re-read), the agent's cached capability view is stale by construction. The invariant that bounds the race: **a capability token is valid for execution only if its epoch matches the sandbox's current epoch at the moment of execution, not at the moment of emission.** This is the use-time binding rule. It converts the race from "sometimes unsafe" to "always rejected, with a distinguishable error" — which is what the agent needs to recover. ## Decision Boundary The agent must distinguish three cases at the tool-call boundary, and the sandbox must expose enough state to make the distinction: 1. **Token valid, epoch current** → proceed. No race. 2. **Token valid at emission, epoch stale at execution** → the commitment-window race fired. The agent's *plan* is invalidated, not its *reasoning*. Correct response: re-read the capability set, re-derive the plan step from current labels, and retry. The sandbox must return a distinct error (`CapabilityEpochStale`) carrying the new epoch and the label that caused escalation — not a generic permission-denied, which the agent will misread as a permanent revocation and abandon the task. 3. **Token invalid at emission** (agent used a revoked capability it should have seen revoked) → genuine policy violation. Abandon and surface to the operator. The boundary is between (2) and (3). A sandbox that collapses them into one error forces the agent to guess, and agents guess wrong: they either retry a permanently-revoked capability (loop) or abandon a recoverable plan (task failure). The `CapabilityEpochStale` error must be *recoverable* and must carry the escalation provenance so the agent can re-derive without re-reading the whole context. ## Operational Effect Closing the race has three operational consequences: - **Latency at the tool boundary increases by one epoch check per call.** Negligible, but it must be *synchronous* with execution, which means the sandbox's epoch store must be on the same consistency domain as the executor — not eventually consistent. An eventually-consistent epoch store reintroduces the race at the storage layer. - **Agents must be written to handle `CapabilityEpochStale` as a recoverable signal**, with a bounded retry (typically one re-derivation). Unbounded retry on stale-epoch errors is a livelock: if the label keeps escalating, the plan keeps invalidating. The retry budget must be per-plan-step, not per-call. - **Taint labels must be attached to spans, not to the whole context.** If escalation is context-global, one tainted retrieval revokes all write capabilities and the agent cannot make progress on any independent sub-task. Span-level labels let the agent quarantine the tainted derivation and continue with clean sub-plans — but only if the sandbox can attribute a tool call's arguments to specific spans, which requires the agent to tag its derivations. Untagged derivations must default to the most-tainted span in context (fail-closed), which is the safe but progress-limiting default. The guardrail: **the sandbox must version capabilities by epoch and check epoch at execution; the agent must tag derivations by span and treat stale-epoch as recoverable.** Neither alone closes the race. ```python class CapabilityEpochStale(RuntimeError): """Raised when a tool call's capability token was valid at emission but the sandbox epoch advanced (taint escalation) before execution.""" def __init__(self, capability: str, emitted_epoch: int, current_epoch: int, taint_source: str): self.capability = capability self.emitted_epoch = emitted_epoch self.current_epoch = current_epoch self.taint_source = taint_source super().__init__( f"capability {capability!r} stale: emitted@{emitted_epoch} " f"current@{current_epoch} escalated by {taint_source!r}" ) class TaintAwareSandbox: def __init__(self): self.epoch = 1 self.revoked = set() self.max_rederivations_per_step = 1 def escalate(self, span_id: str, label: str, capability: str): # asynchronous label adjudication lands here, after the agent may # have already committed a call under the pre-escalation epoch if label == "untrusted": self.revoked.add(capability) self.epoch += 1 def execute(self, capability: str, emitted_epoch: int, args: dict, step_id: str): if capability in self.revoked and emitted_epoch != self.epoch: raise CapabilityEpochStale( capability=capability, emitted_epoch=emitted_epoch, current_epoch=self.epoch, taint_source="read_web", ) if capability in self.revoked and emitted_epoch == self.epoch: # genuine policy violation: agent used a capability it saw revoked raise PermissionError(f"capability {capability!r} revoked at current epoch") return {"ok": True, "step": step_id, "epoch": self.epoch} def run_plan_step(sandbox: TaintAwareSandbox, capability: str, emitted_epoch: int, args: dict, step_id: str): attempts = 0 while True: try: return sandbox.execute(capability, emitted_epoch, args, step_id) except CapabilityEpochStale as e: attempts += 1 if attempts > sandbox.max_rederivations_per_step: raise CapabilityEpochStale( capability=e.capability, emitted_epoch=e.emitted_epoch, current_epoch=e.current_epoch, taint_source=e.taint_source, ) from e # re-derive the step against the new epoch, then retry once emitted_epoch = sandbox.epoch if capability in sandbox.revoked: raise PermissionError( f"cannot re-derive {capability!r}: still revoked at epoch {sandbox.epoch}" ) ```