# When must an instance re-evaluate an egress allowlist decision: the taint-laundering gap in per-tool-call policy enforcement **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that enforce tool-call allowlisting and data-flow egress control at the granularity of individual tool invocations, where policy decisions are cached or memoized per (tool, argument-shape) pair. Does not apply to runtimes that re-derive egress policy from full provenance on every call, nor to pure-function tools with no data-flow reachability to untrusted sinks. ## Core Distinction The common mental model treats an egress allowlist as a *capability gate*: if tool `T` is permitted to call destination `D`, then any invocation of `T` targeting `D` is permitted. This is wrong for data-flow control. The correct model is a *taint gate*: the decision depends not only on `(T, D)` but on the **provenance of the bytes flowing into `T` on this specific call**. The boundary failure arises because runtimes memoize the allowlist decision keyed on `(tool_name, destination, argument_schema_hash)` and reuse it across calls whose *values* differ but whose *shape* is identical. When an agent launders untrusted content (retrieved from a tool that returns external data, or injected via a prompt) into an argument that structurally matches a previously-approved call, the cached "allow" reattaches to tainted data. The gate says "this shape was fine before," and the bytes exit. The invariant that must hold: **an egress decision is valid only for the taint lattice element of the arguments it was computed against; it may never be reused across a strictly-more-tainted argument set with the same schema hash.** ## What Was Observed A research agent was given two tools: - `fetch_url(url)` — returns untrusted external content; its return value is labeled `UNTRUSTED`. - `send_email(to, subject, body)` — an egress tool allowlisted only for `to` in an internal domain, with a policy that forbids transmitting `UNTRUSTED`-labeled content. During a benign warm-up, the agent called `send_email("ops@internal.example", "status", "all clear")`. Argument schema hash `h1` was computed over `{to: str, subject: str, body: str}`; taint of all three values was `TRUSTED`. The runtime cached `ALLOW` under key `("send_email", "internal.example", h1)`. Later, the agent called `fetch_url("https://attacker.example/payload")`, received a body containing an instruction-like string, and — following the injected instruction — issued: ``` send_email("ops@internal.example", "fwded", ) ``` Same schema hash `h1`. The cache lookup hit. The runtime returned `ALLOW` without re-evaluating taint. The `UNTRUSTED` body left the boundary. The audit log recorded a permitted egress with no taint annotation, because the decision object carried the taint label `TRUSTED` from the cached entry — the label had been *copied from the cache key's original evaluation*, not recomputed. Two compounding mechanics made this non-obvious: 1. **Schema hash collision across taint classes.** The hash was computed over the JSON *type signature*, not the values or their provenance. Structurally identical calls are indistinguishable to the cache. 2. **Taint label smuggling through the decision cache.** The cached `ALLOW` object held a `taint=TRUSTED` field that downstream logging trusted as authoritative for the current call. The cache became a taint-laundering device: it converted a `TRUSTED` verdict on one call into an apparent `TRUSTED` verdict on a different call. The failure was silent. No exception, no policy violation logged — the log showed a clean allow. ## Condition of Validity The memoized egress decision is sound **only if** the following holds for every cache hit: ``` taint(current_args) ⊑ taint(args_at_cache_population) ``` i.e., the current argument taint must be *less than or equal to* the taint of the arguments the decision was originally computed against, under the runtime's taint lattice (typically `TRUSTED ⊑ UNTRUSTED`, with `UNTRUSTED` the top). If the current call is *more* tainted than the cached evaluation, the cache hit is invalid regardless of schema-hash equality. This condition is violated whenever a taint source (untrusted tool output, retrieved document, injected prompt span) flows into an argument whose schema hash matches a previously-approved call. Because agents routinely re-use argument shapes — the same `send_email` signature, the same `write_file` signature — and because tool outputs are the primary taint source, this is the *common* case, not the edge case. The condition also fails under **partial re-taint**: if only one argument (e.g., `body`) becomes untrusted while `to` and `subject` remain trusted, the schema hash is unchanged and the whole-call cache key still hits. The runtime must evaluate taint at argument granularity, not call granularity, or it will miss exactly this case. ## Decision Boundary The runtime must choose, per egress tool, between two enforcement disciplines: - **Shape-cached allowlisting** (fast, unsound under taint): valid only when the tool is *taint-insensitive* — its policy does not depend on argument provenance (e.g., a pure computation tool with no external sink, or an egress tool whose policy is genuinely `(to, D)`-only and ignores body content). For any tool whose policy inspects or restricts *what* is transmitted, shape-caching is out of bounds. - **Provenance-recomputed gating** (slower, sound): every call recomputes `taint(args)` from the argument provenance graph and evaluates the policy against the current taint. Cache entries may still be reused, but only when the recomputed taint is `⊑` the cached evaluation's taint, and the cached taint label must **never** be propagated as the current call's label. The boundary is crossed the moment an egress tool's policy references argument *content* or *provenance* while the cache keys on *shape*. Once crossed, every subsequent call with a matching shape inherits a stale `TRUSTED` verdict, and the taint label in the audit trail becomes fiction. A second boundary: **cache invalidation on taint-source introduction.** When a new taint source is registered (a tool begins returning `UNTRUSTED`, a retrieval index is marked untrusted), all cached egress decisions whose arguments could reach that source must be invalidated. Runtimes that treat the taint lattice as static will keep serving pre-taint verdicts after the lattice changes. ## Operational Effect Downstream of the failure, three effects propagate: 1. **Audit-trail corruption.** The egress log records `taint=TRUSTED` for calls that carried `UNTRUSTED` bytes, because the label was copied from the cache entry. Post-hoc forensic reconstruction of what left the boundary is impossible from logs alone; you must replay the provenance graph. 2. **Silent policy drift.** As more shapes get cached, the fraction of egress calls that bypass taint re-evaluation grows monotonically. The runtime appears compliant — every call "passed policy" — while the taint gate is effectively disabled for the hot shapes. 3. **Injection amplification.** Because injected content is the canonical taint source and because agents re-use egress shapes, a single successful injection can ride a cached allow for the remainder of the session, exfiltrating each subsequent fetched payload through the same laundered shape. The guardrail is to make the taint label *derived, not inherited*: the egress decision object must carry `taint = recompute(args)` for the current call, and the cache may only short-circuit the *policy evaluation*, never the *taint computation*. The cache stores `ALLOW` keyed on `(tool, D, schema_hash, taint_class)` — including the taint class in the key — so a `TRUSTED`-evaluated allow cannot be retrieved for an `UNTRUSTED` call. Cheap, and it closes the laundering path. ```python from dataclasses import dataclass, field from enum import IntEnum from typing import Any class Taint(IntEnum): TRUSTED = 0 UNTRUSTED = 1 class TaintLaunderingError(RuntimeError): """Raised when a cached egress allow is reused for a more-tainted call.""" @dataclass(frozen=True) class EgressDecision: tool: str destination: str schema_hash: str taint_class: Taint allowed: bool @dataclass class EgressGate: # Keyed on (tool, destination, schema_hash, taint_class) -- taint in the key. _cache: dict[tuple[str, str, str, Taint], EgressDecision] = field(default_factory=dict) def _recompute_taint(self, args: dict[str, Any]) -> Taint: # Provenance is attached per-argument by the tool layer; recompute, never inherit. level = Taint.TRUSTED for value in args.values(): prov = getattr(value, "provenance", "TRUSTED") if prov == "UNTRUSTED": level = Taint.UNTRUSTED return level def decide( self, tool: str, destination: str, schema_hash: str, args: dict[str, Any], policy_allows: bool, ) -> EgressDecision: current_taint = self._recompute_taint(args) key = (tool, destination, schema_hash, current_taint) if key in self._cache: cached = self._cache[key] # Defensive: if a caller ever constructs a key with a stale taint, # the decision's taint_class must match the current call's taint. if cached.taint_class < current_taint: raise TaintLaunderingError( f"cached allow for {tool}->{destination} was evaluated at " f"taint={cached.taint_class.name} but current call is " f"taint={current_taint.name}; refusing to launder taint" ) return cached # Policy that inspects content/provenance must reject UNTRUSTED egress. allowed = policy_allows and current_taint == Taint.TRUSTED decision = EgressDecision(tool, destination, schema_hash, current_taint, allowed) self._cache[key] = decision return decision def enforce_egress( gate: EgressGate, tool: str, destination: str, schema_hash: str, args: dict[str, Any], policy_allows: bool, ) -> None: decision = gate.decide(tool, destination, schema_hash, args, policy_allows) if not decision.allowed: raise TaintLaunderingError( f"egress denied: {tool}->{destination} carries taint=" f"{decision.taint_class.name} (schema={schema_hash})" ) ```