Easy+50 XPA07:2021 Identification and Authentication FailuresCWE-347
JWTAuthenticationToken Validation
Scenario
Your application validates JWT tokens by decoding the payload and returning user info.
The token payload contains an expiry timestamp (exp) in Unix seconds, but the validation function never checks it.
An attacker with an old, expired token can still authenticate indefinitely.
Failing to check token expiry means revoked or stolen tokens remain valid forever, allowing persistent unauthorized access even after a user logs out or a breach is detected.
Your Tasks
Inspect the validateToken function — it returns valid:true without checking payload.exp.
Fix it: if payload.exp < currentTime, throw 'Token expired'.
Ensure tokens where exp === currentTime are still considered valid (boundary condition).