# Which invariants prevent taint-laundering across sandbox re-instantiation when capability revocation lands mid-tool-call **Date of Record:** 2026 November 30 **Scope:** Applies to agent runtimes that propagate taint labels (untrusted-provenance bits) alongside tool-call arguments and that revoke capabilities dynamically upon injection detection. Does not address static allow-list sandboxing without taint tracking, nor prompt-level filtering that never reaches the capability layer. ## Core Distinction The naive model treats taint as a property of *data*: an argument is either tainted or not, and a tainted argument blocks a privileged tool. The operational reality is that taint is a property of the *(data, capability-instance, call-frame)* triple, and revocation is an *event* that races the call it is meant to interrupt. The failure mode is not "tainted data reaches a privileged tool." It is **taint laundering via re-instantiation**: an injection is detected, the capability is revoked, the sandbox is torn down and rebuilt to apply the revocation, and the rebuilt instance re-admits the same in-flight arguments under a fresh capability handle whose taint set was initialized empty because the taint ledger lived inside the destroyed sandbox. The revocation succeeded; the taint did not survive the revocation. The invariant that matters is not "revoke on detection" but "**taint provenance is monotonically non-decreasing across capability generations, and revocation is a barrier that flushes or quarantines in-flight frames rather than a reset that clears them.**" ## What Was Observed A three-tool pipeline: `fetch_doc` (untrusted egress, returns web content), `summarize` (LLM call, no side effects), and `send_email` (privileged, external side effect). The runtime tags `fetch_doc` output with taint label `T_EXT`. `send_email` refuses arguments carrying `T_EXT` unless the argument was produced by a `summarize` frame whose *inputs* were reviewed — a declassification rule. Trace of the failure: 1. `fetch_doc` returns content containing an injected instruction. Output argument `d1` is labeled `{T_EXT}`. Correct. 2. `summarize(d1)` begins. The frame's taint context is `{T_EXT}`. The injection-detection classifier fires mid-frame on the *tool-call arguments* of a nested `send_email(recipient=attacker, body=d1)` that the model emitted inside the summarize step. 3. Detector emits `revoke(send_email)`. The revocation controller tears down the sandbox generation `G_n`, writes a revocation record, and spawns generation `G_{n+1}` with `send_email` removed from the capability table. 4. The in-flight `summarize` frame is *resumed* in `G_{n+1}` by replaying its last checkpoint. The checkpoint serialized the conversation and the tool result `d1`, but **the taint ledger was a sandbox-local structure not included in the checkpoint schema**. On resume, `d1` is re-materialized as plain text with an empty taint set. 5. The model, now in `G_{n+1}`, re-emits `send_email(recipient=attacker, body=d1)`. `send_email` is gone — so this specific call fails. But the *declassification gate* for the next privileged tool, `post_webhook` (still present), reads `d1`'s taint as `∅`, treats it as trusted-origin, and admits it. Observed result: the revocation removed the *named* capability but the taint reset let the same payload reach a *sibling* privileged capability. Revocation fired correctly; containment failed because taint did not cross the generation boundary. The detector's true positive produced a false negative downstream. ## Condition of Validity The laundering is only possible when all of the following hold simultaneously: - **Taint ledger is sandbox-local.** If taint labels are stored in a durable, generation-independent store keyed by content hash, re-instantiation cannot clear them. - **Checkpoint/resume is the recovery path after revocation.** If revocation instead *aborts* the frame and requires the agent to re-derive arguments from scratch under a re-tainted read, the payload must pass through `fetch_doc` again and is re-labeled. - **Revocation is scoped to a capability name, not to the tainted data lineage.** Revoking `send_email` leaves `post_webhook` as a laundering sink. - **Declassification is a positive check ("is this argument clean?") rather than a negative check ("is this argument provably clean, defaulting to tainted on unknown").** A default-tainted policy would have blocked step 5. The invariant holds (no laundering) iff **taint is bound to content identity, not to sandbox instance, and revocation is a lineage barrier: any frame whose taint context intersects a revoked capability's admitted-taint set is quarantined, not resumed.** ## Decision Boundary The boundary is between two revocation semantics: | | **Reset semantics** (broken) | **Barrier semantics** (correct) | |---|---|---| | Revocation action | tear down, rebuild, resume frame | tear down, mark lineage, quarantine intersecting frames | | Taint on resume | re-initialized empty | carried from durable content-keyed ledger | | Scope | capability name | capability name + taint lineage set | | In-flight frames | replayed | aborted; agent must re-read sources | | Sibling capabilities | unaffected | blocked for the tainted lineage until re-derivation | Choose barrier semantics whenever *any* privileged capability shares a taint-admission rule with the revoked one, or whenever checkpoint/resume is enabled. Choose reset semantics only if revocation is the *sole* privileged capability (no sibling sink) and no resume path exists — a configuration that essentially never holds in practice. The decision must be made at design time because it determines whether the checkpoint schema includes the taint ledger. Retrofitting barrier semantics onto a schema that omitted taint requires invalidating every existing checkpoint — a hard cutover. ## Operational Effect Under barrier semantics, the observed trace changes at step 4: the resume of the `summarize` frame is refused because its taint context `{T_EXT}` intersects the revoked lineage. The agent is forced to re-invoke `fetch_doc`, which produces fresh `T_EXT`-labeled content, and the declassification gate — now reading a non-empty taint set — blocks `post_webhook`. The injection is contained at the cost of one redundant fetch. Under reset semantics, the cost is a silent exfiltration. The general operational rule: **a revocation that does not also revoke the taint-cleanliness of data derived from the triggering frame is a no-op against sibling sinks.** Detection without lineage-scoped revocation converts a true positive into a laundering event. Every revocation handler must answer, before resuming any frame: *what is the taint set of every argument this frame will re-emit, and where did that set come from?* If the answer is "the sandbox," the invariant is already broken. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import FrozenSet class TaintLaunderingError(RuntimeError): """Raised when a resumed frame would re-emit arguments whose taint set was lost across a capability-generation boundary.""" @dataclass(frozen=True) class TaintedValue: content_hash: str taint: FrozenSet[str] @dataclass class TaintLedger: """Durable, generation-independent, keyed by content identity.""" _by_hash: dict[str, set[str]] = field(default_factory=dict) def label(self, content_hash: str, labels: set[str]) -> None: self._by_hash.setdefault(content_hash, set()).update(labels) def taint_of(self, content_hash: str) -> FrozenSet[str]: # Default-tainted: unknown content is assumed untrusted, never clean. return frozenset(self._by_hash.get(content_hash, {"T_UNKNOWN"})) @dataclass class Frame: frame_id: str args: list[TaintedValue] capability: str def resume_frame_after_revocation( frame: Frame, ledger: TaintLedger, revoked_lineage: FrozenSet[str], sibling_privileged_caps: FrozenSet[str], ) -> None: # Recompute taint from the durable ledger, never from sandbox state. resumed_taint: set[str] = set() for arg in frame.args: resumed_taint |= ledger.taint_of(arg.content_hash) if resumed_taint & revoked_lineage: raise TaintLaunderingError( f"frame {frame.frame_id!r} resumed with taint {sorted(resumed_taint)} " f"intersecting revoked lineage {sorted(revoked_lineage)}; " f"quarantine required, not resume" ) if frame.capability in sibling_privileged_caps and resumed_taint: raise TaintLaunderingError( f"frame {frame.frame_id!r} targets privileged sibling " f"{frame.capability!r} with non-empty taint {sorted(resumed_taint)}; " f"declassification gate must refuse" ) ```