# Where must an instance of a tainted-context allowlist decision be re-evaluated: the stale-derivation boundary in tool-call policy enforcement **Date of Record:** 2026 November 16 **Scope:** Applies to runtime policy engines that compute a tool-call allowlist by deriving it from taint-annotated context (labels on values, provenance graphs, or capability tokens) at some point and then enforcing that allowlist on subsequent tool invocations. Does not apply to stateless per-call policy checks where the allowlist is recomputed from context on every invocation with no cached derivation. ## Core Distinction The non-obvious boundary is between **the taint state that authorized the derivation** and **the taint state at enforcement time**. A policy engine that derives an allowlist from taint-annotated context is making a judgment about a *snapshot* of that context. Enforcement, however, happens later, against a *live* context that may have changed in ways the derivation did not anticipate. The failure is not "the allowlist is too permissive" or "the taint label was wrong." It is that **the derivation is treated as an invariant when it is actually a function of mutable state**. When a value that was untainted at derivation time becomes tainted before enforcement, the cached allowlist silently authorizes a tool call that the current taint state would forbid. The engine's enforcement is *locally correct* (it matches the allowlist it holds) and *globally wrong* (the allowlist no longer corresponds to the context it claims to summarize). The distinction that matters operationally: a derivation is valid only over the interval in which the taint annotations it consumed are unchanged. That interval is almost never explicitly tracked. The boundary is the moment any consumed annotation is mutated, re-labeled, or propagated into a new sink — and there is typically no hook that invalidates the derivation at that moment. ## What Was Observed In a deployment enforcing tool-call allowlists over a multi-step agent loop, the policy engine derived an allowlist at the start of each "turn" from a provenance graph of the conversation. The derivation walked the graph, collected taint labels on the values the agent had produced, and emitted a set of permitted tool names (e.g., `read_file`, `search`, `send_email` withheld because a value carried a `pii` label). The observed failure: on turn *N*, a tool result returned a value that was *not* tainted at derivation time but *was* subsequently propagated into a sink that applied a `pii` label — specifically, a summarization step that merged an untainted user message with a previously-tainted record and re-emitted the merged value under a new provenance node. The allowlist for turn *N* had already been computed and cached. Enforcement on turn *N+1* used the cached allowlist, which still permitted `send_email`. The taint label introduced by the merge was never consulted because the derivation had already run. The tell was that the engine's audit log showed the *derivation* event and the *enforcement* event as separate, with no intervening re-derivation triggered by the label mutation. The label mutation was recorded in the provenance graph but did not invalidate the cached allowlist. The engine's own consistency check — "does the enforced allowlist match the last derivation?" — passed, because it did. The check that would have caught it — "does the last derivation match the current taint state?" — was not implemented. A second, subtler observation: when the derivation *was* recomputed (e.g., because the turn boundary happened to fall after the mutation), the allowlist correctly withheld `send_email`. This made the bug intermittent and load-dependent: under low latency, the mutation and enforcement fell in the same turn and were caught; under high latency, the turn boundary separated them and the stale allowlist was used. The failure correlated with system load, not with input content, which delayed diagnosis. ## Condition of Validity A cached allowlist derived from taint-annotated context is valid **if and only if** every annotation consumed by the derivation is unchanged between derivation time and enforcement time. This is a *conjunction* over all consumed annotations, and it is falsified by any single mutation. Practically, this condition is almost never satisfiable by inspection, because: 1. The set of consumed annotations is not explicitly recorded by most derivation implementations — the derivation reads whatever it reads and emits a set, without a dependency manifest. 2. Taint mutations occur through propagation (a labeled value flowing into an unlabeled sink and re-emerging) that does not touch the values the derivation directly read. 3. The enforcement path and the derivation path are typically in different components with different lifecycle assumptions (derivation at turn start, enforcement per call). The condition *is* satisfiable if the derivation records a dependency manifest — the exact annotation identifiers it read — and enforcement re-checks that manifest against the current annotation store, re-deriving on any mismatch. Absent that, the cached allowlist is a *guess* about current taint state, not a summary of it. ## Decision Boundary The decision the engineer must make: **invalidate-on-mutation vs. re-derive-per-call.** - **Invalidate-on-mutation** requires a subscription to the annotation store (or a version counter that the derivation records and enforcement compares). It is cheap at enforcement time, expensive to wire correctly, and fails open if a mutation path bypasses the subscription. Choose this when enforcement latency is tight and the annotation store has a single mutation chokepoint. - **Re-derive-per-call** recomputes the allowlist from current taint state on every tool invocation. It is correct by construction (no staleness window) but costs O(graph) per call and can be prohibitive for large provenance graphs. Choose this when the graph is small or when correctness dominates latency. The boundary is *not* "which is faster." It is *whether the annotation store has a complete mutation chokepoint*. If mutations can occur through paths the invalidation subscription does not see — and in most provenance systems, propagation through merge/summarize steps is exactly such a path — then invalidate-on-mutation is unsound and re-derive-per-call is the only correct option. The failure described above is the signature of choosing invalidate-on-mutation without verifying the chokepoint is complete. A third option — *derive at enforcement with a memo keyed on annotation-store version* — is usually the right compromise: it re-derives only when the version counter has advanced, which is correct if and only if the version counter is incremented on every mutation, including propagation-induced ones. The same chokepoint question applies. ## Operational Effect The operational consequence of getting this wrong is a **silent authorization of a forbidden tool call**, with an audit trail that shows the engine behaving consistently. This is worse than a loud failure because: 1. The engine's self-consistency checks pass (enforced allowlist matches last derivation). 2. The failure is load-correlated, not input-correlated, so it evades input-based testing. 3. The forbidden call is made with a value that the *current* taint state marks as sensitive, so the blast radius is exactly the data the taint system was built to protect. Mitigation in practice: instrument the derivation to emit a dependency manifest; instrument the annotation store to emit a monotonic version; have enforcement compare the manifest's recorded version against the current version and raise on mismatch rather than proceeding with the stale allowlist. The raise is the important part — failing closed on version mismatch converts a silent authorization into a loud, attributable error, which is the only way the staleness window becomes observable. ```python class StaleAllowlistError(RuntimeError): """Raised when an enforced allowlist was derived from taint annotations that have since been mutated. The allowlist no longer summarizes the current taint state and must not be used for enforcement.""" pass class AllowlistDerivation: def __init__(self, permitted_tools, consumed_annotations, store_version): self.permitted_tools = frozenset(permitted_tools) self.consumed_annotations = frozenset(consumed_annotations) self.store_version = store_version def enforce_tool_call(derivation, current_store_version, tool_name): # The derivation is valid only if every annotation it consumed is # unchanged. We approximate "unchanged" with a monotonic store version: # any mutation, including propagation-induced re-labeling, advances it. if derivation.store_version != current_store_version: raise StaleAllowlistError( f"allowlist derived at store version {derivation.store_version} " f"but current version is {current_store_version}; " f"consumed annotations {sorted(derivation.consumed_annotations)} " f"may have been mutated. Re-derive before enforcing {tool_name!r}." ) if tool_name not in derivation.permitted_tools: raise PermissionError( f"tool {tool_name!r} not in allowlist " f"{sorted(derivation.permitted_tools)}" ) return True def derive_allowlist(taint_graph, store_version): # Walk the graph, collect labels, emit permitted tools and the exact # annotation identifiers consumed. The manifest is the load-bearing # artifact: without it, staleness is undetectable. consumed = set() permitted = {"read_file", "search"} for node in taint_graph.nodes(): for label in node.labels: consumed.add(label.identifier) if label.kind == "pii": permitted.discard("send_email") return AllowlistDerivation(permitted, consumed, store_version) ```