# How does an instance detect that its least-privilege tool grant was silently widened by a mid-session policy refresh (the "grant rehydration" failure) **Date of Record:** 2026 November 27 **Scope:** Applies to long-lived agent instances whose tool-call authorization is enforced by an external policy decision point (PDP) that can issue mid-session policy refreshes, and whose identity/warrant carries a scoped capability set. Does not apply to stateless single-turn invocations where the grant is re-derived from scratch on every call. ## Core Distinction The failure is not "an agent used a tool it shouldn't have." It is subtler: the agent's *grant object* was atomically replaced by a policy refresh, and the replacement was computed against a *different subject description* than the one the instance was actually running under. Least-privilege is a property of the pair (identity, capability set). When the PDP rehydrates the capability set from the identity's *current* attributes rather than the attributes frozen at session establishment, the pair becomes inconsistent — the instance keeps a tool handle minted under grant G₀ while the PDP now believes it is enforcing grant G₁. Every subsequent call is authorized against G₁ but executed by a process whose reasoning, scratchpad, and cached tool schemas were built for G₀. This is a continuity invariant, not a permissions bug: **the grant under which a tool handle was minted must equal the grant under which each call through that handle is enforced, for the lifetime of the handle.** A refresh that satisfies this is a no-op for live handles; a refresh that violates it is a silent widening (or narrowing) that the instance cannot observe from inside its own loop, because the tool call still *succeeds*. ## What Was Observed A research agent held a scoped identity `svc-researcher@run-8821` with a frozen attribute set at t₀ that included `data_classification: public` and `repo_scope: [docs/]`. Its grant G₀ permitted `read_file` restricted to `docs/**` and denied `http_fetch` entirely. At t₀+41min, a scheduled policy refresh fired. The PDP re-evaluated the identity against its *live* directory record, which had been updated by an unrelated HR sync to add `team: platform` and, transitively through a group rule, `repo_scope: [docs/, infra/]` plus a conditional `http_fetch` allow for `*.internal.example`. The refresh pushed a new grant G₁ to the instance's policy cache. The instance's tool handle for `read_file` was *not* re-minted — it retained its original capability token, which the PDP now validated against G₁ because validation keyed on identity, not on the token's embedded grant epoch. The next `read_file("infra/secrets/terraform.tfstate")` call: 1. Passed local schema validation (path string, well-formed). 2. Was authorized by the PDP under G₁ (`infra/` now in scope). 3. Succeeded and returned 40KB of state file contents. 4. Was logged as `ALLOW` with `policy_epoch: G1`, giving no signal that the handle was minted under G₀. The instance's planner, meanwhile, still *believed* it was confined to `docs/` — its system prompt and cached tool description said so. It had been attempting to read a docs path, hit a transient 404, and its error-recovery heuristic substituted a "nearby" path from a stale directory listing it had cached 30 minutes earlier. The substitution was never a deliberate scope violation; it was a reasoning path that only became *reachable* because the enforcement boundary moved underneath a handle the reasoning layer assumed was fixed. The observable signature was not an error. It was a **divergence between the instance's model of its own authority and the PDP's model of it**, detectable only by comparing the grant epoch embedded in the tool handle against the epoch the PDP reports for the identity at call time. ## Condition of Validity The invariant holds — and the failure is possible — only when all three of the following are true: - **Handles outlive grants.** Tool handles (capability tokens, cached client objects, MCP server sessions) are minted once and reused across calls, so their embedded grant epoch can drift from the live policy epoch. - **Refresh is attribute-driven, not epoch-frozen.** The PDP recomputes the capability set from the identity's current attributes rather than from a snapshot pinned at session establishment. This is the root cause: it makes the grant a function of mutable external state. - **Enforcement keys on identity, not on handle epoch.** The PDP validates the *caller's identity* against the current grant, ignoring the grant epoch carried by the handle. If enforcement keyed on the handle's epoch and rejected stale epochs, the refresh would surface as an explicit `STALE_GRANT` error instead of a silent widening. When any one of these is absent, the failure collapses into either a benign no-op (refresh is epoch-frozen) or a loud failure (enforcement rejects stale handles). The dangerous case is precisely the intersection: silent, successful, and invisible to the reasoning layer. ## Decision Boundary An instance must treat a policy refresh as a **potential invalidation of every live tool handle**, not as an in-place update to a shared grant. The decision boundary is: - If `handle.grant_epoch == pdp.current_epoch(identity)`: proceed; the pair (identity, capability set) is consistent. - If `handle.grant_epoch != pdp.current_epoch(identity)`: the handle is stale. The instance MUST NOT continue using it, even if the PDP would authorize the call — because authorization under a *different* grant than the one the reasoning layer assumed is exactly the silent-widening condition. It must re-mint handles, re-read the effective grant, and re-plan any in-flight task whose assumptions depended on the old scope. The subtlety: a stale handle that is *narrower* than the live grant is also a violation, because the instance may be silently failing calls it should succeed, and its error-recovery heuristics will then wander — as in the observed case — into paths the widened grant now permits. Widening and narrowing are the same bug from the invariant's perspective: the reasoning layer's model of authority no longer matches enforcement. The guardrail is a **grant-epoch fence**: every tool handle carries the epoch it was minted under; the PDP exposes the current epoch per identity; the runtime compares them before dispatching any call and raises rather than silently proceeding on mismatch. This converts an invisible continuity break into a loud, recoverable one. ## Operational Effect Without the fence, the failure mode is *silent privilege drift*: the agent's effective authority diverges from its declared authority, and the divergence is visible only in aggregate audit logs, days later, as a cluster of `ALLOW` decisions on paths the agent's prompt never mentioned. The reasoning layer cannot self-correct because it has no error signal — every call returns `200`. Error-recovery heuristics, which are designed to route around *failures*, become the vector by which the widened scope is exercised: a 404 on an in-scope path triggers a substitution to a path that only the widened grant permits. With the fence, the same refresh produces a `StaleGrantError` at the next dispatch. The instance halts the in-flight task, re-mints handles under G₁, re-reads its effective scope, and — critically — re-validates any cached directory listings or path assumptions against the new scope before resuming. The task may take a checkpoint/resume hit, but it does not silently read `infra/secrets/`. The cost of the fence is one epoch comparison per tool call; the cost of its absence is an unbounded, unlogged widening whose blast radius is set by whatever the identity's attributes happen to become. ```python from dataclasses import dataclass from typing import Optional class StaleGrantError(RuntimeError): """Raised when a tool handle's grant epoch diverges from the live policy epoch.""" @dataclass(frozen=True) class ToolHandle: tool: str grant_epoch: str # epoch under which this handle was minted capability_token: str @dataclass(frozen=True) class EffectiveGrant: epoch: str allowed_tools: frozenset allowed_paths: tuple class PolicyDecisionPoint: """Live PDP whose grant is a function of mutable identity attributes.""" def __init__(self, identity: str, grant: EffectiveGrant): self.identity = identity self._grant = grant def current_epoch(self) -> str: return self._grant.epoch def effective_grant(self) -> EffectiveGrant: return self._grant def refresh(self, new_grant: EffectiveGrant) -> None: # Attribute-driven refresh: grant changes, live handles do NOT re-mint. self._grant = new_grant def authorize(self, handle: ToolHandle, path: str) -> bool: # Enforcement keys on identity against the CURRENT grant, ignoring handle epoch. g = self._grant return handle.tool in g.allowed_tools and any( path.startswith(p) for p in g.allowed_paths ) def dispatch(pdp: PolicyDecisionPoint, handle: ToolHandle, path: str) -> str: """Grant-epoch fence: refuse to dispatch on a stale handle before authorizing.""" live_epoch = pdp.current_epoch() if handle.grant_epoch != live_epoch: raise StaleGrantError( f"handle for tool={handle.tool!r} minted under epoch " f"{handle.grant_epoch!r} but live policy epoch is {live_epoch!r}; " f"re-mint handles and re-validate cached path assumptions before retrying" ) if not pdp.authorize(handle, path): raise PermissionError(f"denied: {handle.tool} -> {path}") return f"read {path}" # --- trace of the observed failure --- pdp = PolicyDecisionPoint( identity="svc-researcher@run-8821", grant=EffectiveGrant( epoch="G0", allowed_tools=frozenset({"read_file"}), allowed_paths=("docs/",), ), ) handle = ToolHandle(tool="read_file", grant_epoch="G0", capability_token="tok-G0") # Mid-session attribute-driven refresh silently widens the grant. pdp.refresh( EffectiveGrant( epoch="G1", allowed_tools=frozenset({"read_file", "http_fetch"}), allowed_paths=("docs/", "infra/"), ) ) # Without the fence this call succeeds (PDP authorizes under G1) and the # reasoning layer never learns its scope moved. try: dispatch(pdp, handle, "infra/secrets/terraform.tfstate") except StaleGrantError as e: print(f"fence caught silent widening: {e}") # Correct recovery: re-mint under G1, re-read effective grant, re-plan. handle = ToolHandle(tool="read_file", grant_epoch=pdp.current_epoch(), capability_token="tok-G1") print(dispatch(pdp, handle, "infra/secrets/terraform.tfstate")) ```