CVE-2019-5421: Devise Devise Time-of-check Time-of-use Race Condition Vulnerability

MODERATE
Advisory Identifier: GHSA-73rf-6mrf-759q
CWE-367
Published
Advisory Summary

CVE-2019-5421 is a MODERATE devise time-of-check time-of-use race condition vulnerability (CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition) affecting Devise libraries in the RubyGems ecosystem. The issue involves devise time-of-check time-of-use race condition vulnerability. Remediation is available by upgrading affected packages to version 4.6.0.

CVE-2019-5421 at a Glance

CVE Identifier CVE-2019-5421
GHSA Identifier GHSA-73rf-6mrf-759q
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition
Affected Product Devise
Package Ecosystem RubyGems
Published Date
Last Updated

How to Fix CVE-2019-5421

To remediate this vulnerability, upgrade all affected Devise dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

devise fixed: 4.6.0
Upgrade devise to 4.6.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for devise

How to Check if You Are Affected

To determine whether your application is affected by CVE-2019-5421, inspect your project dependencies for Devise:

inspect dependencies for devise

Analyze the terminal output to locate any version of Devise in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.6.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition, where the product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check. In Devise, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Devise ruby gem before 4.6.0 when the `lockable` module is used is vulnerable to a time-of-check time-of-use (TOCTOU) race condition due to `increment_failed_attempts` within the `Devise::Models::Lockable` class not being concurrency safe.

CVE-2019-5421 Affected Devise Versions

1 component(s)
Fixed Versions:
4.6.0
Product / Package Ecosystem Affected Versions Fixed Version
devise
RubyGems
< 4.6.0
4.6.0

References

Frequently Asked Questions

What is CVE-2019-5421?
CVE-2019-5421 is a security vulnerability in Devise involving devise Time-of-check Time-of-use Race Condition vulnerability under CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition.
Which Devise versions are affected?
Affected versions include releases prior to 4.6.0 across affected packages: devise.
What version fixes CVE-2019-5421?
Upgrading to 4.6.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is devise affected?
Yes, devise is affected in releases prior to 4.6.0. Upgrade your dependency to 4.6.0 or later.
What CWE is associated with CVE-2019-5421?
CVE-2019-5421 is classified under CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition (The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.).
How can I check RubyGems dependencies for CVE-2019-5421?
Run the dependency tree command: 'inspect dependencies for devise'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-73rf-6mrf-759q",
  "modified" : "2023-01-23T20:46:50Z",
  "published" : "2019-03-19T18:03:25Z",
  "aliases" : [ "CVE-2019-5421" ],
  "summary" : "devise Time-of-check Time-of-use Race Condition vulnerability",
  "details" : "Devise ruby gem before 4.6.0 when the `lockable` module is used is vulnerable to a time-of-check time-of-use (TOCTOU) race condition due to `increment_failed_attempts` within the `Devise::Models::Lockable` class not being concurrency safe.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "devise"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.6.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-5421"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/plataformatec/devise/issues/4981"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/plataformatec/devise/pull/4996"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/plataformatec/devise"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-367" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-06-16T21:21:17Z",
    "nvd_published_at" : null
  }
}