Is your password reset flow safe? A 10-minute check for AI-built apps
The password reset flow is a second login door. If it is weak, an attacker does not need your password. They take over the account through "forgot password" instead. AI-built apps often get the happy path right: you cli
The password reset flow is a second login door. If it is weak, an attacker does not need your password. They take over the account through "forgot password" instead.
AI-built apps often get the happy path right: you click the link, you set a new password. The checks around it are what get skipped.
Who is at risk
Any app with email and password sign-in and a "forgot password" link. That includes apps that use a hosted auth provider, because the settings and redirects are still yours to configure.
The 10-minute check (your own app only, with test accounts)
- Is the token random and long? Request a reset for a test account. The link should hold a long random token, not something guessable like a user id, an email or a timestamp.
- Does it expire? Wait past the stated time (or request a second link) and try the first one. Old links should stop working.
- Is it single use? Use the link to set a password, then open the same link again. It should be refused.
- Does a new request cancel the old link? Request two resets in a row. Only the newest should work.
- Is the reset link built from a fixed address? Some apps build the link from the request's Host header. Send the reset request with a changed Host header on a test account and check the email. If the link points at the other host, an attacker can steal the token.
- Does the form answer the same for every email? A real address and a made-up one should get the same message and a similar response time.
- Is there a limit? Submit the form many times for one address. You should hit a cap, or strangers can flood your users' inboxes.
- Does the token stay out of the wrong places? The reset page should not load third-party scripts or images that would receive the token in the Referer header. Check the Network tab.
- After a reset, are other sessions signed out? Sign in on two browsers, reset the password in one, then reload the other. It should be signed out.
What to fix
- Use your auth provider's built-in reset flow before writing your own.
- Make tokens random, single use and short lived, and store only a hash of them.
- Build links from a fixed, configured site URL, never from request headers.
- Return one generic message for every email, and rate limit the form.
- Sign out all sessions after a password change.
A prompt you can paste into your AI builder
"Review the password reset flow. Use random single-use tokens that expire in 30 minutes and are stored hashed. Build the reset link from a configured SITE_URL, not from request headers. Return the same response for known and unknown emails, rate limit reset requests per email and per IP, and invalidate all sessions after a password change."
What a scanner can and cannot tell you
An outside scan cannot trigger a reset email or open your inbox, so it cannot test this flow. It can only report what a visitor sees without signing in. This one you test yourself, with test accounts, as above.
I work on ProofForge. The free scan covers the outside view and says plainly what it could not check.
Check your own app from the outside, free. Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see. One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.