Summary
Rack: Rack::Request#hostwithport (and #base_url / #url) return the raw invalid Host header, incomplete fix of CVE-2026-34835
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.
This 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.
Details
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.
For 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.
Mitigation
- Update to a patched version of Rack, in which
host_with_portreturnsnilfor an invalid authority andbase_urlfalls back to the server's own name. - Enforce a host allowlist with
Rack::Protection::HostAuthorization,config.hostsin Rails, or at the reverse proxy, and configure the proxy to overwriteX-Forwarded-HostandForwarded. - Pin the authority with the
rack.request.config:authoritykey where available.
Impact
Applications 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.
Rails 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.
CVE-2026-125109 has a CVSS score of 4.8 (Medium). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (3.1.23, 3.2.8); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
rack to 3.1.23 or later; rack to 3.2.8 or later
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2026-125109? CVE-2026-125109 is a medium-severity security vulnerability in rack (rubygems), affecting versions >= 3.0.0, < 3.1.23. It is fixed in 3.1.23, 3.2.8.
- How severe is CVE-2026-125109? CVE-2026-125109 has a CVSS score of 4.8 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of rack are affected by CVE-2026-125109? rack (rubygems) versions >= 3.0.0, < 3.1.23 is affected.
- Is there a fix for CVE-2026-125109? Yes. CVE-2026-125109 is fixed in 3.1.23, 3.2.8. Upgrade to this version or later.
- Is CVE-2026-125109 exploitable, and should I be worried? Whether CVE-2026-125109 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-125109 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-125109?
- Upgrade
rackto 3.1.23 or later - Upgrade
rackto 3.2.8 or later
- Upgrade