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

Source: https://junglewise.ai/threats/cve-2026-40295-heartcombo-devise-open-redirect-in-timeoutable-session-handler  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-05-22. Updated: 2026-05-29  
License: CC BY 4.0 with a link back

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)](https://junglewise.ai/threats/technologies/rubygems-devise). Vendors: [RubyGems](https://junglewise.ai/threats/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

  ```sh
  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

- [https://api.github.com/users/offset](https://api.github.com/users/offset)
- [https://github.com/offset](https://github.com/offset)
- [https://api.github.com/users/offset/gists%7B/gist_id%7D](https://api.github.com/users/offset/gists%7B/gist_id%7D)
- [https://api.github.com/users/offset/repos](https://api.github.com/users/offset/repos)
- [https://avatars.githubusercontent.com/u/114768995?v=4](https://avatars.githubusercontent.com/u/114768995?v=4)
- [https://api.github.com/users/offset/events%7B/privacy%7D](https://api.github.com/users/offset/events%7B/privacy%7D)

## Related threats

- [Devise has a confirmable "change email" race condition permits user to confirm email they have no access to](https://junglewise.ai/threats/cve-2026-32700-devise-has-a-confirmable-change-email-race-condition-permits-user)
- [Devise Gem for Ruby Unauthorized Access Using "Remember Me" Cookie](https://junglewise.ai/threats/cve-2015-8314-devise-gem-for-ruby-unauthorized-access-using-remember-me-cookie)
- [Authentication Bypass in Devise](https://junglewise.ai/threats/cve-2019-16109-authentication-bypass-in-devise)
- [devise Time-of-check Time-of-use Race Condition vulnerability](https://junglewise.ai/threats/cve-2019-5421-devise-time-of-check-time-of-use-race-condition-vulnerability)
- [Devise does not properly perform type conversion when performing database queries](https://junglewise.ai/threats/cve-2013-0233-devise-does-not-properly-perform-type-conversion-when-performing)
