CVE-2026-40295: heartcombo Devise open redirect in Timeoutable session handler

CVE-2026-40295 · Severity: medium · CVSS 6.1 · Published 2026-05-22

Devise, a popular authentication library for Ruby on Rails applications, contains a vulnerability that can be used to redirect users to malicious websites. When a user's session expires during a form submission, the application may automatically send them to a URL specified by an attacker rather than the intended login page. This can be used in phishing campaigns to trick users into entering their credentials on a fake website that looks like the legitimate application.

Technologies: devise (RubyGems). Vendors: RubyGems.

Quick answers

Is CVE-2026-40295 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-40295 being exploited in the wild.
How severe is CVE-2026-40295?
Medium severity, with a CVSS score of 6.1, published 22 May 2026.
Which products and versions are affected?
Heartcombo Devise <= 5.0.3; devise (RubyGems) ECOSYSTEM:introduced=0,fixed=5.0.4.
Is there a fix for CVE-2026-40295?
Yes. devise (RubyGems): upgrade to 5.0.4 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-40295 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-40295?
Check whether you run Heartcombo Devise or devise (RubyGems) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • devise (RubyGems): upgrade to 5.0.4 or later
    bundle update devise

Technical details

An open redirect vulnerability exists in Devise's `FailureApp#redirect_url` method when the `Timeoutable` module is enabled. For non-GET requests (such as POST) that trigger a session timeout, the application uses the attacker-controllable HTTP `Referer` header to determine the redirect destination without proper validation. While GET requests are protected by server-side path tracking and other mechanisms sanitize URLs by stripping hostnames, this specific code path lacks those protections. An attacker can exploit this by hosting a page with an auto-submitting cross-origin form; if a victim with an expired session interacts with it, they are redirected to an arbitrary URL. This bypasses Rails' built-in open-redirect protection because `Devise::FailureApp` operates as an isolated `ActionController::Metal` application. The issue is fixed in version 5.0.4.

Affected products

  • heartcombo devise <= 5.0.3

Identifiers

  • CVE-2026-40295
  • GHSA-jp94-3292-c3xv

Timeline

  • 2026-05-08: advisory
  • 2026-05-08: patched

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.