Devise: Open Redirect via Unvalidated `request.referrer` in Timeoutable Session Timeout Handler
Devise is an authentication solution for Rails based on Warden. In versions 5.0.3 and below, 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. Expired-session users can be silently redirected from the trusted app domain to attacker-controlled URLs, enabling phishing and malware delivery while bypassing browser warnings. 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. This issue has been fixed in version 5.0.4.
- Products
- Not specified
- Affected versions
- Not specified
- Fixed versions
- Not specified
- CVEs
- CVE-2026-40295
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 3 Nov 2026, 07:11 UTC · Revision 1
Source evidence
Devise: Open Redirect via Unvalidated `request.referrer` in Timeoutable Session Timeout Handler
core-osv · Original sourcePublished 22 May 2026, 19:10 UTC
Devise is an authentication solution for Rails based on Warden. In versions 5.0.3 and below, 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. Expired-session users can be silently redirected from the trusted app domain to attacker-controlled URLs, enabling phishing and malware delivery while bypassing browser warnings. 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. This issue has been fixed in version 5.0.4.
osv:CVE-2026-40295
Complete source record
{
"id": "2887c3ed919e3ad5979a17dc8506d77aac075d5af04ec20bcef58c3990819f86",
"url": "https://osv.dev/vulnerability/CVE-2026-40295",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "Devise: Open Redirect via Unvalidated `request.referrer` in Timeoutable Session Timeout Handler",
"summary": "Devise is an authentication solution for Rails based on Warden. In versions 5.0.3 and below, 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. Expired-session users can be silently redirected from the trusted app domain to attacker-controlled URLs, enabling phishing and malware delivery while bypassing browser warnings. 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. This issue has been fixed in version 5.0.4.",
"evidence": "osv:CVE-2026-40295",
"products": [],
"severity": "medium",
"structured": {
"id": "CVE-2026-40295",
"aliases": [
"CVE-2026-40295",
"GHSA-jp94-3292-c3xv"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
}
],
"affected": [
{
"ranges": [
{
"repo": "https://github.com/heartcombo/devise",
"type": "GIT",
"events": [
{
"introduced": "0"
},
{
"fixed": "9ea459de9aec5f1217ad738c58e0d23fb9f5beaa"
},
{
"fixed": "025fe2124f9928766fc46520e999633b598d0360"
}
],
"database_specific": {
"extracted_events": [
{
"cpe": "cpe:2.3:a:heartcombo:devise:*:*:*:*:*:ruby:*:*",
"range": [
{
"introduced": "0"
},
{
"fixed": "5.0.4"
}
],
"source": "CPE_RANGE"
},
{
"range": [
{
"fixed": "025fe2124f9928766fc46520e999633b598d0360"
}
],
"source": "REFERENCES_COMMIT"
}
]
}
}
],
"versions": [
"v5.0.3",
"v5.0.2",
"v5.0.1",
"v5.0.0",
"v5.0.0.rc",
"v4.9.2",
"v4.9.1",
"v4.9.0",
"v4.8.1",
"v4.8.0",
"v4.7.2",
"v4.7.1",
"v4.7.0",
"v4.6.2",
"v4.6.1",
"v4.6.0",
"v4.5.0",
"v4.4.3",
"v4.4.2",
"v4.4.1",
"v4.4.0",
"v4.3.0",
"v4.2.1",
"v4.2.0",
"v4.1.0",
"v4.0.1",
"v4.0.0",
"v4.0.0.rc2",
"v4.0.0.rc1",
"v3.5.3",
"v3.5.2",
"v3.5.1",
"v3.5.0",
"v3.4.1",
"v3.4.0",
"v3.3.0",
"v3.2.4",
"v3.2.3",
"v3.2.2",
"v3.2.1",
"v3.2.0",
"v3.1.0",
"v3.1.0.rc2",
"v3.1.0.rc",
"v3.0.1",
"v2.2.4",
"v3.0.0",
"v3.0.0.rc",
"v2.2.3",
"v2.1.2",
"v2.2.2",
"v2.2.1",
"v2.2.0",
"v2.2.0.rc",
"v2.1.1",
"v2.1.0",
"v2.1.0.rc2",
"v2.1.0.rc",
"v2.0.3",
"v2.0.2",
"v2.0.1",
"v2.0.0",
"v2.0.0.rc2",
"v2.0.0.rc",
"v1.5.1",
"v1.5.0",
"v1.5.0.rc1",
"v1.5.0.rc",
"v1.4.7",
"v1.4.6",
"v1.4.4",
"v1.4.3",
"v1.4.2",
"v1.4.1",
"v1.4.0",
"v1.3.1",
"v1.3.0",
"v1.2.0",
"v1.2.rc2",
"v1.2.rc",
"v1.1.0",
"v1.1.rc2",
"v1.1.rc1",
"v1.1.rc0",
"v1.1.pre4",
"v1.1.pre3",
"v1.1.pre2",
"v1.1.pre",
"v1.0.1",
"v1.0.0",
"v0.9.1",
"v0.9.0",
"v0.8.2",
"v0.8.1",
"v0.8.0",
"v0.7.5"
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-40295.json"
}
}
],
"modified": "2026-10-28T02:30:26.749434464Z",
"provider": "osv",
"references": [
"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/40xxx/CVE-2026-40295.json",
"https://github.com/heartcombo/devise/security/advisories/GHSA-jp94-3292-c3xv",
"https://nvd.nist.gov/vuln/detail/CVE-2026-40295",
"https://github.com/heartcombo/devise/commit/025fe2124f9928766fc46520e999633b598d0360"
],
"provider_metadata": {
"cwe_ids": [
"CWE-601"
],
"cna_assigner": "GitHub_M",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/40xxx/CVE-2026-40295.json"
}
},
"related_cves": [
{
"value": "CVE-2026-40295",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 493279,
"published_at": "2026-05-22T19:10:57.039+00:00"
}