Improper Restriction of Excessive Authentication Attempts The advisory has been revoked - it doesn't affect any version of package devise-two-factor  (opens in a new tab)


Threat Intelligence

EPSS
0.04% (12th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Improper Restriction of Excessive Authentication Attempts vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-RUBY-DEVISETWOFACTOR-6153866
  • published12 Jan 2024
  • disclosed11 Jan 2024
  • creditChristian Reitter, Chris MacNaughton

Introduced: 11 Jan 2024

CVE-2024-0227  (opens in a new tab)
CWE-307  (opens in a new tab)

How to fix?

There is no fixed version for devise-two-factor.

Amendment

This was deemed not a vulnerability.

Overview

Affected versions of this package are vulnerable to Improper Restriction of Excessive Authentication Attempts due to the lack of an account lockout mechanism. When combined with the Time-based One Time Password algorithm's (TOTP) inherent entropy limitations, an attacker can bypass the two-factor authentication protection by performing a brute-force attack.

Notes:

The attacker needs access to a user's username and password to exploit this vulnerability.

The user under attack would not necessarily know that their account has been compromised.

The maintainers will not release any fixes for this vulnerability. This library is open-ended by design and cannot solve this for all applications natively. It's recommended that any application leveraging Devise-Two-Factor implement controls at the application level to mitigate this threat.

Workaround

  1. Use the lockable strategy from Devise to lock a user after a certain number of failed login attempts. See https://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Lockable for more information.

  2. Configure a rate limit for your application, especially on the endpoints used to log in. One such library to accomplish this is rack-attack.

  3. When displaying authentication errors hide whether validating a username/password combination failed or a two-factor code failed behind a more generic error message.

Note: The CVE for this issue has been withdrawn and the project maintainers have clarified the expected behavior of the package and the ways to use it securely, given the attack vector described here.

References