CyberSearch .in
SUBSCRIBE
← All articles
WEB SECURITY · 7 min read

Password reset flows that don't become a back door

Day 11 of our web security series: how the Forgot password link works, where it goes wrong, and how to build one that only lets the real owner back in.

Day 11 of Web Security, From the Ground Up: password reset flows

This week we’ve hashed passwords properly, slowed down guessing at the login page and locked down the session cookie. All of that protects the front door. But every login page has a second door right next to it: the small “Forgot password?” link.

That link has to let someone into an account without knowing the password. That’s its whole purpose. So if it’s built carelessly, it lets the wrong person in just as easily. Today is about making sure it only opens for the real owner.

How a good reset flow works

Most well-built sites follow the same basic pattern:

  1. You enter your email address.
  2. The site shows the same message whether or not that address has an account: “If an account exists, we’ve sent a reset link.”
  3. If the account exists, the site creates a long, random, single-use token, stores a hashed copy with an expiry time, and emails you a link containing it.
  4. You click the link, the site checks the token is valid and unexpired, and you choose a new password.
  5. The token is destroyed, all other sessions are logged out, and you get a confirmation email saying your password changed.

Every one of those steps exists because someone, somewhere, got it wrong.

Why it matters for security

A weak reset flow is an account takeover that needs no password at all. It also skips the rate limits on the login page, and sometimes two-factor login too. Because the reset page is used rarely, it’s often tested less than the login page, so mistakes survive for years.

Here are the most common ways the second door gets left open.

Where reset flows go wrong

Telling attackers which accounts exist

“No account found with that email” sounds helpful, but it lets anyone check whether a particular person uses your site. That’s a privacy leak on its own, and it gives attackers a clean list of real accounts to target with credential stuffing (Day 9). Show the same message, and take about the same time to respond, whether the account exists or not.

Guessable or reusable tokens

A reset token is a temporary password. It needs the same strength: generated by a secure random generator, long enough that guessing is hopeless, never based on the user ID, email or time. It should work once, expire quickly (15 to 60 minutes is common), and stop working as soon as a newer one is requested or the password is changed. Store it hashed, like a password, so a database leak doesn’t hand out live reset links.

The reset link in the email has to point to your real site. Some applications build that link from the address the request claims to come from, using the Host header (remember from Day 2: never trust what the browser sends). If an attacker can change that header, the email your user receives may contain a link to the attacker’s server, and clicking it hands over the token. The fix is to build links from a fixed, configured site address, never from request headers.

Tokens that leak through the page

Once the user lands on the reset page, the token is sitting in the address bar. If that page loads third-party scripts, analytics or images, the full URL can be sent to them in the Referer header. Keep the reset page plain, set Referrer-Policy: no-referrer on it, and exchange the token for a short server-side session as soon as the page loads.

Security questions

“What was the name of your first pet?” was never a good second factor. The answers are often guessable, findable on social media, or the same on every site. Modern guidance (including OWASP and NIST) says not to rely on them. Use the email link, and if the account has two-factor login, ask for it as well.

Resets that don’t end anything

People often reset a password because they suspect someone else got in. If the reset doesn’t log out existing sessions (Day 10), the intruder stays logged in with the old session after the owner thinks they’ve fixed things. End every session and revoke “remember me” tokens on a successful reset.

Silent changes

If the password changes and nobody is told, a takeover can go unnoticed for weeks. Always send a “your password was changed” email to the account’s address, with a clear way to report “this wasn’t me”. The same goes for changes to the account’s email address or phone number, which are an attacker’s favourite way to make a takeover permanent: notify the old address too.

Don’t forget the rate limits

The reset form sends email, so it can be abused to flood someone’s inbox, or to hammer your email provider until it blocks you. Apply the same thinking as Day 9: limit requests per email address and per IP, and add a step-up check like a CAPTCHA if the volume looks automated.

A quick self-check for your site

Try your own reset flow once, as a user, and look for these:

  • The message after entering an email is the same for a real and a made-up address.
  • The email link points to your real domain.
  • The link stops working after you’ve used it once.
  • An old link stops working after you request a new one.
  • You get a “password changed” email afterwards.
  • Other devices where you were logged in are signed out.

If any of these fail, that’s where to start.

What you can do today

If you use websites:

  1. Secure your email account first: a strong unique password and two-factor login. Almost every reset link on the web goes there, so whoever controls your inbox controls your accounts.
  2. Never click a password reset email you didn’t ask for. Ignore it, and if they keep coming, change your password from the site directly.
  3. Don’t ignore “your password was changed” emails. If it wasn’t you, use the site’s recovery or support option straight away.
  4. If a site still asks security questions, give answers that aren’t true or findable, and store them in your password manager.

If you run a website:

  1. Show the same response for existing and non-existing accounts on reset, sign-up and login.
  2. Use long random tokens, store them hashed, and make them single-use and short-lived.
  3. Build reset links from a configured site address, never from the Host header.
  4. Log out all sessions on reset, require two-factor login when it’s enabled, and send a confirmation email.
  5. Rate limit the reset form. The OWASP Forgot Password Cheat Sheet covers each step in detail.

Coming up next

On Day 12 we’ll make logins stronger still: adding passkeys and two-factor login to your own site, and which options give your users the most protection for the least effort.

Written & tested by CyberSearch Get one tip a week →
KEEP READING

More from the blog

WEB SECURITYNov 17, 2026 · 7 min
Adding passkeys and 2FA to your own site

Day 12 of our web security series: which second factors protect your users best, how passkeys work, and how to add them without locking people out.

WEB SECURITYNov 15, 2026 · 7 min
Sessions done right: secure cookie settings explained

Day 10 of our web security series: every setting on a login cookie explained, and the server-side habits that keep a logged-in user safe.

WEB SECURITYNov 14, 2026 · 7 min
Login pages that resist guessing: rate limits and lockouts

Day 9 of our web security series: how attackers try passwords at scale, and how a login page can slow them down without locking out the real user.