{"id":"CVE-2026-125109","aliases":["CVE-2026-125109","GHSA-2j8w-xcrc-x985"],"related":[],"kind":"vulnerability","state":"published","title":"Rack: Rack::Request#host_with_port (and #base_url / #url) return the raw invalid Host header — incomplete fix of CVE-2026-34835","summary":"Rack is a modular Ruby web server interface. From 3.0 until 3.1.23 and 3.2.8, Rack::Request#host_with_port, #base_url, and #url can return an attacker-controlled invalid authority from Host, X-Forwarded-Host, or Forwarded: host= verbatim. Applications without an independent host allowlist that use these methods for absolute URLs, redirects, or origin-dependent checks can emit attacker-chosen delimiters, enabling redirect manipulation, string-based allowlist bypass, or unescaped markup reflection. Rails overrides these methods and is not expected to be affected. This issue is fixed in versions 3.1.23 and 3.2.8.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Rack is a modular Ruby web server interface. From 3.0 until 3.1.23 and 3.2.8, Rack::Request#host_with_port, #base_url, and #url can return an attacker-controlled invalid authority from Host, X-Forwarded-Host, or Forwarded: host= verbatim. Applications without an independent host allowlist that use these methods for absolute URLs, redirects, or origin-dependent checks can emit attacker-chosen delimiters, enabling redirect manipulation, string-based allowlist bypass, or unescaped markup reflection. Rails overrides these methods and is not expected to be affected. This issue is fixed in versions 3.1.23 and 3.2.8.","source":"cvelist"},{"lang":"en","text":"## Summary\n\n`Rack::Request#host_with_port`, and therefore `#base_url` and `#url`, return the raw authority string when it fails validation. An attacker-controlled `Host`, `X-Forwarded-Host`, or `Forwarded: host=` value containing characters that are not permitted in an authority is embedded verbatim in URLs generated by the application.\n\nThis completes the fix for CVE-2026-34835 (GHSA-g2pf-xv49-m2h5), which made `#host` and `#hostname` return `nil` for an invalid authority but left this path unchanged.\n\n## Details\n\n`Rack::Request#host_with_port` splits the authority with `split_authority`. When the `AUTHORITY` pattern does not match, no components are returned and `host_with_port` falls back to returning the unvalidated authority string. `base_url` is `\"#{scheme}://#{host_with_port}\"` and `url` appends the full path, so both inherit the raw value.\n\nFor a request with `Host: evil.com/@legit.com`, `host` returns `nil` while `host_with_port` returns `evil.com/@legit.com` and `base_url` returns `http://evil.com/@legit.com`. A valid `Host` together with an invalid `X-Forwarded-Host` produces the same result, because forwarded headers take priority by default.\n\n## Impact\n\nApplications that build absolute URLs, redirects, or origin-dependent checks from `req.url`, `req.base_url`, or `req.host_with_port`, and that do not enforce a host allowlist, may emit URLs containing attacker-chosen characters such as `@`, `/`, `?`, `#`, spaces, or angle brackets. Generated links and `Location` headers can be redirected through userinfo tricks, string-based URL checks can be bypassed, and markup is reflected where the application does not escape the value. For example, `redirect` in Sinatra behind a proxy that forwards `X-Forwarded-Host` emits the raw invalid authority in `Location`.\n\nRails overrides these methods in Action Dispatch and is not expected to be affected. Rack 3.1 and 3.2 are affected. Rack 2.2 did not receive the CVE-2026-34835 change and returns the raw value from every host method.\n\n## Mitigation\n\n* Update to a patched version of Rack, in which `host_with_port` returns `nil` for an invalid authority and `base_url` falls back to the server's own name.\n* Enforce a host allowlist with `Rack::Protection::HostAuthorization`, `config.hosts` in Rails, or at the reverse proxy, and configure the proxy to overwrite `X-Forwarded-Host` and `Forwarded`.\n* Pin the authority with the `rack.request.config` `:authority` key where available.","format":"markdown","source":"ghsa"}],"published":"2026-11-09T21:57:46.924Z","modified":"2026-11-12T19:18:09.510Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N","score":4.8,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N","score":4.8,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N","score":4.8,"rating":"MEDIUM"}],"cwes":["CWE-1286"],"affected":[{"ranges":[{"version":">= 3.0, < 3.1.23","status":"affected"},{"version":">= 3.2, < 3.2.8","status":"affected"}],"vendor":"rack","product":"rack","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"3.0.0","status":"affected","fixed":"3.1.23"}],"ecosystem":"RubyGems","package":"rack","purl":"pkg:gem/rack","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"3.2.0","status":"affected","fixed":"3.2.8"}],"ecosystem":"RubyGems","package":"rack","purl":"pkg:gem/rack","source":"ghsa"}],"references":[{"url":"https://github.com/rack/rack/security/advisories/GHSA-2j8w-xcrc-x985","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/rack/rack/commit/4380381a56dc52556a436d6d794c8e18dc8b0565","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/rack/rack/commit/49386f460286b7346c7003b69a839de782cc8a39","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/rack/rack/releases/tag/v3.1.23","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/rack/rack/releases/tag/v3.2.8","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-125109","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/rack/rack","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/rack/GHSA-2j8w-xcrc-x985.yml","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-11-10T16:17:53.102Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-125109","url":"https://www.cve.org/CVERecord?id=CVE-2026-125109","licence":"CVE Terms of Use","modified":"2026-11-10T16:18:06.940Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2j8w-xcrc-x985","url":"https://github.com/advisories/GHSA-2j8w-xcrc-x985","licence":"CC-BY-4.0","modified":"2026-11-10T19:30:04.014Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-125109","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-125109","licence":"Public domain","modified":"2026-11-12T19:18:09.510Z"}],"updatedAt":"2026-11-25T22:59:49.674Z","epss":{"score":0.00295,"percentile":0.23785,"date":"2026-12-01T12:00:22.000Z"}}