Why the reset flow is a target
"Forgot password" is a back door by design: it lets someone into an account without the password. If it is built carelessly, an attacker can use it to take over accounts without ever guessing a password. It is one of the most common routes to account takeover.
Common flaws
1. Predictable or short tokens
Reset tokens based on timestamps, user IDs or short numeric codes can be guessed. Tokens must be long, random and generated by a cryptographically secure function.
2. Tokens that never expire or can be reused
A reset link should work once and expire quickly — typically within 15 to 60 minutes.
3. Host header poisoning
If the app builds the reset link from the request's Host header, an attacker can trigger a reset for a victim with their own domain in the header. The victim receives a genuine email containing a link to the attacker's site, which captures the token. See host header injection. Always build links from a fixed, configured domain.
4. User enumeration
Messages like "No account with that email" tell attackers which emails are registered. Show the same message whether or not the account exists.
5. No rate limiting
Without limits, attackers can flood users with reset emails or brute-force short codes. See brute force attacks.
6. Token leaks
Tokens in URLs can leak through the Referer header to third-party scripts on the reset page. Set a strict Referrer-Policy and keep third-party scripts off that page.
7. Sessions left alive
After a reset, existing sessions should be invalidated. Otherwise an attacker who already had a session keeps it. See session hijacking.
8. Changing email without verification
If a logged-in user can change the account email without confirming the old address or re-entering a password, a stolen session becomes a permanent takeover.
A secure reset checklist
- long random single-use tokens, stored hashed
- short expiry
- links built from a configured base URL
- identical responses for existing and non-existing accounts
- rate limits per IP and per account
- all sessions revoked on reset; notification email sent
- re-authentication for email and password changes
Test your reset flow
Yrzo AI tests authentication and reset flows for these issues as part of its Professional and Advanced reports. See plans or start free.
Related reading: Account Takeover Prevention: Protecting Customer and Staff Accounts · Laravel Security Checklist for Production Apps · Penetration Testing Checklist: How to Prepare, Run and Follow Up