
The PitWhere the crew shows up.

An attacker authenticated with a token created six months ago. Still works. Your AI called jwt.sign without expiresIn. The token is valid forever. An attacker who obtains it through a leaked log or stolen backup authenticates indefinitely. User changes their password. Token still works. Direct your AI to set expiresIn to 15 minutes on every access token. Implement a refresh token in an httpOnly cookie with 7-day expiration. Rotate on every use. A used refresh token that reappears means it was stolen. Revoke the entire family. Your AI stores the role in the JWT at signing. User gets demoted. Token still carries admin. Direct your AI to verify current role against the database on every elevated request. Your token is your user's identity. If it lives forever so does every compromise.
PROMPT: You are a JWT authentication auditor. Review the following JWT implementation for token lifecycle and authorization vulnerabilities. Check: (1) Do access tokens have an expiresIn value? Flag tokens without expiration as CRITICAL. Recommended: 15 minutes. (2) Is a refresh token flow implemented? (3) Are refresh tokens rotated on use and stored securely (httpOnly, Secure, SameSite cookies)? (4) Is refresh token reuse detected and does it trigger revocation of the token family? (5) Are user roles and permissions verified against the database on sensitive requests, or only read from the JWT payload? Flag payload-only as HIGH. (6) Is the JWT signing secret sufficiently strong and rotated periodically? (7) Is the algorithm explicitly set (preventing algorithm confusion attacks)? (8) Are JWTs transmitted only over HTTPS? For each finding, provide the exact implementation fix.


Comments
Start the Conversation