AWS Builder Center

JWT Revocation: Why Logout Can Leave an Access Token Working

Build a revocation contract around access-token lifetime, session state, refresh-token replay, and explicit failure handling. Logout needs an observable boundary.

Series: Json Web Tokens (2 articles)

  1. 2
    JWT Revocation: Why Logout Can Leave an Access Token Working This article
You click logout. The browser clears its credentials. A copied access token still reaches the API successfully. Nothing about those two observations is contradictory. The browser forgot the token; the API hasn't learned that it should stop accepting it.
A signed access token is closer to an entry pass than a live permission lookup. Printing an expiry on the pass doesn't give every door a connection to the reception desk. I'd decide how quickly a door must reject a cancelled pass before choosing the revocation mechanism.
Let's build that contract for a hypothetical application. Access tokens live for five minutes. Ordinary reads can tolerate that remaining lifetime after logout. Administrative actions must consult current session state. These are example product decisions, not universal security thresholds.

Give logout a precise meaning

There are three separate actions: remove credentials from the current client, prevent future token refresh, and reject already-issued access tokens at resource servers. A logout endpoint can implement the first two while other APIs continue accepting an access token until expiry.
 OAuth token revocation  defines an authorization-server endpoint and discusses propagation to resource servers. A successful response alone doesn't demonstrate that every verifier has invalidated its local view. Test the API that performs the protected action.
My first decision would be whether local JWT verification is still buying us enough. If every request needs immediate, centralized permission evaluation, an opaque token with introspection or an ordinary server-side session may be a clearer design. JWTs are useful when carrying a signed snapshot helps. They don't require us to pretend that authorization never changes.

Keep the identity check and the session check distinct

For the sensitive path, put a session identifier and session version in an access token. After cryptographic validation, load the corresponding session record. Reject a revoked session or a version mismatch. An unknown lookup result must not silently become permission.
The following illustrative application function assumes its input claims have already passed signature, issuer, audience, required-field, and expiry checks. It shows the additional session decision, not a complete authentication server.
class AccessDenied(Exception):
pass

class AuthorizationUnavailable(Exception):
pass

def require_live_session(claims, load_session):
sid = claims.get('sid')
version = claims.get('session_version')
if not isinstance(sid, str) or type(version) is not int:
raise AccessDenied('invalid session claims')
try:
session = load_session(sid)
except TimeoutError as exc:
raise AuthorizationUnavailable('session check unavailable') from exc
if session is None or session['revoked']:
raise AccessDenied('session revoked or missing')
if session['subject'] != claims['sub']:
raise AccessDenied('session subject mismatch')
if session['version'] != version:
raise AccessDenied('session version changed')
return session
A session-version increment can invalidate all tokens for that session without storing every JWT. A denylist keyed by token identifier is useful when only a particular token must be revoked. Its entries need remain only until those tokens can no longer be accepted, including allowed clock skew. Neither approach is inherently unscalable; the lookup rate, distribution, availability target, and retention determine its cost.
If the API caches a positive session lookup for 30 seconds, it has also chosen a possible stale-authorization interval. Include cache expiry, invalidation delivery, replica lag, and retry behavior in the contract. A push notification can shorten that interval, but a disconnected subscriber needs resynchronization. Silence isn't evidence that nothing changed.

Rotate refresh tokens without losing the race

 RFC 9700  requires public clients receiving refresh tokens to use sender-constrained tokens or refresh-token rotation. Rotation retains the relationship between successive tokens so reuse can be detected. It doesn't retroactively erase an independently accepted access token.
I'd store a hash of each high-entropy opaque refresh token, its grant or family identifier, consumption state, and expiry. Rotation must atomically consume the presented token and create its successor. Two concurrent requests must not both mint independent active successors from the same token.
In a transaction, lock or conditionally update the presented token. If it is unused and valid, consume it and create the next token before committing. If a consumed token returns, mark the grant revoked and commit that outcome before returning an error. Rolling the transaction back on the error can accidentally undo the very revocation intended to protect the grant.
There is a usability cost. A legitimate client retry after a lost response can resemble theft. Serialize refreshes at the client and define the server's retry policy deliberately. Any grace mechanism needs a bounded design that doesn't give a stolen predecessor indefinite life.

Verify the boundary from the resource server

Use a real token copied before logout and record these outcomes in a disposable environment:
Experiment
Required observation
Log out, then use the copied token on a sensitive endpoint
Session check denies it.
Use it on a locally verified ordinary read
Acceptance lasts only for the explicitly permitted interval.
Present the old refresh token after successful rotation
The configured replay response is committed.
Race two refresh requests
At most one successor is created from the presented token.
Interrupt the session store
Sensitive action fails closed with a retriable service error.
Disconnect an invalidation consumer
Resynchronization restores the intended boundary.
The session decision function was exercised locally for revocation, subject and version mismatch, malformed claims, missing records, and store timeouts. The distributed propagation and refresh-transaction scenarios above are integration checks, not claimed production measurements.

Conclusion

I'd start with short-lived access tokens and a clearly managed refresh grant, then add current session checks where the required revocation delay demands them. Measure the interval from a committed logout to a rejected protected request. That interval, including failures and caches, is the behavior users are actually relying on.
Adapted and substantially updated from  my original article . Technical references reviewed November 8, 2026. Prepared with AI assistance; examples and validation limits are identified in the text.

Series: Json Web Tokens (2 articles)

  1. 2
    JWT Revocation: Why Logout Can Leave an Access Token Working This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article