Lorixen.
EN

A password reset flow that doesn't leak or annoy

Short answer: A good password reset flow gives the same response whether or not an account exists, sends a random, single-use link that expires, changes nothing until the link is used, limits repeated requests, and confirms the change by email. For users, it should be quick: one field, one clear email, one page to set the new password, then a normal sign-in. OWASP's Forgot Password Cheat Sheet is the standard reference for the security side.

"Forgot password" is one of the most-used features in any web app, and one of the most commonly built carelessly. It can reveal which email addresses have accounts, let attackers flood someone's inbox, or leave reset links that work forever. It can also frustrate real users with confusing messages and expired links. This step-by-step guide covers both sides for a typical small business app: a client portal, booking system or internal tool.

Step 1: The request form

Keep it to one field: email address (or username, if that's how people sign in).

Security rules from OWASP's cheat sheet:

  • Return a consistent message for existing and non-existing accounts, for example: "If an account exists for that email, we've sent a link to reset your password. Check your inbox and spam folder."
  • Respond in a consistent time, so attackers can't tell from response speed which accounts exist. OWASP suggests asynchronous processing or following the same logic either way rather than exiting early.
  • Limit automated requests, for example rate limiting per account, a CAPTCHA or similar controls. Without this, OWASP notes, an attacker could send thousands of reset requests and flood the user's inbox.

User experience: the neutral message should still be helpful. Tell people what to expect next and roughly how long the link stays valid, and offer a route for those who no longer have access to their email.

Step 2: Generate the token

OWASP recommends that tokens or codes are:

  • randomly generated with a cryptographically secure method;
  • long enough to resist brute-force guessing;
  • stored securely;
  • single use, and expire after an appropriate period.

It also advises not changing the account (for example, locking it) until a valid token is presented. Otherwise anyone could lock other people out just by typing their email address.

How long should a link last? Long enough for someone to find the email, short enough to limit risk. Many apps choose somewhere between 15 minutes and a few hours. Whatever you choose, say it in the email.

Step 3: Build and send the email

OWASP's guidance for URL tokens includes several details that are easy to miss:

  • Don't build the reset URL from the incoming Host header. Hard-code your domain or validate it against a list of trusted domains, to avoid Host header injection.
  • Use HTTPS for the link.

Make the email clear:

  • a recognisable sender name and subject ("Reset your password for [App name]");
  • one prominent button or link;
  • how long the link is valid;
  • "If you didn't request this, you can ignore this email; your password hasn't changed."

Send it from a properly configured domain, so it doesn't land in spam.

Step 4: The reset page

When someone opens the link:

  • Check the token: valid, unexpired, unused. If not, explain plainly ("This link has expired or has already been used") and offer to send a new one.
  • Protect the token from leaking: OWASP recommends the reset page set a Referrer Policy of no-referrer. MDN explains that with no-referrer, the Referer header is omitted entirely, so the token in the URL isn't passed to any third-party resource or link on that page. Keep third-party scripts off this page anyway.
  • Rate-limit token attempts to prevent brute-forcing.
  • Ask for the new password twice, apply the same password policy as the rest of the app, and show the rules up front.

Step 5: After the password changes

OWASP's recommendations:

  • Store the new password securely, using proper password hashing.
  • Send a confirmation email saying the password was changed, without including the password.
  • Don't log the user in automatically. Have them sign in through the normal process, which keeps session handling simpler and less error-prone.
  • Offer to sign out other sessions, or do it automatically.
  • Invalidate the token and any other outstanding reset links.

Step 6: Edge cases worth deciding in advance

  • Multiple requests: when a new link is requested, invalidate older ones so only the latest works.
  • Changed email addresses: send reset links only to the current, verified address.
  • Suspected account compromise: a password reset alone may not be enough. OWASP notes an attacker may still have an active session or may have changed recovery details; review those with the verified owner and end existing sessions.
  • Staff-initiated resets: if admins can trigger resets, log who did it and when.

Step 7: Test it like an attacker and like a user

  • Request a reset for an existing and a non-existing email, and compare responses and timing.
  • Use a link twice; use an expired link.
  • Request several links quickly and confirm only the newest works.
  • Check the reset page's response headers for the referrer policy.
  • Ask a colleague to reset their password on a phone without guidance, and watch where they hesitate.

A note on support

Some users will still get stuck: the email went to an old address, or the link was opened on a different device. Decide in advance how support verifies identity before helping, and make sure support staff can resend a link but never see or set a password themselves.

FAQ

Should we tell users their email isn't registered?

Not on the reset form. A neutral message protects your users from having their accounts revealed. Offer clear help options instead.

Are security questions a good idea?

They're weak on their own, because answers are often guessable or findable. OWASP discusses them only as an additional step.

Should the reset link log people in?

OWASP recommends against automatic login after reset; have users sign in normally.

What about SMS codes?

OWASP covers PINs sent by SMS as an alternative to email links, with the same principles of randomness, expiry and single use.

If you're not sure how your app's forgot-password feature behaves, ask us to review the flow and we'll test it against these steps.

Sources

WhatsAppLet’s talk