Ruby/devise/0.8.2
Flexible authentication solution for Rails with Warden
https://rubygems.org/gems/devise
UNKNOWN
12 Security Vulnerabilities
Devise has a confirmable "change email" race condition permits user to confirm email they have no access to
- https://github.com/heartcombo/devise/security/advisories/GHSA-57hq-95w6-v4fc
- https://github.com/heartcombo/devise/issues/5783
- https://github.com/heartcombo/devise/pull/5784
- https://github.com/advisories/GHSA-57hq-95w6-v4fc
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/devise/GHSA-57hq-95w6-v4fc.yml
- https://nvd.nist.gov/vuln/detail/CVE-2026-32700
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/devise/CVE-2026-32700.yml
Impact
A race condition in Devise's Confirmable module allows an attacker to confirm an email address they do not own. This affects any Devise application using the reconfirmable option (the default when using Confirmable with email changes).
By sending two concurrent email change requests, an attacker can desynchronize the confirmation_token and unconfirmed_email fields. The confirmation token is sent to an email the attacker controls, but the unconfirmed_email in the database points to a victim's email address. When the attacker uses the token, the victim's email is confirmed on the attacker's account.
Patches
This is patched in Devise v5.0.3. Users should upgrade as soon as possible.
Workarounds
Applications can override this specific method from Devise models to force unconfirmed_email to be persisted when unchanged: (assuming your model is User)
class User < ApplicationRecord
protected
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
unconfirmed_email_will_change!
super
end
end
Note: Mongoid does not seem to respect that will_change! should force the attribute to be persisted, even if it did not really change, so you might have to implement a workaround similar to Devise by setting changed_attributes["unconfirmed_email"] = nil as well.
devise Time-of-check Time-of-use Race Condition vulnerability
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.
Devise Gem for Ruby Unauthorized Access Using "Remember Me" Cookie
- https://github.com/heartcombo/devise/commit/c92996646aba2d25b2c3e235fe0c4f1a84b70d24
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/devise/CVE-2015-8314.yml
- http://blog.plataformatec.com.br/2016/01/improve-remember-me-cookie-expiration-in-devise/
- https://github.com/advisories/GHSA-746g-3gfp-hfhw
- https://nvd.nist.gov/vuln/detail/CVE-2015-8314
- https://rubysec.com/advisories/CVE-2015-8314/
Devise version before 3.5.4 uses cookies to implement a Remember me
functionality. However, it generates the same cookie for all devices. If an attacker manages to steal a remember me cookie and the user does not change the password frequently, the cookie can be used to gain access to the application indefinitely.
Authentication Bypass in Devise
- https://nvd.nist.gov/vuln/detail/CVE-2019-16109
- https://github.com/advisories/GHSA-fcjw-8rhj-gwwc
- https://github.com/plataformatec/devise/compare/v4.7.0...v4.7.1
- https://github.com/plataformatec/devise/issues/5071
- https://github.com/plataformatec/devise/pull/5132
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/devise/CVE-2019-16109.yml
An issue was discovered in Plataformatec Devise before 4.7.1. It confirms accounts upon receiving a request with a blank confirmationtoken, if a database record has a blank value in the confirmationtoken column. (However, there is no scenario within Devise itself in which such database records would exist.)
Devise has an Open Redirect via Unvalidated `request.referrer` in Timeoutable Session Timeout Handler
Summary
When the Timeoutable module is enabled in Devise, the FailureApp#redirect_url method returns request.referrer — the HTTP Referer header, which is attacker-controllable — without validation for any non-GET request that results in a session timeout. An attacker who hosts a page with an auto-submitting cross-origin form can cause a victim with an expired Devise session to be redirected to an arbitrary external URL. This contrasts with the GET timeout path (which uses server-side attempted_path) and Devise's own store_location_for mechanism (which strips external hosts via extract_path_from_location), both of which are protected; only the non-GET timeout redirect path is unprotected.
Details
The vulnerable code is in lib/devise/failure_app.rb:
def redirect_url
if warden_message == :timeout
flash[:timedout] = true if is_flashing_format?
path = if request.get?
attempted_path # safe: server-side value from warden options
else
request.referrer # UNSAFE: HTTP Referer header, attacker-controlled
end
path || scope_url
else
scope_url
end
end
This is passed directly to redirect_to:
def redirect
store_location!
# ...
redirect_to redirect_url # redirect_url may be an external attacker URL
end
The GET timeout path uses attempted_path, which is set server-side by Warden and cannot be influenced by the client. The store_location! method also only runs for GET requests, so no session-based protection is applied on POST timeouts.
By contrast, Devise's store_location_for method (used elsewhere) correctly sanitizes URLs via extract_path_from_location, which strips the scheme and host.
Impact
- Victims with expired sessions who click any attacker-crafted link or visit an attacker page with an auto-submitting form are redirected to an arbitrary external URL.
- The redirect happens transparently via a trusted domain (the target app's domain), bypassing browser phishing warnings.
- An attacker can redirect victims to a fake login page to harvest credentials (phishing), or to malicious download sites.
Note: Rails' built-in open-redirect protection does not mitigate this issue. Devise::FailureApp is an ActionController::Metal app with its own isolated copy of the relevant redirect configuration, so config.action_controller.action_on_open_redirect = :raise (and the older raise_on_open_redirects setting) do not reach it.
Patches
This is patched in Devise v5.0.4. Users should upgrade as soon as possible.
Workaround
None beyond upgrading. If an upgrade is not immediately possible, the same changes from the patch commit can be applied as a monkey-patch in a Rails initializer (Devise::FailureApp#redirect_url and Devise::Controllers::StoreLocation#extract_path_from_location). Remove the monkey-patch after upgrading.
Devise Database Type Conversion Crafted Request Parsing Security Bypass
Devise contains a flaw that is triggered during when a type conversion error occurs during the parsing of a malformed request. With a specially crafted request, a remote attacker can bypass security restrictions.
Devise Gem for Ruby Unauthorized Access Using Remember Me Cookie
Devise version before 3.5.4 uses cookies to implement a Remember me
functionality. However, it generates the same cookie for all devices. If an attacker manages to steal a remember me cookie and the user does not change the password frequently, the cookie can be used to gain access to the application indefinitely.
Devise Gem for Ruby confirmation token validation with a blank string
Devise before 4.7.1 confirms accounts upon receiving a request with a blank confirmationtoken, if a database record has a blank value in the confirmationtoken column. However, there is no scenario within Devise itself in which such database records would exist.
Devise Gem for Ruby Time-of-check Time-of-use race condition with lockable module
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.
Confirmable "change email" race condition permits user to confirm email they have no access to
Impact
A race condition in Devise's Confirmable module allows an attacker to confirm an email address they do not own. This affects any Devise application using the reconfirmable option (the default when using Confirmable with email changes).
By sending two concurrent email change requests, an attacker can desynchronize the confirmationtoken and unconfirmedemail fields. The confirmation token is sent to an email the attacker controls, but the unconfirmed_email in the database points to a victim's email address. When the attacker uses the token, the victim's email is confirmed on the attacker's account.
Patch
This is patched in Devise v5.0.3. Users should upgrade as soon as possible.
Workaround
Applications can override this specific method from Devise models to force unconfirmed_email to be persisted when unchanged: (assuming your model is User)
class User < ApplicationRecord
protected
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
unconfirmed_email_will_change!
super
end
end
Note: Mongoid does not seem to respect that willchange! should force the attribute to be persisted, even if it did not really change, so you might have to implement a workaround similar to Devise by setting changedattributes[unconfirmed_email
] = nil as well.
Devise has an Open Redirect via Unvalidated `request.referrer` in Timeoutable Session Timeout Handler
Summary
When the Timeoutable module is enabled in Devise, the FailureApp#redirect_url method returns request.referrer — the HTTP Referer header, which is attacker-controllable — without validation for any non-GET request that results in a session timeout. An attacker who hosts a page with an auto-submitting cross-origin form can cause a victim with an expired Devise session to be redirected to an arbitrary external URL. This contrasts with the GET timeout path (which uses server-side attempted_path) and Devise's own store_location_for mechanism (which strips external hosts via extract_path_from_location), both of which are protected; only the non-GET timeout redirect path is unprotected.
Details
The vulnerable code is in lib/devise/failure_app.rb:
def redirect_url
if warden_message == :timeout
flash[:timedout] = true if is_flashing_format?
path = if request.get?
attempted_path # safe: server-side value from warden options
else
request.referrer # UNSAFE: HTTP Referer header, attacker-controlled
end
path || scope_url
else
scope_url
end
end
This is passed directly to redirect_to:
def redirect
store_location!
# ...
redirect_to redirect_url # redirect_url may be an external attacker URL
end
The GET timeout path uses attempted_path, which is set server-side by Warden and cannot be influenced by the client. The store_location! method also only runs for GET requests, so no session-based protection is applied on POST timeouts.
By contrast, Devise's store_location_for method (used elsewhere) correctly sanitizes URLs via extract_path_from_location, which strips the scheme and host.
Impact
- Victims with expired sessions who click any attacker-crafted link or visit an attacker page with an auto-submitting form are redirected to an arbitrary external URL.
- The redirect happens transparently via a trusted domain (the target app's domain), bypassing browser phishing warnings.
- An attacker can redirect victims to a fake login page to harvest credentials (phishing), or to malicious download sites.
Note: Rails' built-in open-redirect protection does not mitigate this issue. Devise::FailureApp is an ActionController::Metal app with its own isolated copy of the relevant redirect configuration, so config.action_controller.action_on_open_redirect = :raise (and the older raise_on_open_redirects setting) do not reach it.
Patches
This is patched in Devise v5.0.4. Users should upgrade as soon as possible.
Workaround
None beyond upgrading. If an upgrade is not immediately possible, the same changes from the patch commit can be applied as a monkey-patch in a Rails initializer (Devise::FailureApp#redirect_url and Devise::Controllers::StoreLocation#extract_path_from_location). Remove the monkey-patch after upgrading.
CSRF token fixation attacks in Devise
Devise contains a flaw that allows a remote, user-assisted attacker to conduct a CSRF token fixation attack. This issue is triggered as previous CSRF tokens are not properly invalidated when a new token is created. If an attacker has knowledge of said token, a specially crafted request can be made to it, allowing the attacker to conduct CSRF attacks.
173 Other Versions
| Version | License | Security | Released | |
|---|---|---|---|---|
| 3.2.3 | MIT | 10 | 2014-02-20 - 18:33 | about 12 years |
| 3.2.2 | MIT | 10 | 2013-11-25 - 11:00 | over 12 years |
| 3.2.1 | MIT | 10 | 2013-11-13 - 13:25 | over 12 years |
| 3.2.0 | MIT | 10 | 2013-11-06 - 20:51 | over 12 years |
| 3.1.2 | MIT | 10 | 2013-11-13 - 13:24 | over 12 years |
| 3.1.1 | MIT | 10 | 2013-10-01 - 15:51 | over 12 years |
| 3.1.0 | MIT | 10 | 2013-09-05 - 22:50 | over 12 years |
| 3.1.0.rc2 | MIT | 10 | 2013-08-18 - 08:18 | almost 13 years |
| 3.0.4 | MIT | 10 | 2013-11-13 - 13:24 | over 12 years |
| 3.0.3 | MIT | 10 | 2013-08-18 - 08:26 | almost 13 years |
| 3.0.2 | MIT | 10 | 2013-08-09 - 08:24 | almost 13 years |
| 3.0.1 | MIT | 10 | 2013-08-02 - 21:25 | almost 13 years |
| 3.0.0 | MIT | 11 | 2013-07-14 - 18:48 | almost 13 years |
| 3.0.0.rc | MIT | 11 | 2013-05-07 - 16:35 | about 13 years |
| 2.2.8 | MIT | 10 | 2013-11-13 - 13:24 | over 12 years |
| 2.2.7 | MIT | 10 | 2013-08-18 - 08:29 | almost 13 years |
| 2.2.6 | MIT | 10 | 2013-08-09 - 08:32 | almost 13 years |
| 2.2.5 | MIT | 10 | 2013-08-02 - 21:24 | almost 13 years |
| 2.2.4 | MIT | 10 | 2013-05-07 - 15:54 | about 13 years |
| 2.2.3 | UNKNOWN | 10 | 2013-01-28 - 14:49 | over 13 years |
| 2.2.2 | UNKNOWN | 12 | 2013-01-15 - 20:03 | over 13 years |
| 2.2.1 | UNKNOWN | 12 | 2013-01-11 - 18:16 | over 13 years |
| 2.2.0 | UNKNOWN | 12 | 2013-01-08 - 20:31 | over 13 years |
| 2.2.0.rc | UNKNOWN | 11 | 2012-12-13 - 09:05 | over 13 years |
| 2.1.4 | UNKNOWN | 11 | 2013-08-18 - 08:38 | almost 13 years |
| 2.1.3 | UNKNOWN | 11 | 2013-01-28 - 14:49 | over 13 years |
| 2.1.2 | UNKNOWN | 12 | 2012-06-19 - 09:27 | almost 14 years |
| 2.1.0 | UNKNOWN | 12 | 2012-05-15 - 17:16 | about 14 years |
| 2.1.0.rc2 | UNKNOWN | 11 | 2012-05-09 - 22:54 | about 14 years |
| 2.1.0.rc | UNKNOWN | 11 | 2012-03-15 - 14:19 | about 14 years |
| 2.0.6 | UNKNOWN | 11 | 2013-08-18 - 08:44 | almost 13 years |
| 2.0.5 | UNKNOWN | 11 | 2013-01-28 - 14:49 | over 13 years |
| 2.0.4 | UNKNOWN | 12 | 2012-02-17 - 08:32 | over 14 years |
| 2.0.2 | UNKNOWN | 12 | 2012-02-15 - 16:26 | over 14 years |
| 2.0.1 | UNKNOWN | 12 | 2012-02-09 - 10:15 | over 14 years |
| 2.0.0 | UNKNOWN | 12 | 2012-01-26 - 19:45 | over 14 years |
| 2.0.0.rc2 | UNKNOWN | 11 | 2012-01-24 - 13:29 | over 14 years |
| 2.0.0.rc | UNKNOWN | 11 | 2011-12-19 - 12:36 | over 14 years |
| 1.5.4 | UNKNOWN | 11 | 2013-01-28 - 14:49 | over 13 years |
| 1.5.3 | UNKNOWN | 12 | 2011-12-19 - 11:57 | over 14 years |
| 1.5.2 | UNKNOWN | 12 | 2011-11-30 - 09:26 | over 14 years |
| 1.5.1 | UNKNOWN | 12 | 2011-11-22 - 15:13 | over 14 years |
| 1.5.0 | UNKNOWN | 12 | 2011-11-13 - 21:23 | over 14 years |
| 1.5.0.rc1 | UNKNOWN | 11 | 2011-11-10 - 21:27 | over 14 years |
| 1.4.9 | UNKNOWN | 12 | 2011-10-20 - 14:50 | over 14 years |
| 1.4.8 | UNKNOWN | 12 | 2011-10-10 - 12:44 | over 14 years |
| 1.4.7 | UNKNOWN | 12 | 2011-09-22 - 09:51 | over 14 years |
| 1.4.5 | UNKNOWN | 12 | 2011-09-08 - 21:54 | over 14 years |
| 1.4.3 | UNKNOWN | 12 | 2011-08-30 - 12:43 | over 14 years |
| 1.4.2 | UNKNOWN | 12 | 2011-06-30 - 18:20 | almost 15 years |
