JWT Token Lifetime
| Severity | Medium to High |
|---|---|
| Checks | jwt.missing_expiry, jwt.long_lifetime, jwt.expired_accepted |
| Classifications | CWE-613: Insufficient Session Expiration |
| OWASP Category | OWASP API2:2023 Broken Authentication |
The exp claim bounds how long a leaked or stolen token stays usable. A token without exp, with a lifetime of days or months, or accepted after exp has passed, gives an attacker a long window to replay it.
Checks
Section titled “Checks”| Check | Mode | What it detects |
|---|---|---|
jwt.missing_expiry | Offline | The token has no exp claim |
jwt.long_lifetime | Offline | exp minus iat (or minus now without iat) is above --max-token-lifetime (default 24h) |
jwt.expired_accepted | Online | The server accepts the token while its exp is in the past |
jwt.expired_accepted sends the token as given, so pass an expired token. When the HMAC secret is known, timestamp tampering re-signs a valid token with an expired exp.
How to test?
Section titled “How to test?”jwtop crack [token] --max-token-lifetime 1hjwtop crack [expired-token] --url [url]What is the impact?
Section titled “What is the impact?”A token that never expires, or whose expiry is not enforced, can be replayed indefinitely once leaked through logs, browser storage or a compromised client.
How to remediate?
Section titled “How to remediate?”- Always set
exp, and keep access token lifetimes short (minutes to hours); use refresh tokens for longer sessions. - Verify
expon every request and do not disable claims validation in the JWT library.