Loading...
Skip to main content

CVE-2026-34835

MEDIUM

Rack::Request accepts invalid Host characters, enabling host allowlist bypass

Published April 2, 2026Updated May 13, 2026Source: osv

Summary

## Summary `Rack::Request` parses the `Host` header using an `AUTHORITY` regular expression that accepts characters not permitted in RFC-compliant hostnames, including `/`, `?`, `#`, and `@`. Because `req.host` returns the full parsed value, applications that validate hosts using naive prefix or suffix checks can be bypassed. For example, a check such as `req.host.start_with?("myapp.com")` can be bypassed with `Host: myapp.com@evil.com`, and a check such as `req.host.end_with?("myapp.com")` can be bypassed with `Host: evil.com/myapp.com`. This can lead to host header poisoning in applications that use `req.host`, `req.url`, or `req.base_url` for link generation, redirects, or origin validation. ## Details `Rack::Request` parses the authority component using logic equivalent to: ```ruby AUTHORITY = / \A (?<host> \[(?<address>#{ipv6})\] | (?<address>[[[:graph:]&&[^\[\]]]]*?) ) (:(?<port>\d+))? \z /x ``` The character class used for non-IPv6 hosts accepts nearly all printable characters except `[` and `]`. This includes reserved URI delimiters such as `@`, `/`, `?`, and `#`, which are not valid hostname characters under RFC 3986 host syntax. As a result, values such as the following are accepted and returned through `req.host`: ```text myapp.com@evil.com evil.com/myapp.com evil.com#myapp.com ``` Applications that attempt to allowlist hosts using string prefix or suffix checks may therefore treat attacker-controlled hosts as trusted. For example: ```ruby req.host.start_with?("myapp.com") ``` accepts: ```text myapp.com@evil.com ``` and: ```ruby req.host.end_with?("myapp.com") ``` accepts: ```text evil.com/myapp.com ``` When those values are later used to build absolute URLs or enforce origin restrictions, the application may produce attacker-controlled results. ## Impact Applications that rely on `req.host`, `req.url`, or `req.base_url` may be affected if they perform naive host validation or assume Rack only returns RFC-valid hostnames. In affected deployments, an attacker may be able to bypass host allowlists and poison generated links, redirects, or origin-dependent security decisions. This can enable attacks such as password reset link poisoning or other host header injection issues. The practical impact depends on application behavior. If the application or reverse proxy already enforces strict host validation, exploitability may be reduced or eliminated. ## Mitigation * Update to a patched version of Rack that rejects invalid authority characters in `Host`. * Enforce strict `Host` header validation at the reverse proxy or load balancer. * Do not rely on prefix or suffix string checks such as `start_with?` or `end_with?` for host allowlisting. * Use exact host allowlists, or exact subdomain boundary checks, after validating that the host is syntactically valid.

Remediation

Upgrade to the fixed version using your package manager.

Bundler
Update rack to 3.2.6 or later
gem install rack -v 3.2.6
Bundler
Update rack to 3.1.21 or later
gem install rack -v 3.1.21

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (2)

PackageEcosystemAffectedFixed In
rack
rubygems
3.2.0, 3.2.1, 3.2.2, 3.2.3 (+2 more)3.2.6
rack
rubygems
3.0.0, 3.0.0.beta1, 3.0.0.rc1, 3.0.1 (+42 more)3.1.21

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 4.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
High
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
None

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N

Frequently Asked Questions

What is CVE-2026-34835?
Rack::Request accepts invalid Host characters, enabling host allowlist bypass This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 4.8/10).
How do I check if my project is affected by CVE-2026-34835?
CVE-2026-34835 affects rack. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-34835 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
4.8

Exploitation requires specific conditions or has limited impact. Remediate within weeks.

Also Known As

GHSA-g2pf-xv49-m2h5

Related CVEs

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies