Devise CVE-2026-40295
MEDIUMAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
ReconAttacker hosts malicious page
-
DeliveryVictim visits page or clicks link
-
ExploitAuto-submitting form posts to target app
-
InstallSession detected as expired
-
C2FailureApp#redirect_url reads attacker-controlled Referer header
-
Executeredirect_to sends victim to attacker phishing server
-
ImpactVictim credential theft
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V3 - Web Frontend Security Redirect URL validation
MITRE ATT&CK
1 technique across 1 tactic: Initial Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | The Timeoutable module must be explicitly enabled in the Devise configuration (typically via |
| Impact | CVSS 6.1 (AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N) indicates network-exploitable vulnerability with low attack complexity and required user interaction (clicking a link or visiting attacker page), affecting confidentiality and integrity via credential theft or social engineering. The attack vector is network-based but requires initial user action (UI:R), which moderately constrains exploitation. Scope change (S:C) reflects that the vulnerability impacts confidentiality and integrity beyond the vulnerable application itself (victims redirected to external sites). No EPSS score, KEV status, or POC availability data provided; however, the vulnerability is straightforward to exploit (AC:L) and requires no authentication (PR:N), making it attractive for phishing campaigns once publicly disclosed. The attack surface is limited to environments where the Timeoutable module is explicitly enabled and sessions can expire, but such configurations are common in production Devise deployments. Real-world risk is amplified because the redirect occurs through a trusted domain (bypassing URL bar inspection), increasing victim click-through rates. The existence of a protected parallel code path (GET timeout using |
| Exploit ScenarioDerived | An attacker registers a domain and creates a webpage with hidden HTML containing an auto-submitting form (POST request) targeting the victim's Devise-protected application. The form includes a Referer header pointing to the attacker's credential-harvesting server. When a victim with an expired session visits the attacker's page, the form auto-submits, triggering a session timeout in the target application. The vulnerable |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – May 08, 2026
Open redirect in Devise's Timeoutable module allows unauthenticated attackers to redirect users with expired sessions to arbitrary external URLs via an unvalidated HTTP Referer header on non-GET requests. An attacker can host a page with an auto-submitting form to transparently redirect victims through a trusted domain, enabling credential harvesting or malware distribution without triggering browser phishing warnings. Affects Devise versions up to 5.0.3; patched in 5.0.4.
RemediationAI
Vendor-released patch: Devise 5.0.4. Users must upgrade immediately by updating the Devise gem to version 5.0.4 or later in their Gemfile and running bundle update devise. If immediate upgrade is not feasible, apply the same code changes from the patch commit as a monkey-patch in a Rails initializer (modifying Devise::FailureApp#redirect_url and Devise::Controllers::StoreLocation#extract_path_from_location to strip external hosts from referrer-based redirects using the same extract_path_from_location mechanism applied to GET timeouts). The monkey-patch must be removed after upgrading to the patched version. No workarounds exist beyond these patching approaches; disabling the Timeoutable module entirely would prevent session expiration handling and degrade user experience. See GitHub advisory GHSA-jp94-3292-c3xv for patch details.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in rubygems
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Devise is a flexible authentication solution for Rails that includes a Timeoutable module enabling session expiration. The vulnerability exists in the FailureApp#redirect_url method in lib/devise/failure_app.rb, which handles session timeout redirects. When a non-GET request times out, the method returns request.referrer (the HTTP Referer header) directly without validation. This contrasts with GET timeout handling, which uses attempted_path (a server-side value from Warden options), and with Devise's own store_location_for mechanism, which sanitizes URLs via extract_path_from_location to strip external hosts and schemes. The vulnerability is classified as CWE-601 (Open Redirect) and occurs because the attacker-controllable Referer header is passed directly to Rails' redirect_to helper without path extraction or validation. Rails' global config.action_controller.action_on_open_redirect = :raise setting does not protect against this because Devise::FailureApp is an ActionController::Metal app with its own isolated configuration context.
Know when Open Redirect gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Primary rating from Vendor (https://github.com/heartcombo/devise) · only source for this CVE.
CVSS VectorVendor: https://github.com/heartcombo/devise
DescriptionCVE.org
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
endThis is passed directly to redirect_to:
def redirect
store_location!
# ...
redirect_to redirect_url
# redirect_url may be an external attacker URL
endThe 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.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Affected Products (CPE)CVE.org
More in Open Redirect
View allA malicious third-party can give a crafted "ssh://..." URL to an unsuspecting victim, and an attempt to visit the URL ca
GFI Kerio Control versions 9.2.5 through 9.4.5 contain an HTTP response splitting vulnerability in the dest parameter of
PHP through 7.0.8 does not attempt to address RFC 3875 section 4.1.18 namespace conflicts and therefore does not protect
Multiple open redirect vulnerabilities in Apache Struts 2.0.0 through 2.3.15 allow remote attackers to redirect users to
When the default servlet in Apache Tomcat versions 9.0.0.M1 to 9.0.11, 8.5.0 to 8.5.33 and 7.0.23 to 7.0.90 returned a r
Open redirect vulnerability in age-verification.php in the Age Verification plugin 0.4 and earlier for WordPress allows
Open redirect vulnerability in Kaseya Virtual System Administrator (VSA) 7.x before 7.0.0.29, 8.x before 8.0.0.18, 9.0 b
Vulnerability in the Oracle Applications Framework component of Oracle E-Business Suite (subcomponent: Popup windows (li
Unspecified vulnerability in the Oracle Application Server Single Sign-On component in Oracle Fusion Middleware 10.1.4.3
Flarum is open source discussion platform software. Rated medium severity (CVSS 6.5), this vulnerability is remotely exp
Open redirect vulnerability in Novius OS 5.0.1 (Elche) allows remote attackers to redirect users to arbitrary web sites
Open redirect vulnerability in the Redirect function in stageshow_redirect.php in the StageShow plugin before 5.0.9 for
GHSA-jp94-3292-c3xv
NVD
CVE.org
EPSS
VulDB
Exploit-DB