6.1
Medium
devise

CVE-2026-40295

CVE-2026-40295 is a medium-severity open redirect vulnerability in devise (rubygems), affecting versions <= 5.0.3. It is fixed in 5.0.4.

Key facts
CVSS score
6.1
Medium
Attack vector
Network
Issuing authority
GitHub Advisory Database
Affected package
devise
Fixed in
5.0.4
Disclosed
2026

Summary

Summary When the Timeoutable module is enabled in Devise, the FailureApp#redirecturl 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 attemptedpath) and Devise's own storelocationfor mechanism (which strips external hosts via extractpathfromlocation), both of which are protected; only the non-GET timeout redirect path is unprotected. Details The vulnerable code is in lib/devise/failureapp.rb: This is passed directly to redirectto: The GET timeout path uses attemptedpath, which is set server-side by Warden and cannot be influenced by the client. The storelocation! method also only runs for GET requests, so no session-based protection is applied on POST timeouts. By contrast, Devise's storelocationfor method (used elsewhere) correctly sanitizes URLs via extractpathfromlocation, 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.actioncontroller.actiononopenredirect = :raise (and the older raiseonopenredirects 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#redirecturl and Devise::Controllers::StoreLocation#extractpathfrom_location). Remove the monkey-patch after upgrading.

Impact

What is open redirect?

Untrusted input controls a URL used for redirection, which can forward users to attacker-controlled sites. Typical impact: phishing and credential harvesting via a trusted domain.

Severity and exposure

CVE-2026-40295 has a CVSS score of 6.1 (Medium). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment.

A fixed version is available (5.0.4). Upgrading removes the vulnerable code path.

Affected versions

rubygems

  • devise (<= 5.0.3)

Security releases

  • devise → 5.0.4 (rubygems)
Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter instead of chasing every advisory.

Kodem's runtime-powered SCA identifies whether CVE-2026-40295 is reachable in your applications. Explore open-source security for your team.

See if CVE-2026-40295 is reachable in your applications. Get a demo

Remediation advice

Upgrade devise to 5.0.4 or later to resolve this vulnerability.

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently asked questions about CVE-2026-40295

What is CVE-2026-40295?

CVE-2026-40295 is a medium-severity open redirect vulnerability in devise (rubygems), affecting versions <= 5.0.3. It is fixed in 5.0.4. Untrusted input controls a URL used for redirection, which can forward users to attacker-controlled sites.

How severe is CVE-2026-40295?

CVE-2026-40295 has a CVSS score of 6.1 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.

Which versions of devise are affected by CVE-2026-40295?

devise (rubygems) versions <= 5.0.3 is affected.

Is there a fix for CVE-2026-40295?

Yes. CVE-2026-40295 is fixed in 5.0.4. Upgrade to this version or later.

Is CVE-2026-40295 exploitable, and should I be worried?

Whether CVE-2026-40295 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo

What actually determines whether CVE-2026-40295 is exploitable, and how bad it is?

Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.

How do I fix CVE-2026-40295?

Upgrade devise to 5.0.4 or later.

Stop the waste.
Protect your environment with Kodem.