aspnetcore: 2FA Recovery Code login doesn't have lockout

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:

// 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.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 19 (5 by maintainers)

Most upvoted comments

The problem seems to still be present on the method:

TwoFactorRecoveryCodeSignInAsync

Will there be improvements on this? @blowdart