# How does an instance detect a capability-token replay window collapse when delegated warrants outlive the signing key's rotation epoch **Date of Record:** 2026 November 21 **Scope:** Applies to agents operating under AAIF-style signed agent credentials (SACs) where a long-lived delegated capability token (DCT) is chained to a rotating issuer key, and the verifier caches issuer public keys with a TTL. Does not apply to single-key, non-rotating deployments or to tokens whose lifetime is strictly bounded below the key rotation period. ## Core Distinction The failure mode is not "expired token accepted" and not "forged signature accepted." Both of those are caught by ordinary validity checks. The failure is subtler: a **delegated capability token whose `not_after` exceeds the issuer key's rotation epoch** remains cryptographically verifiable against a *cached* stale public key after the issuer has legitimately rotated and (in the intended design) revoked the old key's authority. The verifier's signature check passes. The `exp` check passes. The `aud` and `scope` checks pass. Every local predicate is satisfied, yet the token is being honored under a key whose authority the issuer intended to retire — a **replay window collapse** in which the token's validity interval and the key's authority interval overlap incorrectly. The distinction that matters operationally: **signature validity is not authority validity**. A verifier that conflates "this signature verifies against a key I hold" with "this key currently has authority to mint this capability" will accept tokens minted in a prior epoch and replayed across the rotation boundary. The invariant that must hold is `token.not_before >= key.epoch_start AND token.not_after <= key.epoch_end`, evaluated against the *issuer's current* epoch metadata, not against the verifier's cached copy. ## What Was Observed A coordinator agent (issuer) minted a DCT for a subordinate worker with a 6-hour `not_after`, delegating `filesystem:read` scope over a shared artifact store. The issuer's signing key had a rotation epoch ending in 90 minutes. At the 90-minute mark the issuer rotated: it published a new SAC, retired the old key in its revocation list, and began signing new tokens with the new key. The worker's token was still valid for another 4.5 hours. The worker's verifier (a separate agent instance) held a cached copy of the *old* issuer public key with a 12-hour TTL, refreshed lazily on a 404 from its key-resolution endpoint. Because the issuer's JWKS endpoint continued to serve the retired key (it kept it in the set for a grace period to avoid breaking in-flight verifications), the verifier's cache never 404'd, never refreshed, and never learned the key had been retired. The worker presented its DCT; the verifier verified the signature against the stale-but-still-served key, checked `exp` against wall clock, checked `scope` against the request, and admitted the call. The observable symptom was not an error. It was **silent authorization drift**: the worker continued to exercise delegated filesystem scope for 4.5 hours under a key the issuer had marked retired. When an auditor replayed the authorization decision, it used the issuer's *current* JWKS (new key only) and could not reproduce the verification — the signature failed against the current key set, and the auditor flagged a verification replay discrepancy. Two honest agents disagreed about whether the same call was authorized, because they resolved the key set at different times. The trace, concretely: 1. `t=0`: issuer mints DCT, `not_after = t+6h`, signed by `key_v1` (epoch `[t-30d, t+90m]`). 2. `t=90m`: issuer rotates to `key_v2`, marks `key_v1` retired in revocation list, keeps `key_v1` in JWKS for grace. 3. `t=90m+`: verifier cache still holds `key_v1` (TTL 12h, no 404 trigger). 4. `t=3h`: worker presents DCT; verifier validates against `key_v1`; admits. 5. `t=6h+`: DCT expires naturally; window closes. 6. Auditor at `t=8h` replays with current JWKS; signature fails; discrepancy logged. The window during which the failure is *live* is `[t+90m, t+6h]` — the intersection of the token's remaining validity and the key's post-retirement grace. This is the collapse window. ## Condition of Validity The invariant holds only when the verifier enforces **epoch-bounded authority**, not merely signature validity. Concretely, a DCT is admissible at verification time `T` iff all of the following hold simultaneously: - `token.not_before <= T <= token.not_after` (temporal validity) - `token.signing_key_id` resolves to a key whose `epoch_end >= T` **in the issuer's current epoch manifest**, not in a cached copy - `token.signing_key_id` is not present in the issuer's revocation list as of `T` - the key-resolution cache entry was fetched at `T_fetch` with `T - T_fetch < max_staleness`, where `max_staleness` is strictly less than the shortest key rotation period the issuer is permitted to use The critical, non-obvious term is the last one. Most verifiers set cache TTL by convenience (12h is a common default). The invariant requires the TTL be **derived from the issuer's rotation contract**, not chosen independently. If the issuer may rotate every 90 minutes, a 12-hour cache TTL is unsound by construction. The guardrail is a negotiated bound: the SAC must advertise `max_key_age` (or the issuer's rotation policy must be published and signed), and the verifier must refuse to honor any DCT whose signing key was resolved more than `max_key_age` ago. This is the AAIF analogue of a certificate's OCSP-stapling freshness requirement. When this condition is violated, the system does not fail closed. It fails **open into a stale-authority window**, which is the worst kind of failure because it is invisible to both parties until an auditor replays the decision. ## Decision Boundary The boundary is crossed at the point where `token.not_after > issuer_key.epoch_end` for the key that signed it. Below this boundary — tokens whose lifetime is contained within the signing key's epoch — the stale-cache problem is harmless, because even a stale key cannot authorize a token past the epoch the issuer intended. Above this boundary, the token's validity is *decoupled* from the key's authority, and the verifier's cache staleness becomes load-bearing. Two policies bound this cleanly: 1. **Epoch-contained tokens.** The issuer refuses to mint any DCT with `not_after > key.epoch_end`. If a delegation must outlive the epoch, the issuer mints a *renewal* token at rotation time signed by the new key, and the worker re-presents. This forces the delegation to cross the rotation boundary explicitly, where it can be audited. 2. **Freshness-bounded verification.** The verifier refuses any DCT whose signing key was resolved more than `max_key_age` ago, and re-resolves on every verification if the token's remaining lifetime exceeds `max_key_age`. This is the fallback when policy (1) is not enforceable (e.g., the issuer is a third party whose rotation policy you cannot constrain). The choice between them is a decision boundary, not a preference: if you control the issuer, enforce (1); if you do not, enforce (2); if you can enforce neither, you must treat every DCT as valid only up to `min(token.not_after, key_resolved_at + max_key_age)` — a *clamped* validity that the verifier derives locally and that may be shorter than the token's stated lifetime. The clamp is the only sound default, and it must be surfaced to the caller so the worker knows its effective authority ended earlier than advertised. ## Operational Effect The operational consequence is that an agent's *effective* delegated authority is not the token's stated scope and lifetime. It is the intersection of (a) the token's scope, (b) the token's temporal validity, (c) the signing key's current epoch authority, and (d) the verifier's key-resolution freshness. Four independent clocks, and the agent only controls none of them. For the worker agent, this manifests as **authority that silently shrinks or silently persists** depending on which side of the rotation boundary its token landed. A worker that read its token's `exp` and planned a 6-hour task around it may find its authority clamped to 90 minutes by a freshness bound it never saw. Conversely, a worker whose token landed in the collapse window may believe its authority ended at `exp` when in fact a stale verifier is still honoring it — until an auditor disagrees. For the coordinating agent, the effect is that **audit replay is not idempotent across key-set resolution times**. Two auditors resolving the issuer's JWKS at different times will reach different verdicts on the same call. This breaks the fundamental AAIF property that authorization decisions are replayable. The fix is that the authorization decision must be *bound to a key-set snapshot*: the verifier records the JWKS version (or key-set hash) it used, and the audit replays against that snapshot rather than the current set. A decision without a pinned key-set version is not replayable and must be treated as un-auditable. The guardrail, in one sentence: **never verify a delegated capability against a key you did not resolve within the issuer's declared rotation period, and never record an authorization decision without pinning the key-set version that justified it.** Both halves are required; either alone leaves a hole. ```python import time from dataclasses import dataclass class StaleAuthorityWindowError(RuntimeError): """Raised when a delegated capability token would be honored under a signing key whose resolution is older than the issuer's declared rotation period, collapsing the token-validity / key-authority windows.""" pass class ReplayUnpinnedError(RuntimeError): """Raised when an authorization decision is recorded without a pinned key-set version, making the decision non-replayable by an auditor.""" pass @dataclass(frozen=True) class KeyResolution: key_id: str epoch_end: float # issuer's authority end for this key resolved_at: float # when the verifier fetched this key jwks_version: str # pinned snapshot identifier @dataclass(frozen=True) class DelegatedCapabilityToken: signing_key_id: str not_before: float not_after: float scope: frozenset class AAIFVerifier: def __init__(self, max_key_age: float): # max_key_age MUST be < the issuer's minimum rotation period. if max_key_age <= 0: raise ValueError("max_key_age must be positive") self.max_key_age = max_key_age def verify( self, token: DelegatedCapabilityToken, resolution: KeyResolution, requested_scope: frozenset, now: float, ) -> dict: # 1. Temporal validity of the token itself. if not (token.not_before <= now <= token.not_after): raise StaleAuthorityWindowError( f"token outside temporal validity at {now}" ) # 2. Key-resolution freshness: the load-bearing invariant. age = now - resolution.resolved_at if age > self.max_key_age: raise StaleAuthorityWindowError( f"signing key {resolution.key_id} resolved {age:.1f}s ago, " f"exceeds max_key_age={self.max_key_age:.1f}s; " f"authority cannot be confirmed current" ) # 3. Epoch-bounded authority: the key must still hold authority at # verification time, per the issuer's current manifest. if now > resolution.epoch_end: raise StaleAuthorityWindowError( f"signing key {resolution.key_id} authority ended at " f"{resolution.epoch_end}, verification at {now}; " f"token.not_after={token.not_after} exceeds key epoch" ) # 4. Scope containment. if not requested_scope.issubset(token.scope): raise StaleAuthorityWindowError( f"requested scope {requested_scope} not within {token.scope}" ) # 5. Pin the key-set version so the decision is replayable. if not resolution.jwks_version: raise ReplayUnpinnedError( "authorization decision recorded without a pinned " "jwks_version; audit replay would resolve a different key set" ) # Effective authority is clamped to the tighter of token and key. effective_end = min(token.not_after, resolution.epoch_end) return { "admitted": True, "effective_not_after": effective_end, "jwks_version": resolution.jwks_version, "clamped": effective_end < token.not_after, } # --- demonstration of the collapse window --- def _demo() -> None: now = 1_000_000.0 token = DelegatedCapabilityToken( signing_key_id="key_v1", not_before=now - 60, not_after=now + 6 * 3600, # 6h token scope=frozenset({"filesystem:read"}), ) # Key rotated at now+90m; verifier resolved it 30m ago. resolution = KeyResolution( key_id="key_v1", epoch_end=now + 90 * 60, resolved_at=now - 30 * 60, jwks_version="jwks-2025-06-13T00:00Z", ) verifier = AAIFVerifier(max_key_age=3600.0) # At t=3h the token is still temporally valid, but the key's authority # ended at t+90m. This must raise, not admit. try: verifier.verify(token, resolution, frozenset({"filesystem:read"}), now + 3 * 3600) except StaleAuthorityWindowError as e: print(f"collapse window detected: {e}") if __name__ == "__main__": _demo() ```