# Under what conditions must an instance re-derive taint closure after an egress allowlist widens mid-session **Date of Record:** 2026 November 26 **Scope:** Applies to single- or multi-agent systems where tool-invocation policy is enforced by a taint-tracking capability gate that (a) propagates data-provenance labels through tool arguments and return values and (b) consults an egress allowlist at call time. Does not apply to stateless per-call policy engines that re-evaluate provenance from scratch on every invocation, nor to systems where the allowlist is immutable for the lifetime of a session. ## Core Distinction The failure mode is not "an unauthorized tool call succeeded." It is subtler: **the allowlist widened, the taint labels on already-materialized context did not.** Taint closure — the set of (value, label) pairs the gate believes are in scope — is computed incrementally as the agent runs. When an egress allowlist is *relaxed* at runtime (a new domain added, a new tool capability granted, a sandbox tier raised), the gate re-checks the *current* call against the *new* allowlist but does not retroactively re-propagate taint through values that were already laundered under the old, stricter policy. The result is a window in which a value that should carry a `secret` label after re-derivation is still labeled `public` in the working set, and the now-wider egress path lets it out. The distinction that matters operationally: **allowlist widening is a policy event, not just a lookup-table mutation.** A lookup-table mutation changes the answer to "may X egress to Y?" A policy event changes the *closure* — which derivations are now reachable, and therefore which labels should exist. Most implementations treat the first and ignore the second. ## What Was Observed A retrieval agent held a session with three tools: `fetch_url` (egress to an allowlist of 4 internal domains), `summarize` (local model call), and `write_note` (egress to an internal wiki). Taint labels were assigned at ingestion: anything returned by `fetch_url` from a domain marked `sensitive` got label `SECRET`; everything else got `PUBLIC`. The gate blocked any `write_note` call whose argument carried `SECRET`. Mid-session, an operator widened the `fetch_url` allowlist to include `partner.example.net`, classified `PUBLIC`, and simultaneously raised the agent's egress tier so `write_note` could target an external webhook. The gate was reloaded and correctly admitted the new domain and the new egress target. The trace: 1. Step 12 — `fetch_url(partner.example.net/status)` returns a body containing an internal identifier `acct-7731`. Labeled `PUBLIC` (correct per the domain classification at fetch time). 2. Step 13 — `summarize` condenses the body; the summary retains `acct-7731`. Still `PUBLIC` by join of inputs. 3. Step 14 — the agent calls `write_note(target=external_webhook, body=summary)`. The gate checks: `body` is `PUBLIC`, target is now allowed. **Admitted.** The identifier was, in fact, `SECRET` — it appears in an internal registry that a *different* tool, `lookup_registry`, would have labeled `SECRET` had it been called. But `lookup_registry` was never in the derivation path; the value arrived via a `PUBLIC` domain. The taint closure computed at step 12 was correct *under the allowlist as it stood at step 12*. After the allowlist widened at step 13.5, the same derivation became reachable from a `SECRET`-sensitive context (the registry could now be joined against the partner feed), and the closure was stale. The gate's incremental taint store had no invalidation hook for "allowlist widened → recompute derivations that touch newly-reachable sensitive sources." It only invalidated on writes to individual values. ## Condition of Validity The invariant that was violated: **taint closure must be recomputed (or conservatively invalidated) whenever the egress allowlist widens in a way that makes a previously-unreachable sensitive source reachable from an already-materialized value.** Precisely, re-derivation is *required* when all of the following hold: - The allowlist change is a **widening** (adds a target, raises a tier, or reclassifies a source from `sensitive` to `public`). Narrowing never requires re-derivation — it can only over-block, which is safe. - There exists at least one value `v` in the working set whose derivation graph (the set of source fetches and tool calls that produced it) intersects, under the *new* allowlist, a source labeled `SECRET`. In practice this means the new allowlist entry enables a join or lookup that was previously blocked. - `v` was labeled under the *old* closure and has not been re-derived since the change. Re-derivation is *not* required when the allowlist change adds only targets that are themselves `SECRET`-labeled (egress to them is already blocked by the taint gate, so the closure is unchanged), or when the working set contains no values whose derivation graph could reach the newly-added source. The subtlety that makes this non-obvious: **the value's label was correct when assigned.** The bug is not a mislabeling at ingestion; it is a *temporal* invariant — label correctness is relative to the policy under which it was computed, and policy is mutable. A gate that treats labels as absolute rather than as functions of policy will pass every per-call check and still leak. ## Decision Boundary The gate must distinguish two operations that look identical at the call site: | Operation | Effect on closure | Required action | |---|---|---| | Allowlist **narrows** | Closure shrinks or holds | No re-derivation; re-check current call only | | Allowlist **widens**, new target is `SECRET` | Closure holds (egress still blocked) | No re-derivation; re-check current call only | | Allowlist **widens**, new target is `PUBLIC` and reachable from a `SECRET` source | Closure must **grow** | Re-derive or invalidate affected values before next egress | | Source **reclassified** `sensitive`→`public` | Closure may grow (previously-blocked joins now legal) | Re-derive affected values | The decision boundary is the third and fourth rows. A gate that collapses all four into "reload allowlist, re-check current call" is unsound. The correct guardrail is a **closure-generation counter**: every widening event increments it; every value carries the generation at which its label was computed; any egress of a value whose generation is older than the current generation triggers re-derivation (or, conservatively, blocks until re-derived). This bounds the leak to the re-derivation latency, which is the only honest bound available — you cannot make widening instantaneous and sound simultaneously without paying the recompute cost. A second guardrail: **widening events must be logged as policy events, not config changes**, and the gate must refuse to serve egress from a value whose derivation graph it cannot re-walk (e.g., the source tool is no longer available). Fail closed on un-walkable graphs. ## Operational Effect The practical consequence is that allowlist widening is a **stop-the-world event for the taint closure**, not a hot-reloadable config tweak. Systems that hot-reload the allowlist and continue serving will leak for the duration between the reload and the next full re-derivation — and if re-derivation is never triggered (the common case, because the gate has no generation counter), they leak for the remainder of the session, and the leak is *silent* because every per-call check passes. The mitigation that actually holds: treat the allowlist as part of the policy generation, version it alongside the taint store, and make egress admission a function of `(value, label, generation)`. When `generation(value) < generation(policy)`, the gate must either re-derive or block. This converts a silent temporal leak into a bounded, observable stall — which is the correct trade for a security boundary. The cost is that widening an allowlist mid-session now has a latency floor proportional to the working-set re-derivation; operators who expect sub-second widening will be surprised, and that surprise is the invariant asserting itself. ```python class StaleTaintClosureError(RuntimeError): """Raised when egress is attempted from a value whose taint label was computed under an older policy generation than the current allowlist.""" pass class PolicyGeneration: def __init__(self): self.gen = 0 def widen(self): # Any widening (or sensitive->public reclassification) bumps the generation. self.gen += 1 return self.gen class TaintStore: def __init__(self, policy: PolicyGeneration): self.policy = policy self._labels = {} # value_id -> (label, generation) def label(self, value_id, label): self._labels[value_id] = (label, self.policy.gen) def relearn(self, value_id, label): # Re-derivation under current policy generation. self._labels[value_id] = (label, self.policy.gen) def get(self, value_id): return self._labels.get(value_id) def admit_egress(value_id, target, allowlist, store: TaintStore, rederive): entry = store.get(value_id) if entry is None: raise StaleTaintClosureError(f"no taint label for {value_id!r}; cannot admit egress") label, gen = entry if target not in allowlist: return False # blocked by allowlist, not a closure issue if gen < store.policy.gen: # Allowlist widened since this label was computed. Re-derive before admitting. new_label = rederive(value_id) store.relearn(value_id, new_label) label, gen = store.get(value_id) if label == "SECRET": return False if gen < store.policy.gen: raise StaleTaintClosureError( f"re-derivation of {value_id!r} did not advance to current " f"generation {store.policy.gen}; refusing egress" ) return label != "SECRET" ```