How Unlimited Backup Code Generation Can Break Account Security
Backup codes for two-factor authentication were generated from a small character set and could be regenerated without limit, so an attacker with their own account could collect nearly every possible code. The text claims this could let an attacker bypass 2FA and take over accounts, though it does not show the final step of matching codes to real users.
medium.com
Published on medium.com
Backup codes are commonly used as a recovery mechanism for accounts protected by Two-Factor Authentication (2FA). When a user loses access to their primary authentication method (e.g., phone or authenticator app), they can fall back to these codes to regain access.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the backup codes were drawn from a small character set and could be regenerated without any limit, so the whole set of possible codes could be collected.
Impact
The text claims this could bypass 2FA and lead to account takeover, but it does not demonstrate the final step of linking collected codes to real accounts, so the takeover is asserted rather than shown.
What the attacker needed
Attacker has their own account; 2FA enabled on the target account
The fix
Generation should be limited to a few times, codes should be long and random, requests should be rate limited, users should be notified, and old codes should be invalidated when new ones are issued.
How it was found
- Sign up for an account and enable two-factor authentication.
- Request backup codes.
- Keep regenerating backup codes until nearly the whole code space is collected.
- Use the collected codes as a dictionary to match against real user accounts.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Two-factor authentication asks for a second proof, such as a code from a phone app, when you log in. Backup codes are spare one-time codes you can use if you lose that phone. Here the spare codes were short and could be requested again and again, so someone could gather almost every possible code in advance and later guess their way past the second step.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.