# What structural signals indicate a delegated-capability token has silently outlived its consent grant in AAIF per-tool scoping **Date of Record:** 2026 November 25 **Scope:** Applies to AAIF (Agent Identity and Authorization Framework) delegated-capability tokens where a parent agent mints per-tool scoped consent grants for child/sub-agents and tool invocations are authorized against the grant's scope set. Does not apply to monolithic bearer tokens without per-tool scope decomposition, nor to human-OAuth consent flows where the resource server re-validates consent on every call. ## Core Distinction The failure mode here is not token *expiry* and not token *revocation*. It is **scope-set staleness under delegation**: a delegated-capability token whose cryptographic envelope is valid, unexpired, and correctly signed, but whose embedded per-tool scope set no longer matches the consent the human principal actually granted at mint time — because the consent grant was narrowed, a tool was de-scoped, or a scope was re-bound to a different resource, *after* the token was minted but *before* it was consumed. The token remains verifiable; it is no longer *authorized*. Standard AAIF validation checks signature, issuer, audience, and `exp`/`nbf`, all of which pass. The consent grant is a separate, mutable record that the token references by `grant_id` but does not cryptographically bind to the grant's *current* contents. The non-obvious part: **the failure is silent on the token side and silent on the grant side.** The token doesn't know its grant shrank. The grant store doesn't know a token was minted against the old version. Only the tool's authorization check — if it re-reads the grant — can detect the divergence, and most AAIF implementations optimize that check away by trusting the token's embedded scope set as authoritative. ## What Was Observed A parent orchestrator agent mints a delegated token for a child agent to run a data-export pipeline. At mint time, the human principal's consent grant `g-4471` includes scopes `{fs.read, fs.write, http.post, shell.exec}` for tool family `pipeline-runner`. The token envelope embeds `scopes=["fs.read","fs.write","http.post","shell.exec"]`, a `grant_id: g-4471`, and `grant_version: 3`. Mid-pipeline, a consent-management event fires (a human revokes `shell.exec` from `g-4471` after a policy review, bumping the grant to `version: 4`). The token is not revoked — revocation lists are keyed on `token_id`, and the orchestrator has no mechanism to enumerate and revoke live child tokens when a grant mutates. The token's `exp` is 40 minutes out. The child agent, at step 6, calls the `shell.exec` tool. The tool's AAIF middleware performs: 1. Signature verification against the issuer's JWKS — passes. 2. `exp`/`nbf`/`aud` checks — passes. 3. Scope check: `"shell.exec" in token.scopes` — passes, because the token still carries the version-3 scope set. 4. **Grant re-read: skipped** (the middleware trusts the token as the authoritative scope carrier; re-reading `g-4471` would add a store round-trip per tool call). Result: `shell.exec` executes with a scope the principal revoked 90 seconds earlier. No error, no audit anomaly, no denial. The structural signal that *should* have fired — `token.grant_version != grant.current_version` — was never evaluated because the comparison was never performed. A second, subtler trace: when the grant is *narrowed* rather than revoked (e.g., `http.post` re-bound from `api.internal.example` to `api.partner.example`), the token embeds the old resource binding in its scope claim. The tool authorizes against `http.post` generically and the resource binding is enforced only at the *grant* layer — which the token bypasses. The child posts to the now-unauthorized internal endpoint with a fully valid token. The third trace is the one that produces false confidence: an auditor agent replaying the child's action log sees a valid token, a valid signature, a passing scope check, and concludes the action was authorized. The replay reproduces the *token's* view of authorization, not the *grant's*. Verification replay diverges from ground truth because the replay input (the token) is a stale snapshot of a mutable authorization decision. ## Condition of Validity The invariant that makes this a *boundary* failure rather than a bug is: **a delegated-capability token is a point-in-time snapshot of an authorization decision, but it is consumed as if it were a continuous assertion of that decision.** The token is valid iff, at consumption time, `token.scopes ⊆ grant(token.grant_id).current_scopes` AND `token.resource_bindings == grant(token.grant_id).current_bindings` AND `token.grant_version == grant(token.grant_id).current_version`. This holds only when one of the following is true: - **Grant immutability window:** grants cannot be mutated while any live token references them (tokens are revoked synchronously on mutation). Requires a reverse index from `grant_id` → live `token_id`s, which most AAIF deployments do not maintain. - **Short-token / long-grant asymmetry inverted:** token TTL is shorter than the grant-mutation propagation SLO, so a stale token cannot outlive the propagation window. Requires `token.ttl < grant.propagation_slo`, which fails whenever tokens are minted with 30–60 min TTLs for multi-step pipelines and grant propagation is eventual. - **Consumption-time re-binding:** every tool call re-reads the grant and compares `grant_version`, treating a mismatch as a hard denial. This is the only invariant that holds under arbitrary mutation timing, and it is exactly the check that gets optimized out. The failure is *bounded* (not eliminated) when the tool's authorization middleware is the sole enforcement point and it performs the version comparison. It is *unbounded* when scope enforcement is pushed into the token (e.g., a policy engine that reads `token.scopes` and short-circuits), because then no component ever consults the grant's current state. ## Decision Boundary The decision boundary is: **does the authorization path treat the token as the source of truth for scope, or as a pointer to the source of truth?** - If token-as-source-of-truth: the system is exposed to scope-set staleness for the full token TTL after any grant mutation. The blast radius is every tool call in every live child token minted before the mutation. Mitigation requires either synchronous revocation-on-mutation (with the reverse index) or accepting the TTL-bounded exposure. - If token-as-pointer: the system is correct under arbitrary mutation timing but pays a grant-store read per tool call. The optimization to *not* pay that read is precisely the optimization that reintroduces the failure — and it is usually introduced as a latency fix, not as a security change, which is why it evades review. A secondary boundary governs *narrowing vs. revocation*. Revocation (scope removed entirely) is detectable by a set-inclusion check. Narrowing (scope retained but resource binding changed) is **not** detectable by set-inclusion — the scope name is still present — and requires an equality check on the binding payload. Implementations that check `scope in token.scopes` but not `token.binding[scope] == grant.binding[scope]` are correct against revocation and silently wrong against narrowing. This is the boundary most often crossed without notice, because narrowing is the common case in consent UIs (a user edits a grant rather than deleting it). The guardrail: delegated tokens MUST carry `grant_version` and `grant_digest` (a hash over the grant's scope set and bindings at mint time). The tool's authorization middleware MUST re-read the grant, recompute the digest, and reject on mismatch with a distinct error class — not a generic `Unauthorized`, because a generic denial is indistinguishable from a malformed token and gets retried by the agent's error-handling loop, which will mint a fresh token from the *stale* orchestrator state and re-fail identically. The denial must be a terminal, non-retryable `StaleConsentGrant` that forces the orchestrator to re-mint against the current grant. ## Operational Effect The observable effect is a **consent-revocation latency floor** equal to the token TTL, not the grant propagation SLO. Operators measuring "time from consent revocation to enforcement" against the grant store will see sub-second propagation and conclude the system is compliant; the actual enforcement lag is the token TTL because live tokens bypass the grant store entirely. This is a measurement blind spot, not just a security gap: the metric that would reveal the failure (live tokens whose `grant_version` is behind the grant's current version) is never collected because nothing compares the two. The second effect is **auditor replay divergence**. An auditor replaying action logs against token envelopes reproduces the token's authorization view and validates actions that the grant had already de-authorized. The replay is internally consistent and externally wrong. Detecting this requires the audit log to record `grant_version_at_consumption` alongside `token.grant_version`, and flagging any action where they differ — a field most logs omit because the token was assumed authoritative. The third effect is **agent-side misattribution**. When the stale token is eventually rejected (e.g., the grant is fully revoked and a downstream service does re-check), the child agent receives a denial on a token it believes is valid and unexpired. Its error handler classifies this as a transient auth failure and retries with the same token, or requests a re-mint from an orchestrator that still holds version-3 grant state. The retry loop burns the token's remaining TTL and produces a burst of denials that look like a flaky auth service rather than a stale-consent condition. The correct agent behavior — surface `StaleConsentGrant` to the orchestrator, halt the pipeline, require human re-consent — is only reachable if the denial is typed distinctly and the orchestrator's re-mint path re-reads the grant rather than replaying its cached scope set. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class StaleConsentGrant(RuntimeError): """Raised when a delegated token's embedded grant snapshot no longer matches the grant store's current state. Terminal: do NOT retry with the same token, and do NOT re-mint from cached orchestrator state.""" @dataclass class ConsentGrant: grant_id: str version: int scopes: dict[str, str] # scope_name -> resource_binding revoked: bool = False def digest(self) -> str: payload = f"{self.grant_id}|{self.version}|" + "|".join( f"{k}={v}" for k, v in sorted(self.scopes.items()) ) return hashlib.sha256(payload.encode()).hexdigest() @dataclass class DelegatedToken: token_id: str grant_id: str grant_version: int grant_digest: str scopes: dict[str, str] exp: int class GrantStore: def __init__(self) -> None: self._grants: dict[str, ConsentGrant] = {} def put(self, grant: ConsentGrant) -> None: self._grants[grant.grant_id] = grant def get(self, grant_id: str) -> ConsentGrant: return self._grants[grant_id] def authorize_tool_call( token: DelegatedToken, tool_scope: str, requested_binding: str, store: GrantStore, now: int, ) -> None: # Envelope checks (signature verification elided; assumed to pass). if now >= token.exp: raise StaleConsentGrant(f"token {token.token_id} expired") # Consumption-time re-binding: the token is a POINTER, not the truth. grant = store.get(token.grant_id) if grant.revoked: raise StaleConsentGrant( f"grant {grant.grant_id} revoked; token {token.token_id} is stale" ) if token.grant_version != grant.version: raise StaleConsentGrant( f"grant_version mismatch: token={token.grant_version} " f"grant={grant.version} for token {token.token_id}; " f"re-mint required against current grant" ) if token.grant_digest != grant.digest(): raise StaleConsentGrant( f"grant_digest mismatch for token {token.token_id}; " f"scope set or bindings mutated since mint" ) # Narrowing check: set-inclusion is NOT sufficient. Binding must match. if tool_scope not in grant.scopes: raise StaleConsentGrant( f"scope {tool_scope} no longer granted by {grant.grant_id}" ) if grant.scopes[tool_scope] != requested_binding: raise StaleConsentGrant( f"binding mismatch for {tool_scope}: " f"granted={grant.scopes[tool_scope]} requested={requested_binding}" ) # Demonstration: revocation-after-mint produces a typed, terminal denial # instead of a silent authorized call. store = GrantStore() store.put(ConsentGrant( grant_id="g-4471", version=3, scopes={"fs.read": "vol-a", "shell.exec": "sandbox-1"}, )) tok = DelegatedToken( token_id="t-9912", grant_id="g-4471", grant_version=3, grant_digest=store.get("g-4471").digest(), scopes={"fs.read": "vol-a", "shell.exec": "sandbox-1"}, exp=10_000, ) store.put(ConsentGrant( grant_id="g-4471", version=4, scopes={"fs.read": "vol-a"}, # shell.exec revoked )) try: authorize_tool_call(tok, "shell.exec", "sandbox-1", store, now=100) except StaleConsentGrant as e: print(f"DENIED (terminal): {e}") ```