Skip to content

GHSA-73rf-6mrf-759q CVE-2019-5421

devise Time-of-check Time-of-use Race Condition vulnerability

Medium RubyGems
Severity
Medium
The publisher's own rating, not a CVSS score
Exploit chance (EPSS)
1.56%
Chance of exploitation in the next 30 days. Higher than 75.18% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition
Fix
4.6.0
Upgrade devise to this version or later

Description

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.

Affected versions

RubyGems

PackageVulnerableFixed in
devise
< 4.6.0
4.6.0

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

devise RubyGems → 4.6.0

bundler
bundle update devise # Gemfile: gem "devise", ">= 4.6.0"

Weakness

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 to prevent it
  • Implementation: The most basic advice for TOCTOU vulnerabilities is to not perform a check before the use. This does not resolve the underlying issue of the execution of a function on a resource whose state and identity cannot be assured, but it does help to limit the false sense of security given by the check.
  • Implementation: When the file being altered is owned by the current user and group, set the effective gid and uid to that of the current user and group when executing this statement.
  • Architecture and Design: Limit the interleaving of operations on files from multiple processes.
  • Implementation, Architecture and Design: If you cannot perform operations atomically and you must share access to the resource between multiple processes or threads, then try to limit the amount of time (CPU cycles) between the check and use of the resource. This will not fix the problem, but it could make it more difficult for an attack to succeed.
  • Implementation: Recheck the resource after the use call to verify that the action was taken appropriately.
  • Architecture and Design: Ensure that some environmental locking mechanism can be used to protect resources effectively.
  • Implementation: Ensure that locking occurs before the check, as opposed to afterwards, such that the resource, as checked, is the same as it is when in use.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-jp94-3292-c3xv
Devise has an Open Redirect via Unvalidated `request.referrer` in Timeoutable Session Timeout Handler
Medium Also affects devise
GHSA-57hq-95w6-v4fc
Devise has a confirmable "change email" race condition permits user to confirm email they have no access to
Medium Also affects devise
GHSA-746g-3gfp-hfhw
Devise Gem for Ruby Unauthorized Access Using "Remember Me" Cookie
High Also affects devise
GHSA-fcjw-8rhj-gwwc
Authentication Bypass in Devise
Medium Also affects devise
GHSA-jxhw-mg8m-2pj8
Devise does not properly perform type conversion when performing database queries
Medium Also affects devise
GHSA-wfhq-q4j2-c37m
filelock: SoftReadWriteLock follows a lock tree swapped in after its first acquire and writes lock records into directories of the user running the lock
Low Same weakness, CWE-367
GHSA-fq56-3cx3-fjxp
filelock: SoftFileLock stale-lock break removes a live lock file on a reused inode number and admits two holders
Medium Same weakness, CWE-367
GHSA-jqc4-5cvw-7w85
filelock: ReadWriteLock on the hard-link route deletes any directory another user renames onto its .filelock-* link directory name
Medium Same weakness, CWE-367
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor