Authentication and session management define who a caller is on every HTTP request. If an adversary can guess credentials without throttling, hijack an unrotated session identifier, or intercept a leaked password-reset token, every downstream authorization check is compromised.
Four authentication and session flaws to test before launch
Even when teams use established identity libraries, custom login wrappers, password recovery routes, and cookie settings frequently introduce exploitable gaps:
- Session fixation and missing rotation: failing to issue a fresh session identifier when a user logs in or elevates privileges, or failing to invalidate the server-side session token when the user clicks log out.
- Unthrottled login and OTP endpoints: allowing thousands of rapid credential-stuffing or 6-digit OTP guesses on `/api/login` or `/api/verify-otp` without per-account and per-IP rate limiting and lockout.
- Missing cookie security attributes: issuing session cookies without `Secure`, `HttpOnly`, and `SameSite` flags, or scoping cookies broadly to a parent domain where sibling subdomains can read or overwrite them.
- Password-reset token leakage and reuse: placing single-use reset tokens in URLs where third-party scripts or `Referer` headers leak them, failing to expire tokens after one use, or accepting host-header poisoning when building reset links.
Checklist for a resilient session lifecycle
Hash stored passwords with Argon2id or bcrypt, enforce rate limiting and multi-factor authentication (WebAuthn/Passkeys or TOTP) on sensitive accounts, and bind password-reset URLs to a hardcoded canonical origin rather than the incoming HTTP `Host` header.
Store primary session identifiers in `Secure`, `HttpOnly`, `SameSite=Lax` (or `Strict`) cookies—preferably using the `__Host-` cookie prefix—rotate session tokens on login and password change, and revoke all active sessions in your server store whenever a user resets a password or changes multi-factor authentication settings.
Keep session tokens out of localStorage, enforce Secure and HttpOnly cookie attributes, and invalidate server-side sessions on logout and password reset.