2FA Recovery Code login doesn't have lockout
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is your feature request related to a problem? Please describe.
I've noticed that the default 2FA implementation for Identity has lockout implementation for using an authentication code, but _not_ for using a 2FA recovery key inside `TwoFactorRecoveryCodeSignInAsync()`. And neither does this function check for lockouts.
Is this intentional? Wouldn't this effectively expose any user to brute-force attacks against their recovery codes (as at this point the username and password are known, so lockout isn't incremented for login attempts).
In addition, I've noticed that the comment for lockouts on Login.cshtml.cs is as follows:
```cs
// To enable password failures to trigger account lockout, set lockoutOnFailure: true
```
Wouldn't it make more sense to advise it to be set as `lockoutOnFailure: !await _userManager.GetLockoutEnabledAsync(user)` in order to avoid DOS attacks on accounts with authenticators, and use the lockout on the authentication code? I'm not entirely sure about this point so some additional insight would be welcome.
### Describe the solution you'd like
Call `UserManager.AccessFailedAsync()` on bad 2FA Recovery code in the `SignInManager`.
Contributor guide
Assessment
This issue has not been assessed yet.