Skip to main content

Devise CVE-2026-40295

MEDIUM
URL Redirection to Untrusted Site (Open Redirect) (CWE-601)
2026-05-08 https://github.com/heartcombo/devise GHSA-jp94-3292-c3xv
6.1
CVSS 3.1 · Vendor: https://github.com/heartcombo/devise
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Attacker hosts malicious page
  2. Delivery
    Victim visits page or clicks link
  3. Exploit
    Auto-submitting form posts to target app
  4. Install
    Session detected as expired
  5. C2
    FailureApp#redirect_url reads attacker-controlled Referer header
  6. Execute
    redirect_to sends victim to attacker phishing server
  7. Impact
    Victim 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 devise :timeoutable, timeout_in: X.minutes in the User model). The attack requires a non-GET HTTP request (POST, PUT, DELETE, PATCH) to trigger the timeout path; GET requests use the protected attempted_path mechanism and are not vulnerable. The victim's session must be expired at the time of the request. The attack requires user interaction (UI:R per CVSS) to visit the attacker-controlled page or click a link, but this is a standard phishing prerequisite. The browser must transmit a Referer header (standard browser behavior, but can be suppressed by attacker page configuration to their advantage or omitted by user settings, though most users send it). No special network position, authentication, or non-default configuration is required beyond enabling Timeoutable, which is a common feature in production deployments.

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 attempted_path) demonstrates that the development team recognized the risk in one context but failed to apply the same protection to POST/PUT/DELETE timeouts, suggesting this is a regression rather than inherent design flaw.

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 redirect_url method reads the attacker-controlled Referer header and redirects the victim to the fake login page via the legitimate application domain (e.g., redirect from vulnerable-app.com to attacker-phishing.com). The victim, seeing the application domain in the browser URL bar during the redirect, trusts the destination and enters credentials, which the attacker harvests.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.1% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – 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

rubygems devise fix: 5.0.4

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

Vendor (https://github.com/heartcombo/devise) PRIMARY 6.1 MEDIUM
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

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

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:

ruby
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
end

This is passed directly to redirect_to:

ruby
def redirect
  store_location!
# ...
  redirect_to redirect_url
# redirect_url may be an external attacker URL
end

The 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

EPSS Score
0.1%
Top 84% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium
NVD CVE.org EPSS GHSA GitHub VulDB

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.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.1%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

30
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +30
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Affected Products (CPE)CVE.org

pkg:rubygems/devise
CVE-2017-1000117 HIGH POC
8.8 Oct 05

A malicious third-party can give a crafted "ssh://..." URL to an unsuspecting victim, and an attempt to visit the URL ca

CVE-2024-52875 HIGH POC
8.8 Jan 31

GFI Kerio Control versions 9.2.5 through 9.4.5 contain an HTTP response splitting vulnerability in the dest parameter of

CVE-2016-5385 HIGH POC
8.1 Jul 19

PHP through 7.0.8 does not attempt to address RFC 3875 section 4.1.18 namespace conflicts and therefore does not protect

CVE-2013-2248 MEDIUM POC
5.8 Jul 20

Multiple open redirect vulnerabilities in Apache Struts 2.0.0 through 2.3.15 allow remote attackers to redirect users to

CVE-2018-11784 MEDIUM POC
4.3 Oct 04

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

CVE-2012-6499 MEDIUM POC
5.8 Jan 12

Open redirect vulnerability in age-verification.php in the Age Verification plugin 0.4 and earlier for WordPress allows

CVE-2015-2863 MEDIUM POC
4.3 Jul 20

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

CVE-2017-3528 MEDIUM POC
5.4 Apr 24

Vulnerability in the Oracle Applications Framework component of Oracle E-Business Suite (subcomponent: Popup windows (li

CVE-2012-0518 MEDIUM
4.7 Oct 16

Unspecified vulnerability in the Oracle Application Server Single Sign-On component in Oracle Fusion Middleware 10.1.4.3

CVE-2024-21641 MEDIUM POC
6.5 Jan 05

Flarum is open source discussion platform software. Rated medium severity (CVSS 6.5), this vulnerability is remotely exp

CVE-2015-5354 MEDIUM POC
5.8 Jul 01

Open redirect vulnerability in Novius OS 5.0.1 (Elche) allows remote attackers to redirect users to arbitrary web sites

CVE-2015-5461 MEDIUM POC
6.4 Jul 08

Open redirect vulnerability in the Redirect function in stageshow_redirect.php in the StageShow plugin before 5.0.9 for

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy