Password Reset Security Testing: Tokens and Sessions

Password Reset Security Testing: Tokens and Sessions
To test password reset security in a SaaS application, write down the policy you expect, run bounded checks against fake accounts on staging, and verify the resulting account state (token status, stored credentials, live sessions) rather than the HTTP status code of each request. A 200 OK on a reset confirmation tells you the server answered. It does not tell you the token is now dead, the old sessions are gone, or the account owner was told.
That gap separates a reset flow that looks fine in a browser from one that survives an account takeover attempt. This guide covers how to set up the test safely, which properties to check (token ownership, expiry, one-use, concurrent redemption, request-side leaks, post-reset state), and how routine reset differs from recovery after suspected compromise and from MFA recovery. It uses the OWASP Forgot Password Cheat Sheet as its baseline and stays on harmless, authorised checks. No payloads, no attack tutorial.
Write the expected reset policy before you test anything
Start with a written policy. A test with no expected result can only ever pass. One page is enough, and it should answer a short list of questions in plain engineering terms.
How are reset tokens generated, and how long are they? OWASP expects a cryptographically secure generator, tokens long enough to resist guessing, secure storage, single use and an appropriate expiry (OWASP Forgot Password Cheat Sheet). What is your expiry in minutes? What happens to an unused token when the user requests a second one? What happens to existing sessions when a reset completes? Who gets notified, and through which channel?
Be explicit about what is out of scope for a reset. A reset doesn't have to revoke every independent credential. An API key, an OAuth refresh token or a hardware-bound passkey may have its own lifecycle, and your policy should say so on purpose, not by accident. The tester and the owner need to agree on the intended outcome before the first request.
If you want a second reference for numbers, NIST SP 800-63B-4 sets expiry limits for issued recovery codes: 10 minutes for text or voice, 24 hours for email, 21 days for U.S. postal delivery, and 30 days outside the contiguous United States. It also requires a notification to the subscriber when recovery happens. Use it to sanity-check your own limits, then write down yours.
Set up a safe test: staging, fake accounts, bounded checks
Run every check on a staging environment with accounts you created for the purpose. Never test against production users, and never against a mailbox you don't own.
Create at least three fake accounts. Account A is the subject. Account B is a second tenant or user, used to check that tokens don't cross account boundaries. Account C is an admin or privileged user, used to check recovery paths. Give each a mailbox you control, ideally a catch-all inbox on a test domain, so you can read delivered links without touching real mail.
Bound the checks. Agree a request budget, a time window and an owner who knows the testing is happening, so rate limiting and alerting don't page the wrong people. Keep checks to single, harmless actions: request a reset, redeem a token, redeem it again, request two and redeem both. Don't brute-force token space. If you want to know whether guessing is feasible, review how tokens are generated and measure their length and entropy in the code instead of hammering the endpoint.
Write down the observable state you will inspect after each step. That means the token row in the database (or its status in whatever store you use), the credential hash and its changed-at time, the session table, and the outbound email log. If you can't read those on staging, ask for read-only access first. Without it you are testing status codes, and status codes are the weakest evidence in this flow.
Token ownership and account binding: whose reset is this?
A reset token must be bound to exactly one account, and the server must check that binding at redemption, not just that the token exists.
Test it with two accounts. Request a reset for account A and capture the token from A's mailbox. Then try to redeem it while supplying account B's identifier wherever the flow accepts one: a hidden user_id field, an email parameter, a path segment. The expected result is rejection, and the expected state is that B's credentials are unchanged and A's token status is whatever your policy says for a failed redemption. If the new password lands on B, you have an account-binding flaw. It's the kind that turns a self-service feature into account takeover.
Check the same thing across tenants in a multi-tenant product. A token issued in tenant one shouldn't be redeemable against a same-email account in tenant two. This overlaps with the boundary checks in tenant isolation testing, and the same question applies: does the server derive identity from the token, or trust what the client sends?
Also look at what the token proves. The OWASP guidance says that once a user proves identity with a token or code, they should be able to reset the password. It does not say the token should log them in or reveal account details. A reset page that echoes the account's email, name or tenant before the new password is set leaks more than it needs to. Inspect the page the link opens, not just the final submit.
Expiry, one-use enforcement and concurrent redemption
Token lifetime and single use are the two properties teams most often believe they have and haven't verified.
For expiry, request a token, wait past your stated limit (shorten the limit on staging if you can, or move the token's expiry timestamp in the test database) and attempt redemption. Expected result: rejection, and no change to the credential. Check the token status afterwards. Some implementations reject the request but leave the token usable on the next attempt because of a clock or caching quirk.
For one-use, redeem a valid token, then redeem it again with a different new password. The second attempt must fail, and the password must stay the one set by the first. Then check the stored state: is the token marked used or deleted, or is it merely unlikely to be replayed? OWASP says to invalidate used reset tokens (OWASP Forgot Password Cheat Sheet). Also check that requesting a new token invalidates the previous outstanding one, or that your policy says plainly that several can coexist.
Concurrent redemption is the subtle one. Send two redemption requests for the same token at nearly the same moment, using two different new passwords. If the check-then-update isn't atomic, both can succeed, and you end up not knowing which password is live. Keep this to two requests on a fake account. The state check is what matters: exactly one redemption should win, and the token should end up consumed once. The same read-modify-write pattern shows up in race condition testing for payment workflows, and the fix is usually the same: a single atomic compare-and-set on token status.
Reset links, enumeration and delivery: what the request side leaks
The request side of a reset, before any token exists, can leak account existence and, worse, hand an attacker control of the link that gets emailed.
Start with enumeration. Submit a reset request for a registered fake address and for an address that doesn't exist. The response body, status code, headers and timing should be indistinguishable, with a generic message such as "if an account exists, we have sent an email". Differences in wording, redirect target or response time all count. Keep it to a handful of requests per case. You are looking for a consistent difference, not volume.
Next, the reset link itself. This is the password reset poisoning check, often called host header injection. The question is where the application gets the hostname it puts in the emailed link. OWASP says to build reset links from a hard-coded URL or by validating the URL against trusted domains, rather than relying on the request's Host header. On staging, send a reset request for a fake account with a Host or X-Forwarded-Host value pointing at a domain you control (a test domain you own, receiving nothing sensitive), then read the delivered email. If the link now carries your hostname, the application trusts the request for its own address. In a real attack the victim clicks a link to the attacker's server and hands over the token. The expected result is a link on your canonical domain regardless of what the request claimed.
Check the other delivery details too. Does the token travel in the URL query string, and does the reset page load third-party scripts or resources that could leak it through the Referer header? Is the email sent only to the address on file, with no way to add a second recipient through a parameter? Does the flow avoid security questions as the sole mechanism? OWASP warns that answers are frequently guessable or obtainable. Finally, check that repeated requests don't lock the real user out. OWASP advises against locking accounts in response to forgotten-password attempts, since that becomes a denial-of-service lever against known usernames.
What a completed reset should change: sessions, credentials and notifications
A completed reset should change the account's state in four places, and each one needs its own check. This is where HTTP status misleads most.
Sessions. Sign in on account A from two browser profiles, so you hold two live sessions. Complete a reset using a valid token. Now use each old session to make an authenticated request. OWASP says to offer to invalidate existing sessions, or do so automatically, so your written policy should pick one. If the policy is automatic invalidation and the old sessions still work, that's a real finding: an attacker who already had a session survives the victim's attempt to recover the account.
Credentials. Confirm the password hash changed and its changed-at timestamp moved. Confirm the old password no longer works and the new one does. Confirm the new password goes through your normal password rules, including any blocklist check, and not a weaker path. A reset form that skips the checks your signup form enforces is a common gap.
Outstanding tokens. Any other unredeemed reset tokens for that account should be dead after a successful reset. Check the token table, not the UI.
Notifications. The account owner should receive a message after the reset completes, to an address that the reset itself couldn't have changed. NIST SP 800-63B-4 requires notification to the subscriber on recovery. Check that the email exists, that it doesn't contain the new password or a live token, and that it gives the owner something to do if they didn't initiate it.
A reset doesn't have to revoke every independent credential. If your policy keeps long-lived API keys or OAuth grants alive across a password reset, that may be a defensible decision, but write it down and review it against your threat model. The OAuth security testing guide covers the token boundaries that sit next to this one.
Routine reset vs recovery after suspected compromise vs MFA recovery
These are three different flows with different risk, and testing them as one produces a policy that fits none of them.
Routine forgotten-password reset: the user lost a password and the account is otherwise believed safe. The checks above apply. A token proves control of the mailbox, the user sets a new password, and sessions are revoked per policy.
Recovery after suspected compromise: OWASP is explicit that a password reset alone may not restore control of a compromised account. If an attacker has been in the account, they may hold sessions, API keys, OAuth grants, recovery email changes, forwarding rules or added MFA devices. Test the compromise path as its own scenario. Mark account A as suspected-compromised in staging, run recovery, and verify that all sessions are invalidated, outstanding recovery links and codes are revoked, and the account's recovery email, phone and MFA enrolments are surfaced for the owner to review and not silently kept. The policy should also say whether a password change is forced on next sign-in.
MFA recovery: this is a separate flow from password reset and usually the weaker one. If a password reset can also disable or bypass MFA, mailbox control becomes the only factor, and the second factor is decoration. Test it directly. Complete a password reset on an MFA-enrolled fake account and confirm the next sign-in still demands the second factor. Then test the lost-device path: what does it require, how long does it take, who is notified, and can it be started by someone holding only the reset email? For AAL2 accounts, NIST SP 800-63B-4 requires recovery to use two recovery codes obtained through different methods, one recovery code plus authentication with a bound single-factor authenticator, or repeated identity proofing if the subscriber account was identity-proofed. If your MFA recovery is easier to pass than the login it replaces, it's broken.
Keep three rows in your test plan, one per flow, with separate expected outcomes. The most common failure is a single code path serving all three.
Turn the checks into regression tests and findings you can verify
A manual pass finds today's bugs. Regression tests keep them from returning when someone refactors the auth module in six months.
Turn each property into an assertion on state. A minimal suite covers: token bound to one account; expired token rejected and credential unchanged; used token can't be replayed; second request invalidates the first (or coexistence is asserted deliberately); two simultaneous redemptions yield exactly one success; emailed link host equals the configured canonical host under a spoofed Host header; old sessions rejected after reset; MFA still required after reset; notification email sent. Each asserts on the database or session store, not on the status code alone. The approach matches what we describe in security regression testing for authorisation fixes: a fix is only done when a test that failed before now passes, for the right reason.
Write findings so another engineer can reproduce them. State the account setup, the exact sequence, the expected state from your policy, the observed state, and the consequence in ordinary terms ("a session opened before the reset still reads the account after the password changed"). Where you can, record how the issue was established. A finding you reproduced end to end is stronger than one inferred from reading code, and reviewers should be able to tell which is which. See verified security findings for how to separate proof from inference.
Run the suite on every change that touches authentication, session handling or the mailer. Those are the diffs where reset behaviour quietly changes.
Test the state a reset leaves behind, not the page it returns
Password reset fails in the gaps between what the response said and what the account now looks like: a token that still works, a session that survived, an emailed link built from an attacker's header, an MFA step that a reset quietly skipped. Write the policy, test the state, and keep the checks as regressions.
If you want an independent pass over your reset and recovery flows, with findings confirmed against the running application and retested after the fix, Borg can run that for your team. Book a walkthrough at borghq.io.
Frequently asked questions
- How do you test password reset security in a SaaS application?
- Write the expected policy first, then use fake accounts on staging. Check that tokens are bound to one account, expire, work once, and survive no concurrent double redemption. Check the emailed link ignores a spoofed `Host` header. After a reset, inspect state: old sessions revoked, outstanding tokens dead, credential changed, owner notified. Do not rely on HTTP status codes.
- How do you test for password reset poisoning and host header injection?
- On staging, request a reset for a fake account while sending a `Host` or `X-Forwarded-Host` value pointing at a test domain you own. Then read the delivered email. If the link uses your supplied hostname, the application builds links from the request. Links should come from a hard-coded URL or domain allowlist, as OWASP advises.
- What should a password reset token checklist cover?
- Check generation (cryptographically secure, long enough), account binding, a stated expiry, single use, invalidation of older tokens on a new request, and atomic handling of two simultaneous redemptions. Verify each by inspecting token status and the credential afterwards. OWASP's Forgot Password Cheat Sheet is the usual baseline for these properties.
- Should a password reset log the user out of every session?
- OWASP says to offer to invalidate existing sessions, or do so automatically, and after suspected compromise to invalidate sessions and outstanding recovery links. Decide which applies in your written policy, then test it by holding an old session open through a reset. Independent credentials such as API keys may follow a separate lifecycle if you choose that deliberately.
- Is password reset the same as MFA recovery?
- No. A password reset proves mailbox control and sets a new password. MFA recovery replaces a lost second factor and is higher risk. Test that a completed password reset still requires MFA at next sign-in, and that the lost-device path is not easier to pass than the login it replaces.



