# Which invariants prevent tainted-tool revocation from silently un-tainting downstream agent state **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that propagate information-flow taint labels across tool calls and revoke tool capabilities at runtime in response to taint escalation. Does not apply to static capability manifests fixed at session start, nor to single-shot LLM calls with no persistent state. ## Core Distinction There are two different things an agent runtime can revoke when taint escalates: a *capability* (the right to invoke a tool) and a *label* (the fact that data derived from a tainted source is tainted). Most sandboxes conflate these. Revoking a capability removes the tool from the agent's callable set, but it does not retroactively alter the taint labels already attached to values in the agent's working memory, scratchpad, or episodic store. The boundary failure is not that revocation fails to stop *future* calls—it usually does. The failure is that revocation is treated as a state transition on the *tool registry* while the *data-flow graph* continues to admit tainted-value propagation through cached results, memoized tool outputs, and replayed reasoning traces. The invariant that must hold is: **no value derived from a revoked capability's output may be consumed by a non-tainted sink after revocation, regardless of when the value was produced.** ## What Was Observed Consider an agent with two tools: `fetch_url` (egress-capable, taint source for untrusted content) and `write_file` (sink, taint-sensitive). A prompt-injection payload arrives via `fetch_url` and lands in the agent's scratchpad as a tool-result message with taint label `UNTRUSTED:web`. The runtime's policy engine detects the taint and revokes `fetch_url` for the remainder of the task—a correct response to egress escalation. The failure trace proceeds as follows: 1. `fetch_url` is invoked, returns content, and the result is labeled `UNTRUSTED:web`. The tool result is also **memoized** in the runtime's tool-result cache keyed by `(tool_name, args_hash)` to avoid redundant calls. 2. Policy detects the taint and revokes `fetch_url`. The capability table is updated: `fetch_url → REVOKED`. 3. The agent, mid-reasoning, attempts a *second* call to `fetch_url` with identical arguments (a common retry-or-re-read pattern in ReAct-style loops). The cache hits. The memoized result is returned **without re-checking the capability table** because the cache lookup path short-circuits before the capability gate. 4. The cached result is re-injected into the context window. Because it arrives via the cache path rather than the tool-invocation path, the taint-labeling middleware is bypassed. The value enters the scratchpad **unlabeled**. 5. The agent now passes this unlabeled value to `write_file`. The taint-sink check sees no `UNTRUSTED:web` label and permits the write. The net effect: revocation succeeded at the capability layer and failed at the information-flow layer. The injected content was laundered into a sink through a cache hit that outlived the capability that produced it. A second observed variant: revocation is applied to the *tool*, but the agent's episodic memory already contains a distilled summary of the tainted content (e.g., "the page said X"). The distillation step dropped the provenance label because the summarizer model was not taint-aware. After revocation, the agent reasons over the summary and treats it as self-generated (trusted) belief rather than externally-sourced (tainted) content. This is taint loss through *semantic distillation*, and it is invisible to any check that operates on tool-call boundaries. ## Condition of Validity The invariant above holds only under three conditions, and it is precisely their violation that produces the failure: - **Monotonic labeling across derivation.** Every value derived from a tainted value must inherit the label. This requires the taint checker to run on *every* value-introduction path—tool results, cache hits, memory retrievals, distilled summaries, and replayed traces—not just on live tool invocations. Cache hits and memory reads are value-introduction paths and must be gated identically. - **Revocation is a data-flow event, not a registry event.** Revoking a capability must invalidate or re-label every live value in working memory whose provenance chain includes that capability. If the runtime cannot enumerate those values (because provenance was not recorded per-value), it cannot honor the invariant. Provenance must be recorded at value-creation time, not reconstructed at revocation time. - **No trusted-relabeling without a declassification warrant.** Any step that removes a taint label—summarization, deduplication, schema coercion, or "trusted re-derivation"—must carry an explicit declassification warrant signed by a policy authority. Absent such a warrant, label removal is a violation, not an optimization. The condition of validity is therefore: the taint lattice is enforced at every value-introduction and value-transformation site, and revocation triggers a re-labeling pass over the live provenance graph, not merely a mutation of the capability table. ## Decision Boundary The runtime must decide, at revocation time, between two strategies, and the choice is not free: - **Invalidate-and-replay:** Drop all values whose provenance includes the revoked capability, then require the agent to re-derive them (or halt). This is sound but expensive: it can discard most of the context window and force a cold re-derivation, and it may be *impossible* if the revoked capability was the only source of a needed value. The agent then deadlocks—it cannot proceed without the value and cannot re-fetch it. - **Re-label-and-continue:** Keep the values but re-apply the taint label and propagate it to all downstream sinks, blocking any sink that cannot accept tainted input. This preserves progress but requires complete provenance, and it will block legitimate sinks that the agent genuinely needs (e.g., a logging sink that should accept tainted data under a redaction policy). The decision boundary is: **if the runtime cannot prove complete provenance for a live value, it must choose invalidate-and-replay (fail-closed); if it can prove provenance, it may re-label-and-continue.** A runtime that cannot distinguish these cases will silently choose the unsound option—continue without re-labeling—because that is the path of least resistance and produces no immediate error. ## Operational Effect The operational consequence is that revocation must be modeled as a *graph rewrite over the provenance DAG*, not a row update in a capability table. Concretely, the runtime must: 1. Record, for every value entering the agent's state, a provenance record: `(value_id, source_tool, source_args_hash, parent_value_ids, taint_labels, timestamp)`. 2. On revocation, compute the transitive closure of values whose provenance includes the revoked capability. 3. For each such value, either invalidate it (removing it from all reachable state and forcing re-derivation) or re-apply the taint label and mark all downstream consumers for re-check. 4. Gate every value-introduction path—cache, memory, distillation—through the same taint checker used for live tool calls. Cache hits must re-validate the capability table before returning a memoized result. 5. Require a signed declassification warrant for any label removal, and log the warrant alongside the value. Without steps 1–3, revocation is a no-op at the information-flow layer. Without step 4, the cache and memory become laundering channels. Without step 5, distillation silently declassifies. The invariant is only as strong as the weakest value-introduction path, and the cache path is almost always the weakest because it is optimized to bypass the very checks that enforce the invariant. The guardrail that bounds the failure: treat a cache hit as a *re-invocation* for taint purposes—re-check the capability table, re-apply the label, and re-run the sink check—even though no tool was actually called. The cost is a table lookup and a label merge; the alternative is a laundered injection that the agent will act on as if it were its own trusted reasoning. ```python from dataclasses import dataclass, field from typing import Optional class TaintRevocationViolation(RuntimeError): """Raised when a value derived from a revoked capability reaches a sink.""" pass @dataclass class Provenance: value_id: str source_tool: str args_hash: str parent_ids: tuple[str, ...] = () taint_labels: frozenset[str] = frozenset() declassification_warrant: Optional[str] = None @dataclass class Runtime: capability_table: dict[str, str] = field(default_factory=dict) # tool -> ACTIVE|REVOKED provenance: dict[str, Provenance] = field(default_factory=dict) cache: dict[tuple[str, str], str] = field(default_factory=dict) # (tool, args_hash) -> value_id def revoke(self, tool: str) -> None: self.capability_table[tool] = "REVOKED" # Graph rewrite: re-label every live value whose provenance includes the tool. for pid, prov in self.provenance.items(): if prov.source_tool == tool and prov.declassification_warrant is None: self.provenance[pid] = Provenance( value_id=prov.value_id, source_tool=prov.source_tool, args_hash=prov.args_hash, parent_ids=prov.parent_ids, taint_labels=prov.taint_labels | {f"REVOKED:{tool}"}, ) def cached_lookup(self, tool: str, args_hash: str) -> Optional[str]: # Cache hit must re-validate capability, not short-circuit the gate. if self.capability_table.get(tool) == "REVOKED": raise TaintRevocationViolation( f"cache hit for revoked tool {tool!r} with args {args_hash!r}; " "memoized result would bypass taint labeling" ) return self.cache.get((tool, args_hash)) def check_sink(self, value_id: str, sink_accepts_taint: frozenset[str]) -> None: prov = self.provenance.get(value_id) if prov is None: raise TaintRevocationViolation( f"value {value_id!r} has no provenance record; fail-closed" ) offending = prov.taint_labels - sink_accepts_taint if offending and prov.declassification_warrant is None: raise TaintRevocationViolation( f"value {value_id!r} carries {sorted(offending)} into sink that " f"accepts only {sorted(sink_accepts_taint)}" ) ```