OOmnistu

Blog / Engineering Playbooks

Engineering Playbooks

Forgot-password security: design the whole reset flow

Review reset requests, single-use links, abuse controls, session invalidation and compromised-account recovery as separate security decisions.

OOmnistu
Reviewed 2026-11-16 · 4 min read

A password-reset flow must verify the right person's access, resist automated abuse and avoid leaving an attacker signed in after recovery. Sending an email with a link is only one part of that job.

The OWASP Forgot Password Cheat Sheet separates the request step from setting the new password. It also warns that recovering a potentially compromised account needs more than replacing a password. Use that distinction when reviewing a product's reset design.

Stage 1: accept the request without revealing account existence

A reset form should return a consistent message for existing and non-existing accounts. An illustrative message is: "If an account matches those details, we will send reset instructions."

The wording is not enough if the response time reliably reveals which accounts exist. OWASP recommends consistent timing behaviour, for example through asynchronous processing or consistent logic paths rather than an obvious early return for an unknown account.

Do not change or lock the account merely because someone requested a reset. Otherwise, an attacker who knows an email address could disrupt the legitimate owner's access without proving anything.

Stage 2: control both request abuse and token guessing

There are at least two different abuse cases:

Abuse case What the attacker is trying to do Review focus
Repeated reset submissions Flood a person's email or phone Request controls, including per-account protections
Repeated token attempts Guess a valid recovery secret Token strength, expiry and verification limits

A control addressing one does not necessarily solve the other. OWASP discusses rate limits, CAPTCHA or other protections for automated submissions, and separate protection against brute-forcing tokens.

The right values depend on the service. This article does not prescribe a universal request limit or expiry period. Record the chosen policy, why it fits the risk, and how legitimate users recover when a limit affects them.

Stage 3: make the reset link trustworthy

For a URL-token design, OWASP recommends a cryptographically secure random token that is sufficiently strong, securely stored, linked to the right user, single-use and time-limited.

Build the reset URL from a trusted configured origin or a validated list of trusted domains. Do not derive its destination blindly from an incoming Host header. Use HTTPS, and prevent referrer leakage from the reset page as described in the cheat sheet.

The link's possession should only enable the intended recovery operation. If a design exchanges a code for a temporary session, keep that session restricted to resetting the password rather than treating it as an ordinary fully authenticated session.

Do not copy real reset URLs into issue trackers or public screenshots. Test with dedicated accounts and non-production recovery messages.

Stage 4: set the new password consistently

The reset path should apply the same password policy as the rest of the application and store the new password using an appropriate password-hashing design.

OWASP recommends confirming the new password, notifying the user that it was reset without emailing the password, and having the user sign in through the usual mechanism rather than automatically signing them in. The cheat sheet also calls for offering to invalidate existing sessions or invalidating them automatically.

Make that session decision explicit. A successful password update does not, by itself, prove that every previously issued session has ended.

Suspected compromise is a different recovery case

If an attacker may have changed recovery details or MFA methods, sending instructions only to the newly configured address can return control to the attacker. OWASP recommends not relying solely on recently changed recovery information, and instead using independent, previously established evidence appropriate to the account's assurance needs.

A recovery process should review recovery addresses, phone numbers and authentication methods with the verified owner. It should not automatically restore an older address either: that address may have been replaced because it was compromised or lost.

After successful compromised-account recovery, OWASP calls for invalidating existing sessions and outstanding reset or recovery links and codes, handling compromised authenticators, and sending appropriate notifications through safe established channels.

This is not a complete identity-proofing or MFA-recovery procedure. Those need their own design and source review, especially for higher-risk or regulated services.

Test outcomes, not only the happy path

Our suggested authorized test plan includes:

  1. Request a reset for a known test account and an unknown address; compare messages and timing behaviour.
  2. Try an expired token and a token that has already been used.
  3. Check that requesting a reset does not lock the account or change the password.
  4. Verify that the link points to the intended domain regardless of untrusted request inputs.
  5. Reset the password and check the intended treatment of old sessions.
  6. Confirm that notifications contain no password or reusable recovery secret.
  7. Exercise a separate suspected-compromise scenario with documented expected outcomes.

A few passing tests are not proof of security. They make the review concrete and expose the assumptions hidden behind "forgot password works."

By Omnistu. Reviewed against OWASP guidance on 16 November 2026. This is educational design guidance, not an audit or a complete account-recovery standard.

Sources

Previous
Letting users upload files safely: a checklist for app teams