CVE-2026-40295 Details
Description
Devise is an authentication solution for Rails based on Warden. In versions 5.0.3 and below, 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. Expired-session users can be silently redirected from the trusted app domain to attacker-controlled URLs, enabling phishing and malware delivery while bypassing browser warnings. 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. This issue has been fixed in version 5.0.4.
A vulnerability exists in Devise, an authentication solution for Rails, in versions 5.0.3 and prior. When the Timeoutable module is active, the FailureApp#redirect_url method improperly handles the HTTP Referer header for non-GET requests that time out, allowing for unvalidated redirects to external URLs. This issue arises because the non-GET timeout path lacks the same protections as the GET path, which uses a server-side value that cannot be manipulated by the client. As a result, an attacker can exploit this vulnerability to redirect users with expired sessions from a trusted domain to an external site, potentially leading to phishing or malware delivery.
Users are advised to upgrade to Devise version 5.0.4, where this vulnerability has been patched. If an immediate upgrade is not possible, the patch can be applied as a monkey-patch in a Rails initializer by modifying the Devise::FailureApp#redirect_url and Devise::Controllers::StoreLocation#extract_path_from_location methods. Remember to remove the monkey-patch after upgrading.
Metrics
CVSS 4.0 Severity and Vector Strings:
No CVSS 4.0 data is available for this CVE.
CVSS 3.x Severity and Vector Strings:
No data available for CVSS Version 2.0 on this CVE.
CISA-ADP
Assessed May 26, 2026References to Advisories, Solutions, and Tools
By selecting these links, you will be leaving this site. These are references gathered from the official CVE record and are not endorsed by Volerion.
| URL | Source(s) | Tag(s) |
|---|---|---|
| https://github.com/heartcombo/devise/commit/025fe2124f9928766fc46520e999633b598d0360 | [email protected] | Patch |
| https://github.com/heartcombo/devise/security/advisories/GHSA-jp94-3292-c3xv | [email protected] | MitigationVendor Advisory |
Weakness Enumeration
| CWE-ID | CWE Name | Source |
|---|---|---|
| CWE-601 | URL Redirection to Untrusted Site ('Open Redirect') | [email protected] |
Affected Products
| Product | Versions |
|---|---|
| heartcombo devise | < 5.0.4 |
CPE
Remediation
| |
Change History
5 change records found show changes
| Date | Action | Recorded By |
|---|---|---|
| Jul 23, 2026 | CVE Translated | [email protected] |
| Jun 17, 2026 | CVE Modified | [email protected] |
| Jun 17, 2026 | CVE Modified | CISA-ADP |
| May 29, 2026 | Initial Analysis | [email protected] |
| May 22, 2026 | New CVE Received | [email protected] |