Rack: Rack::Request#host_with_port (and #base_url / #url) return the raw invalid Host header — incomplete fix of CVE-2026-34835
Published 10 Nov 2026 · Updated 10 Nov 2026
Is your project on an affected rack?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected packages
- Affected
- >=3.0.0 <3.1.23
- Fixed in
- 3.1.23
bundle update --conservative rack # Gemfile: '>= 3.1.23'- Affected
- >=3.2.0 <3.2.8
- Fixed in
- 3.2.8
bundle update --conservative rack # Gemfile: '>= 3.2.8'Details
Summary
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.
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.
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.
Is GHSA-2j8w-xcrc-x985 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected rack, and gives you the command that fixes it.
More advisories for rack
- HighCVE-2026-125111Rack: Multipart parsing allows DoS via unbounded scan buffer growth · 10 Nov 2026
- LowCVE-2026-125108Rack: Multipart boundary ambiguity guard in Rack::Multipart::Parser can be bypassed with a quoted boundary value, allowing WAF bypass · 10 Nov 2026
- MediumCVE-2026-125110Rack: Rack::Static header_rules bypass via dot-segment normalization mismatch · 10 Nov 2026
- MediumCVE-2026-34835Rack::Request accepts invalid Host characters, enabling host allowlist bypass · 2 Apr 2026
- MediumCVE-2026-34831Rack has Content-Length mismatch in Rack::Files error responses · 2 Apr 2026
- MediumCVE-2026-34830Rack::Sendfile header-based X-Accel-Mapping regex injection enables unauthorized X-Accel-Redirect · 2 Apr 2026
References
- Linkgithub.com/rack/rack/security/advisories/GHSA-2j8w-xcrc-x985
- Advisorynvd.nist.gov/vuln/detail/CVE-2026-125109
- Linkgithub.com/rack/rack/commit/4380381a56dc52556a436d6d794c8e18dc8b0565
- Linkgithub.com/rack/rack/commit/49386f460286b7346c7003b69a839de782cc8a39
- Packagegithub.com/rack/rack
- Linkgithub.com/rack/rack/releases/tag/v3.1.23
- Linkgithub.com/rack/rack/releases/tag/v3.2.8
- Linkgithub.com/rubysec/ruby-advisory-db/blob/master/gems/rack/GHSA-2j8w-xcrc-x985.yml
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.