# How does an instance detect its own revocation when the token it holds is still cryptographically valid **Date of Record:** 2026 November 27 **Scope:** Applies to autonomous agents that authenticate to peers, tools, or orchestrators via short-lived bearer tokens (JWTs, macaroons, signed warrants) and that may continue executing across the token's expiry boundary. Does not address long-lived API keys, mTLS client certs, or human-driven interactive sessions where a refresh happens synchronously. ## Core Distinction There are two independent notions of "the token is still good," and agent runtimes routinely conflate them: 1. **Cryptographic validity** — the token's signature verifies, its `exp` claim is in the future, and its `nbf`/`iat` claims are satisfied *at the moment of the check*. 2. **Authorization continuity** — the issuing authority has not revoked the token's warrant, rotated the underlying key, or changed the agent's granted capability set since issuance. A revocation is *not* a signature failure. When an orchestrator revokes an agent's warrant and rotates the signing key, every token the agent already holds continues to verify against the *old* key material it cached, and continues to pass `exp` checks until wall-clock expiry. The agent has no signal. A stateless verifier that checks only (1) will accept a revoked credential for the entire remaining lifetime of the token — which, for a 15-minute rotation window, is up to 15 minutes of unauthorized execution. The non-obvious boundary: **the moment of revocation is invisible to a purely local verifier.** Detection requires either (a) an out-of-band revocation channel the agent polls, (b) a key-version binding the agent checks against a rotating source of truth, or (c) a peer that rejects the token and returns a distinguishable error the agent recognizes as "revoked" rather than "expired" or "transient failure." ## What Was Observed A three-agent pipeline (planner → executor → auditor) used short-lived JWTs with a 900-second TTL, rotated every 300 seconds by the issuer. Each agent cached its token and the issuer's JWKS locally, refreshing JWKS only when a signature failed to verify. At T+0 the executor's warrant was revoked (a policy change removed its `write:ledger` capability). The issuer rotated its signing key at T+0 as part of the same operation. The executor: - Continued to present its still-unexpired token to the ledger tool. - The ledger tool verified the signature against its *own* cached JWKS, which still contained the pre-rotation key, and accepted the token. - The executor performed 41 unauthorized writes over 612 seconds before the token's `exp` fired. The failure trace: - `T+0` — revocation event; key rotated; old key retained in issuer JWKS for a grace window (so *new* verifiers could still validate in-flight tokens — a deliberate compatibility choice that extended the blast radius). - `T+0..T+612` — executor's local `exp` check passes; signature check passes against cached key; no revocation list is consulted because the agent has no such concept. - `T+612` — token expires; executor attempts refresh; refresh request is rejected with `401 invalid_grant` because the warrant is gone. *This is the first observable signal* — and it arrives 612 seconds after the authority actually withdrew permission. - `T+612` — executor raises a refresh error, but by then the writes are committed and the auditor (which shares the same stale JWKS) has already attested them. The auditor did not catch it because the auditor's verification is *also* local: it re-verifies signatures against its cached key set, not against live authorization state. Both verifier and executor were consistent with each other and both wrong relative to the issuer. ## Condition of Validity The invariant that must hold for local verification to be sound: > A token is authorized iff (signature verifies against a key whose version ≥ the issuer's current revocation epoch) AND (the token's `jti` is absent from the revocation set for that epoch) AND (`exp` not passed). Local-only verification silently drops the first two conjuncts. It is only valid under the assumption that **revocation and key rotation never occur within a token's lifetime** — an assumption that short-lived tokens are specifically designed to violate, because the whole point of short TTL is to make revocation *unnecessary*. The trap: operators rely on short TTL *instead of* revocation, then add revocation *on top*, and the two mechanisms interact badly because the grace window for key rotation re-extends the token's effective life. The condition under which an agent may trust a locally-verified token without a revocation check is narrow: the token TTL must be strictly less than the revocation-propagation latency the system tolerates, *and* the JWKS grace window must be zero (old keys dropped immediately on rotation). If either fails, local verification is unsound. ## Decision Boundary The agent must distinguish three rejection classes from a peer, because the correct response differs: - **`exp`-expired** → refresh via the normal path; retry is safe. - **`invalid_grant` / `revoked`** → do *not* retry; halt, checkpoint, and surface to the orchestrator. Retrying with a fresh token will also fail, and worse, a naive retry loop with backoff can mask the revocation as transient failure for the full backoff budget. - **signature/`kid`-unknown** → fetch fresh JWKS once, re-verify; if still unknown, treat as revocation (the key that signed you is gone). The boundary decision: an agent that receives a *signature failure* on a token it believes is valid must **not** assume "stale JWKS, refresh and retry." It must first check whether the `kid` is absent from the *current* JWKS (rotation/revocation) versus present-but-mismatched (corruption). Absent `kid` = revoked epoch. Present `kid` + bad signature = tampering or clock skew. Additionally, any agent performing a *write* or *state-changing* action must not rely on the token it holds at action time. It must obtain a fresh token whose `iat` is within the current revocation epoch, or it must confirm via a revocation-check endpoint. Read-only idempotent actions may tolerate the grace window; writes may not. ## Operational Effect The architectural guardrail is a **revocation epoch binding**: every token carries an `epoch` claim equal to the issuer's monotonic revocation counter at issuance. Verifiers cache the issuer's current epoch alongside the JWKS and reject any token whose `epoch` is less than current, *regardless of `exp`*. This converts the invisible revocation into a locally-checkable predicate, at the cost of one epoch fetch per verification window (not per request). Second guardrail: **zero-grace key rotation for revocation events.** The compatibility grace window that keeps old keys alive for in-flight tokens must be disabled when rotation is triggered by revocation (as opposed to routine rotation). Routine rotation keeps the grace window; revocation rotation does not. The two rotation causes must be distinguishable in the issuer's API. Third: **write-path re-authorization.** Any state-mutating tool call must carry a token whose `iat` is within `revocation_epoch_current`, forcing a refresh round-trip that will fail loudly if the warrant is gone. This bounds unauthorized writes to at most one refresh latency rather than one token TTL. The failure this prevents is not "the agent used an expired token" — that is caught trivially. It is "the agent used a *valid* token for a warrant that no longer exists," which is undetectable without an epoch binding or an out-of-band check, and which the auditor cannot catch because the auditor shares the same stale view of authority. ```python import time from dataclasses import dataclass class RevocationUndetectedError(RuntimeError): """Raised when an agent cannot prove its held token is still authorized against the issuer's current revocation epoch.""" pass @dataclass class Token: jti: str kid: str epoch: int iat: float exp: float signature_valid: bool @dataclass class IssuerState: current_epoch: int revoked_jtis: set live_kids: set def verify_for_write(token: Token, issuer: IssuerState, now: float | None = None) -> None: """Verify a token for a state-changing action. Local signature + exp checks are necessary but NOT sufficient. The token must also be bound to the issuer's current revocation epoch, and its jti must not be revoked. A token that passes exp but fails epoch is a revoked warrant masquerading as a live credential. """ now = time.time() if now is None else now if not token.signature_valid: # A signature failure on a token the agent believes valid is ambiguous: # either stale JWKS (rotation) or tampering. Resolve via kid liveness. if token.kid not in issuer.live_kids: raise RevocationUndetectedError( f"signing key {token.kid!r} no longer live: rotation/revocation epoch " f"{issuer.current_epoch}; token epoch {token.epoch}" ) raise RevocationUndetectedError( f"signature invalid but kid {token.kid!r} live: tampering or clock skew" ) if now >= token.exp: # Ordinary expiry: safe to refresh and retry. raise RevocationUndetectedError( f"token {token.jti!r} expired at {token.exp}; refresh via normal path" ) if token.epoch < issuer.current_epoch: # The invisible revocation: exp is fine, signature is fine, but the # warrant was withdrawn in a later epoch. Do NOT retry with backoff. raise RevocationUndetectedError( f"token {token.jti!r} issued in epoch {token.epoch} < current " f"{issuer.current_epoch}: warrant revoked; halt and checkpoint" ) if token.jti in issuer.revoked_jtis: raise RevocationUndetectedError( f"token {token.jti!r} explicitly revoked in epoch {issuer.current_epoch}" ) def guarded_write(token: Token, issuer: IssuerState, apply_write) -> None: verify_for_write(token, issuer) apply_write() ```