# Why does an instance of taint-aware tool gating fail when provenance labels decohere across a re-plan boundary? **Date of Record:** 2026 November 29 **Scope:** Applies to LLM agents that carry per-value taint/provenance labels (e.g., `UNTRUSTED` from tool output, `SECRET` from a vault read) through a planner-executor loop and gate tool invocation on those labels. Does not apply to stateless single-shot function calling, nor to gateways that re-derive taint from scratch on every call. ## Core Distinction Taint-aware gating is usually modeled as a *per-call* predicate: before invoking a tool, inspect the arguments' provenance labels and reject if an `UNTRUSTED`-tainted value flows into a `SENSITIVE_SINK` parameter. That model is correct only if the label set is a *monotone, instance-wide* lattice. The failure mode here is subtler: the **planner and the executor hold divergent taint states after a re-plan**, because the planner reasons over *symbolic argument descriptions* (which it rewrites, summarizes, and re-emits as natural language) while the executor gates over *concrete values* (which retain their original labels). When the planner re-plans mid-task—e.g., after a tool error—it reconstructs the argument list from its context rather than from the executor's value store. The reconstruction **launders taint**: a value that was `UNTRUSTED` in the executor's store is re-described by the planner as a plain string literal, and the executor, seeing a literal, assigns it the default `TRUSTED` label. The gate passes. The invariant that was violated is not "untrusted data must not reach a sink" but the stronger **label-continuity invariant**: *a value's taint label must survive every re-representation of that value between the moment it is produced and the moment it is consumed.* Re-planning is a re-representation, and it is the one the gate does not cover. ## What Was Observed A three-tool agent (`fetch_url` → `summarize` → `send_email`) was tasked with reading a web page and emailing a digest. The page body was correctly labeled `UNTRUSTED` at fetch time. The first `summarize` call succeeded; the executor stored the summary under the same `UNTRUSTED` label. On the `send_email` call, the SMTP tool returned a transient `421` error. The runtime triggered a re-plan: the planner was re-invoked with the conversation history (which contained the summary *as text*, not as a labeled handle) and asked to produce a corrected call. The planner emitted `send_email(to="ops@…", body="")` inline. The executor parsed the arguments, saw a string literal in `body`, and tagged it `TRUSTED` by default. The gate—which only blocks `UNTRUSTED → body`—admitted the call. The trace shows the exact transition: 1. `t0` fetch returns `body` with label `{UNTRUSTED, src=web}`. Executor store: `v7 → (text, UNTRUSTED)`. 2. `t1` summarize consumes `v7`, produces `v9` with label `{UNTRUSTED}` (label propagated). 3. `t2` send_email(`body=v9`) → `421`. Executor retains `v9` in store, still `UNTRUSTED`. 4. `t3` re-plan. Planner context contains the *rendered* text of `v9` (because the history serializer inlines labeled handles as plain text). Planner emits a fresh literal. 5. `t4` executor binds the literal to a new handle `v11` with default label `TRUSTED`. Gate admits. Email sent. The critical observation: at no point did any component *decide* to declassify. The label was dropped by an unlabeled serialization boundary between planner and executor. This is a **decoherence**, not a policy violation: two components that were supposed to share one label lattice ended up with two. ## Condition of Validity The per-call gate is sound only under the conjunction: - **(C1) Handle preservation:** every value crossing the planner↔executor boundary crosses as an opaque handle (`v9`), never as inlined text. - **(C2) Label monotonicity:** the executor never assigns a *weaker* label to a value than any label previously attached to the handle it derives from. - **(C3) Re-plan is not a declassifier:** a re-plan must not be able to introduce a literal that is semantically identical to a previously labeled value but carries no label. (C1) fails the moment the history serializer inlines handles for readability—a near-universal convenience. (C2) fails because default-labeling of literals is `TRUSTED`, which is the *bottom* of the taint lattice, so any literal is a declassification. (C3) fails because the planner has no mechanism to know that the text it is echoing was previously labeled; it sees tokens, not provenance. All three fail together, which is why the bug is non-obvious: each component is individually correct, and the composition is unsound. The invariant required to bound this is not per-call but **end-to-end label continuity across re-representation**: for every value `v` consumed by a sink, there must exist an unbroken chain of label-preserving derivations from `v`'s origin to its consumption, and any re-representation (summarize, re-plan, serialize) must either preserve the handle or be treated as a *new* value whose label is the join of all values it was derived from. The second clause is the one that catches re-plan laundering: a literal that the planner emits while the handle `v9` is in scope must inherit `v9`'s label, because the planner could only have produced that literal by reading `v9`. ## Decision Boundary The boundary between "safe re-plan" and "laundering re-plan" is whether the planner's emitted argument is **grounded in a labeled handle that is still live in the executor store**. Operationally: - If the re-planned call references handles (`body=v9`), the gate evaluates against `v9`'s label. Safe. - If the re-planned call inlines a literal, the executor must attempt **provenance re-attribution**: fuzzy-match the literal against the live labeled values in scope. On a match above a similarity threshold, inherit the matched value's label (join, not replace). On no match, the literal is genuinely new and may default to `TRUSTED`—but only if it was not derived from any labeled value, which the executor cannot verify and must therefore treat conservatively. The conservative rule: **any literal emitted during a re-plan inherits the join of all `UNTRUSTED`/`SECRET` labels live in the planner's context at re-plan time.** This over-taints (a genuinely new literal gets blocked), but over-tainting fails closed, and the failure is visible as a gate rejection rather than a silent exfiltration. The threshold is a tuning parameter, but the *direction* of the default is not: when provenance is ambiguous, the label must be the join of the candidates, never the bottom. ## Operational Effect Without the continuity invariant, taint gating provides a false sense of security: it blocks the naive injection path (tool output passed directly to a sink in the same turn) while admitting the re-plan path, which is exactly the path an adversary can induce by causing a transient tool failure. The attacker does not need to inject into the planner's prompt; they only need the sink tool to fail once, forcing a re-plan that re-serializes the tainted value as a literal. The gate's logs will show a clean `TRUSTED` argument and a successful send. With the invariant enforced, the re-plan either preserves handles (preferred) or re-attributes labels conservatively, and the exfiltration attempt surfaces as a gate rejection the operator can audit. The cost is a small rate of false rejections on legitimately new literals produced during re-plans—acceptable, because the alternative is an unauditable declassification channel that no per-call predicate can see. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import IntEnum from typing import Iterable class Taint(IntEnum): TRUSTED = 0 UNTRUSTED = 1 SECRET = 2 def join(*labels: Taint) -> Taint: return Taint(max(labels, default=Taint.TRUSTED)) class TaintContinuityError(RuntimeError): """Raised when a re-planned argument cannot be proven label-continuous.""" @dataclass class LabeledValue: handle: str text: str label: Taint @dataclass class ExecutorStore: values: dict[str, LabeledValue] = field(default_factory=dict) def put(self, handle: str, text: str, label: Taint) -> None: self.values[handle] = LabeledValue(handle, text, label) def live_labels(self) -> Iterable[Taint]: return (v.label for v in self.values.values()) def gate_replanned_argument( store: ExecutorStore, arg_name: str, *, handle: str | None = None, literal: str | None = None, sink_requires: Taint = Taint.UNTRUSTED, ) -> Taint: """ Gate one argument of a re-planned tool call. Invariant: the argument's effective label must be >= the join of all live labels in the planner's context if the argument is a literal, and must equal the handle's label if it is a handle reference. """ if handle is not None and literal is not None: raise TaintContinuityError( f"argument {arg_name!r} is both a handle and a literal; ambiguous provenance" ) if handle is not None: if handle not in store.values: raise TaintContinuityError( f"argument {arg_name!r} references dead handle {handle!r}; " "label continuity broken (handle evicted before re-plan)" ) effective = store.values[handle].label elif literal is not None: # Re-plan laundering guard: a literal emitted while labeled values are # live must inherit the join of those labels, not the bottom. live = list(store.live_labels()) if live: effective = join(*live) else: effective = Taint.TRUSTED else: raise TaintContinuityError( f"argument {arg_name!r} has neither handle nor literal" ) if effective > sink_requires: raise TaintContinuityError( f"argument {arg_name!r} carries {effective.name} > sink allows " f"{sink_requires.name}; re-plan did not preserve label continuity" ) return effective # --- reproduction of the observed failure --- store = ExecutorStore() store.put("v7", "", Taint.UNTRUSTED) store.put("v9", "", Taint.UNTRUSTED) # Safe re-plan: handle preserved. assert gate_replanned_argument(store, "body", handle="v9") == Taint.UNTRUSTED # Observed failure: re-plan inlined v9 as a literal. Under the naive gate this # passed; under the continuity gate it must be rejected. try: gate_replanned_argument(store, "body", literal="") except TaintContinuityError as exc: print(f"blocked: {exc}") else: raise TaintContinuityError("laundering re-plan was admitted; gate is unsound") ```