Categories
CVE-2026-40295 medium CVSS 6.1

Open Redirect in devise (CVE-2026-40295)

Summary

Vulnerability in devise (CVE-2026-40295). Risk of unauthorized operations or information disclosure. Exploitable via Referer header. Mitigation: upgrade to 5.0.4 or later.

Original description

The description as published by the source.

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:

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:

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 r…

Source: GitHub Security Advisories (Global) NVD GitHub Advisory

Auto-generated summary

Assembled by SecPulse from the source data (CVSS, CWE, affected versions) using templates — no AI involved. Check the original description and references below for exact details.

A vulnerability tracked as CVE-2026-40295 has been found in devise.
Attackers can target a specific entry point like Referer header over the network to misuse the product.
Risk of unauthorized operations or information disclosure. CVSS score: 6.1/10.
What to do: upgrade devise to 5.0.4 or later.
If unsure, ask your IT team or search "devise CVE-2026-40295" on the vendor's site.

CVE-2026-40295 (devise) — CWE-601 / CVSS v3 6.1
Attack vector: remote (network-reachable) / unauthenticated
Attack surface: Referer header / Timeoutable / request.referrer / Referer
Patched: 5.0.4 — apply immediately
Workaround: None beyond upgrading.
Plan: 1) Audit SBOM/dependencies, 2) Stage→prod upgrade, 3) Add WAF/proxy monitoring on affected endpoints, 4) Hunt IOCs in logs.
Refs: see the GHSA / vendor advisory / patched release linked on this page.

❓ What is the problem

A vulnerability (CWE-601) exists in devise. Attackers reach the vulnerable code path via Referer header without authentication.

📍 Affected scope

Check the vendor advisory for the affected versions of devise. Attack surface: Referer header / Timeoutable / request.referrer / Referer.

🔥 Severity

Severity: Medium (CVSS 6.1/10). Risk of unauthorized operations or information disclosure.

🔧 How to fix

Update to 5.0.4.

🛡️ Workaround

Workaround: None beyond upgrading.

🔍 Detection

Search webserver/proxy logs for unusual request patterns matching this CVE's known IOCs. Run grep -r 'devise' . against your dependency files (package-lock.json, requirements.txt, go.sum) to find affected services.

Response actions

Concrete steps and command examples for SOC/SRE teams to execute in order

  1. 1
    Identify exposure identify
    grep -r 'devise' . | grep -v node_modules

    リポジトリと本番環境の依存ファイル (package-lock.json / requirements.txt / go.sum / Gemfile.lock 等) で devise を grep し、稼働しているサービス・バージョンを把握する。

  2. 2
    Apply temporary workaround mitigate
    None beyond upgrading.

    パッチが適用されるまでの応急処置として、None beyond upgrading. を実施。回避策の副作用 (機能低下) を確認した上で。

  3. 3
    Apply patch patch
    Upgrade devise to 5.0.4

    ステージング環境で 5.0.4 に上げて回帰テスト → 本番反映。回帰テストはアプリの主要ハッピーパスを含めること。

  4. 4
    Post-deployment verification verify
    Confirm patched version is live in production

    パッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番ではアクセスログ・WAF でアラート再発が無いか継続監視。

Affected packages

rubygems devise
[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"5.0.4"}]}]

Fix status by distribution

Fixed packages published by each distribution for this CVE

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details