Recovery Codes - Backup Access for MFA
About 2 min read
A recovery code (also called a backup code) is a backup authentication method for regaining access to an account when the device used for multi-factor authentication (MFA) is lost or fails. It is typically a set of single-use codes issued during MFA setup, and each code can be used only once. Because a broken smartphone or a lost security key can happen to anyone, storing recovery codes in advance is one safeguard in MFA operations.
Common Format and Mechanism
The format of recovery codes varies by service. For example, Google and Dropbox issue a set of ten 8-digit codes, while GitHub issues a set of 16 codes.
Example recovery codes (fictitious):
Each code is invalidated after a single use. If all codes are used up, regeneration is required.
NIST SP 800-63B requires the service to store recovery codes in hashed form. When a user enters a code, the service authenticates it by comparing the hash values. Used codes are invalidated immediately and cannot be reused.
Safe Storage Methods
If you store them in the wrong place, the recovery codes themselves become an entry point for attacks.
Store them in the secure notes feature of a password manager. They are kept in encrypted form and can be synced across devices.
Print them and store them in a safe or a locked drawer. They are hard to steal over a network. However, since there is a risk of fire or loss, it is advisable to store copies in multiple locations.
Saving them in your smartphone's camera roll or a note app is dangerous. They could be unintentionally exposed externally through cloud sync, or stolen by malware.
The Risk of Recovery Codes Themselves Becoming an Attack Target
Because a password plus a recovery code alone grants access to an account, recovery codes are targeted by attackers as a "back door" that bypasses MFA. Account takeover techniques include extracting recovery codes through social engineering and stealing an entire password manager database with malware.
As a countermeasure, apply strong protection to the storage location of the recovery codes itself. If you store them in a password manager, make the master password sufficiently strong and also set up MFA on the password manager itself. If you print them on paper, thoroughly enforce physical access control (safes, locks).
Recovery Flow
Recovery Design in the Passkey Era
With the spread of passkeys, the approach to recovery is also changing. Because synced passkeys can be used across devices through iCloud Keychain or Google Password Manager, the risk of losing access to an account due to the loss of a single device has been reduced. However, when recovery of an Apple ID or Google account itself becomes necessary, conventional means such as recovery codes are used.
In corporate environments, one option is a multi-layered design: in addition to passkeys, register a backup security key, and have IT administrators securely store the recovery codes. The security key deployment guide and what happens when your account is hacked are also helpful references for recovery design.
They Cannot Be Obtained After You Need Them
Recovery codes can only be issued from a screen that requires being logged in to the account. In other words, they can be obtained only in normal times; once an authentication factor has been lost, no route to obtaining them remains. Events that take away a second factor (a device breaking or being lost, or a migration being missed when changing phones) happen without warning, so whether the codes were issued and stored in advance directly determines whether recovery is possible on one's own. Without them, the alternative route is the identity verification procedure of each service. That means submitting identification documents or answering inquiries, the review takes time, and if the materials for identity verification cannot be assembled in the first place, recovery may not be possible at all. The value of recovery codes lies in being able to replace that uncertain, time-consuming route with one that can be completed using only information already in one's own hands.
The basics of two-factor authentication also explains the steps for setting up recovery codes.
Was this article helpful?
Related Terms
- Backups - Protecting Data with CopiesA backup stores a copy of data in a separate location. The 3-2-1 rule is the recommended strategy, and offline backups are increasingly important as a defense against ransomware.
- How Password Managers Keep Your Accounts SafePassword managers generate, encrypt, and auto-fill unique credentials for every login. Learn how an encrypted vault simplifies security across all devices.
- Dark Patterns - Deceptive UI Design TricksDark patterns are deceptive UI designs that nudge users into unintended actions, from hard-to-cancel subscriptions to manipulative cookie consent banners that undermine privacy and security settings.
- Passkey Sync - Cross-Device Credential SharingWhat is passkey sync, and does it work between Apple and Google devices? How iCloud Keychain and Google Password Manager replicate FIDO2 credentials across your devices, and where cross-platform sync still falls short.