Skip to content

JWT Timestamp Tampering

SeverityHigh
Classifications
OWASP CategoryOWASP API2:2023 Broken Authentication

The “JWT Timestamp Tampering” vulnerability affects servers that verify a token’s signature but not its time-based claims (exp, and usually nbf and iat with it). A valid signature only proves who issued the token, not that it is still meant to be used. Several JWT libraries can be configured, or default, to skip claims validation; a server set up this way accepts tokens forever once they have been issued.

VulnAPI tests this by re-signing the token under test with its exp claim pushed one hour into the past. A server that enforces expiration must reject it; a server that accepts it does not validate time-based claims at all. See also JWT Expired.

For more details, you can refer to the jwtop documentation on Timestamp Tampering.

An application issues HMAC-signed tokens that expire after one hour:

{
"sub": "2cb307ba-bb46-4194-854f-4774046d9c9b",
"name": "John Doe",
"iat": 1516239022,
"exp": 1516242622
}

If the server does not validate exp, a token stolen today (from logs, browser storage or a leaked request) remains usable long after it should have expired, and logging out or shortening the token lifetime does not protect the account.

If you want to test only the “JWT Timestamp Tampering” vulnerability, you can use the following command:

Terminal window
vulnapi scan curl [url] -H "Authorization: Bearer [JWT]" --scans jwt.timestamp_tampering

This check only runs for HMAC-signed tokens (HS256, HS384, HS512) and needs the signing secret to forge the expired token. VulnAPI uses the secret recovered by the weak secret check; if you already know it, pass it with --jwt-secret:

Terminal window
vulnapi scan curl [url] -H "Authorization: Bearer [JWT]" --scans jwt.timestamp_tampering --jwt-secret [secret]

VulnAPI supports scanning against various types of other vulnerabilities as well.

  • Unlimited token lifetime: A stolen token never expires, giving an attacker a permanent foothold.
  • Ineffective revocation: Logging out, rotating sessions or shortening token lifetimes has no effect on tokens already issued.
  • Session hijacking: Tokens leaked through logs, caches or browser storage remain usable indefinitely.
  • Validate time-based claims: Make sure your JWT library verifies exp (and nbf when present) on every request; do not disable claims validation.
  • Require exp: Reject tokens that do not carry an expiration time.
  • Allow only a small clock skew: Tolerate a few seconds or minutes of skew, never more.
  • Protect the signing secret: Use a long, random HMAC secret so an attacker cannot forge tokens in the first place.