# CVE-2019-5421: devise Time-of-check Time-of-use Race Condition vulnerability

> A race condition in the Devise lockable module allows attackers to bypass brute-force protection mechanisms by sending concurrent requests.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 3 Apr 2019
- **Updated:** 4 Aug 2024
- **Also known as:** DEBIAN-CVE-2019-5421, GHSA-73rf-6mrf-759q, UBUNTU-CVE-2019-5421

## What is CVE-2019-5421?

CVE-2019-5421 is a critical vulnerability in Plataformatec Devise ruby gem, published on 3 Apr 2019. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Plataformatec Devise version 4.5.0 and earlier, using the lockable module contains a CWE-367 vulnerability in The `Devise::Models::Lockable` class, more specifically at the `#increment_failed_attempts` method. File location: lib/devise/models/lockable.rb that can result in Multiple concurrent requests can prevent an attacker from being blocked on brute force attacks. This attack appear to be exploitable via Network connectivity - brute force attacks. This vulnerability appears to have been fixed in 4.6.0 and later.

Weakness: CWE-307 (Improper Restriction of Excessive Authentication Attempts), CWE-367 (Time-of-check Time-of-use (TOCTOU) Race Condition)

## Which versions are affected by CVE-2019-5421?

2 open source packages ship an affected version, including devise. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `devise` | RubyGems | All versions | 4.6.0 |
| `devise` | RubyGems | All versions | 4.6.0 |

Products: Plataformatec Devise.

## How do I fix CVE-2019-5421?

Upgrade devise to 4.6.0 or later.

## Is CVE-2019-5421 being exploited?

There is no known exploitation of CVE-2019-5421 in the wild and no public exploit code.

## Other vulnerabilities in Plataformatec Devise ruby gem

- [CVE-2019-16109](https://insights.sbomify.com/CVE-2019-16109/): Authentication Bypass in Devise (medium 5.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2019-5421 and fix it if it is affected.

What it is: CVE-2019-5421 is a critical vulnerability in Plataformatec Devise ruby gem, published on 3 Apr 2019. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2019-5421 in the wild and no public exploit code.

Affected packages and fixed versions:
- devise (RubyGems): affected all versions; fixed in 4.6.0
- devise (RubyGems): affected all versions; fixed in 4.6.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2019-5421/ (Markdown: https://insights.sbomify.com/CVE-2019-5421/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2019-5421
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2019-5421
- OSV: https://osv.dev/vulnerability/CVE-2019-5421

---
From sbomify Insights: https://insights.sbomify.com/CVE-2019-5421/
Summaries are generated and may contain mistakes; the official description above is the record.
