Recovery codes need the same revocation path as passwords
Recovery codes are often treated as a backup feature rather than an authentication credential. They are issued when a user enrolls, printed or downloaded once, and then ignored until an account needs help. That makes them an attractive alternate path for an attacker who cannot complete the primary factor. It also makes stale recovery material a problem for the user who is trying to recover.
NIST SP 800-63B treats recovery codes as secrets issued to a subscriber to recover an account when the user can no longer authenticate. The guidance includes requirements for recovery-code generation, validity, and account recovery events. [1] The details vary by assurance level and deployment, but the security model is consistent: a recovery code is an authenticator-like secret and needs lifecycle control.
Store one-way, not as plaintext
Generate recovery codes with a cryptographically secure random source. Store a hash or an encrypted record that the application can verify without exposing the code in a database dump. Show the codes only at issuance, and make clear that the user must store them somewhere separate from the primary device. Avoid putting the codes in an email that remains searchable indefinitely.
Do not allow a recovery code to be reused by default. Mark each code as consumed when it is accepted, and invalidate the whole set if the user completes a new enrollment or if the account is suspected of compromise. The recovery path should require a confirmation step, such as a fresh password entry or a second recovery factor, when the application's risk model calls for it.
Revoke the alternate paths together
When a user resets a password, loses a device, or changes an email address, review the recovery codes and recovery contacts at the same time. A password reset that leaves an old recovery code active has not fully revoked access. The same applies to an old phone number, an obsolete email address, and a shared backup location.
If the application supports multiple recovery methods, require the user to confirm the new method and notify the old contact or device where appropriate. Do not reveal whether an old recovery code is valid to an unauthenticated caller. Use uniform responses and rate limits to reduce enumeration.
Make recovery visible to the user
Show the user when recovery codes were issued, when one was last used, and how many remain. Provide a one-click way to regenerate the set. A regeneration should invalidate the previous set atomically. If the system cannot invalidate the old set immediately, it should warn the user and use a short overlap window with individual code tracking.
The support desk needs a documented recovery procedure that does not rely on a password alone. NIST discusses account recovery as a distinct event and recommends that users maintain separate means of authentication where possible. [2] A help-desk workflow that trusts a caller ID or an email response without a second check creates a social-engineering path around the technical controls.
Rotate the dependent sessions
A successful recovery is a high-risk event. Rotate the session identifier, invalidate active sessions, and notify the user through a channel that was already established. If the account has API tokens, service credentials, or delegated access, provide a way to review and revoke them. Do not silently keep every existing session alive because the user changed only the recovery code.
Record an audit event with the recovery method, the authentication steps completed, the time, the account, and the actions that followed. Do not store the raw recovery code. A useful audit record can distinguish a successful self-service recovery from a support-assisted recovery and can show whether the attacker had to pass an additional challenge.
Test the edge cases
Test a used code, a code from an old set, a code with one character changed, a code entered after the account was locked, and a code submitted from an unrecognized browser. Test a regeneration while another recovery flow is pending. Test a password reset that leaves a recovery code active. The expected behavior should be explicit, logged, and consistent across the web, mobile, and support channels.
Recovery codes are not a reason to weaken the primary login. They are a second way to obtain the same account authority. The organization should know where those secrets are stored, who can reset them, how they are invalidated, and what happens to every other credential after a recovery event.
References
[1] NIST, "SP 800-63B, Digital Identity Guidelines: Authentication and Lifecycle Management." https://pages.nist.gov/800-63-4/sp800-63b.html
[2] NIST, "Authenticator Event Management." https://pages.nist.gov/800-63-4/sp800-63b/events/


