Account recovery and password reset
How a service lets someone back in when they can't sign in: reset tokens, recovery codes and repeated identity proofing, and what each step does to sessions, outstanding links and notifications so an intruder's old access is pushed out.
What it is
Two situations look alike from the login page and call for different designs. In the first, the user forgot the password but still holds another way to sign in, say an authenticator app or a passkey. NIST SP 800-63B-4 treats replacing the password in that case as binding a new authenticator, done inside an authenticated session, not as account recovery. In the second, the user has lost control of the authenticators needed to reach the account's assurance level, and the service falls back on evidence arranged earlier: a saved recovery code, a code sent to a registered address, a recovery contact, or a repeat of part of the identity-proofing process. Once one of those succeeds the user binds fresh authenticators, and a notification goes out so a fraudulent recovery can be noticed. Recovery is expected to be rare, so it's allowed to be slower and less convenient than a normal login.
One path is a link sent by email, which the OWASP forgot-password guidance describes as the simplest and fastest to build. The request step is where account enumeration leaks: the service should answer with the same message, in about the same time, whether or not the address belongs to an account, and should throttle requests per account so an attacker can't flood someone's inbox with reset mail. Nothing about the account changes at this point. Locking it on a request, for example, would let anyone deny a user access by typing their address.
The token itself is a short-lived credential and is handled like one: generated from a cryptographically secure random source, long enough that guessing it within its lifetime is impractical, linked to a single user, stored securely under the same storage guidance as passwords (our design hashes it), invalidated the first time it's used, and expired after a set period. Build the link from a configured host rather than the request's Host header, serve the reset page with Referrer-Policy: no-referrer so the token doesn't leak to third parties, and rate-limit attempts to present a token. Once the token is accepted the user sets a new password under the normal policy, gets an email saying it was changed, and then signs in through the usual login rather than being signed in from the reset page, which keeps the session code on one path.
| Code | Minimum randomness | Longest validity | After use |
|---|---|---|---|
Saved recovery code, handed out at enrollment and kept offline | 64 bits from an approved random generator | No validity period is set; the user may request a replacement at any time | Invalidated; a new one is issued |
Code sent by text message or voice call | 6 decimal digits or equivalent | 10 minutes | Single use; attempts are throttled |
Code sent by email | 6 decimal digits or equivalent | 24 hours | Single use; attempts are throttled |
Code sent by post, contiguous United States | 6 decimal digits or equivalent | 21 days | Single use |
Code sent by post, elsewhere | 6 decimal digits or equivalent | 30 days | Single use |
Code sent to a recovery contact (a trusted person) | As for an issued code | The channel's limit, extendable by 24 hours | Single use |
Those limits apply to issued and saved recovery codes. A new recovery address has to be confirmed with a code of the same kind before it counts, a user should be able to register at least two of them, and saved codes are stored hashed with an approved one-way function, like passwords.
A new password doesn't on its own recover an account that someone else has been inside. The intruder may hold a live session and may have swapped in their own email address, phone number or second factor. For a suspected takeover: weigh recovery evidence that was in place before the incident (a saved code, an address verified long ago) above anything added recently; don't automatically reinstate an address that was replaced, since the owner may have replaced it because it was lost; once the owner is back in, invalidate existing sessions and any reset or recovery links still outstanding; review recovery addresses and MFA methods with the owner and remove changes they didn't make; and notify all registered addresses that are still safe, with instructions for reporting a recovery the owner didn't perform.
How much evidence recovery needs. SP 800-63B-4 sets the requirement along two separate axes. The authentication assurance level (AAL) describes how strong the login is: AAL1 requires no more than one factor (offering a second is recommended), AAL2 needs two distinct factors and must offer a phishing-resistant option, and AAL3 rests on proof of possession of a key through a public-key protocol. The identity assurance level (IAL) records whether, and at what level, the account was identity-proofed when it was opened; what proofing at each level involves is set in the companion volume on identity proofing. An account can be strong on one axis and weak on the other, so the recovery rule is read off both.
| Account | What recovery requires |
|---|---|
Not identity-proofed, at any AAL | A saved recovery code, an issued recovery code or a recovery contact. Repeating identity proofing isn't available because there was none to repeat. |
Can authenticate at most at AAL2 | One of: two recovery codes obtained by different methods (saved, issued, recovery contact); one recovery code plus a single-factor authenticator still bound to the account; or repeated identity proofing, if the account was proofed. |
AAL3, proofed at IAL1 or IAL2 | The same as the AAL2 row. |
AAL3, proofed at IAL3 | A biometric comparison against the sample collected at the in-person, attended proofing session. The service may also ask for the evidence used then. |
Any of the above | A notification to the registered addresses in each case. |
When to use it
Use the light path, a password change behind an authenticated step, whenever the user still has a working authenticator. The rule for binding a new authenticator asks for authentication at the account's current maximum AAL or the level the new authenticator will be used at, whichever is lower, plus a notification sent independently of that transaction. Use the emailed or texted token path when the password is the one factor and the mailbox or phone is the registered address. Our advice: once an account carries a second factor the user can lose, offer saved recovery codes or a recovery contact at enrollment, because proving control of a mailbox is weaker evidence than the second factor it would be replacing, and the AAL2 rule above asks for two independent pieces unless the account was identity-proofed and can repeat that instead.
When not to
Ending other sessions is a choice in the ordinary reset, not a fixed rule. The OWASP guidance is to either invalidate the user's other sessions automatically or ask the user whether to. Asking suits someone who changed a password they simply forgot and is signed in on devices they trust; losing those sessions is a cost with no intruder to remove. The exception is suspected compromise, where existing sessions and outstanding links are invalidated as part of recovery rather than offered as a choice.
Don't lock an account because a reset was requested; wait until a valid token is presented before changing anything. Don't sign the user in from the token. Don't make security questions the sole gate; they can add a layer on top of a token but their answers are too often guessable or discoverable. And don't push a user who still holds a passkey or authenticator app through codes and waiting periods meant for someone who has lost everything: the heavier path exists for the rare case, and the lighter authenticated change is the right tool when a factor remains.
Compared
| Method | What it proves | Choose it when | Weak spot |
|---|---|---|---|
Emailed link (URL token) | Control of the registered mailbox | The password is the one factor and the mailbox is the registered address; the simplest and fastest to build | A compromised mailbox, or an intruder who already changed the address |
Texted or voice code (6 to 12 digits) | Control of the phone number | A second channel is wanted, or the user has no reliable email | Short code, so it needs a 10-minute life and throttling; phone numbers can be taken over |
Saved recovery code | The user kept an offline secret from enrollment | Accounts with a second factor that can be lost; counts as evidence independent of any address | Users misplace them; a new one must be issued after each use |
Recovery contact | A trusted person received and passed on a code | Users with no second address of their own; the extra 24 hours gives the contact time | Slower, and depends on the contact being reachable and careful |
Repeated identity proofing | The person matches the evidence or biometric captured at enrollment | Identity-proofed accounts; the required path for AAL3 accounts proofed at IAL3 | Costly and slow; unavailable for accounts that weren't proofed |
Security questions | Knowledge of personal facts | As an extra check layered on a token, where no better second check exists | Too guessable to stand on their own |
Support agent | Whatever the agent is trained to check | The last resort so a user has a way back in, under a documented risk analysis | Social engineering of staff; cost |
In a picture
Step 1 of 4
The request
The user types an address. The service creates a random token, stores it securely (hashed, in this design) linked to the user with an expiry, and emails the link. The reply is the same whether or not the address matched an account.