GHSA-g2pf-xv49-m2h5
MEDIUMGHSA-g2pf-xv49-m2h5 is a medium-severity (CVSS 4.8) CWE-1286 vulnerability in rack. 1 public exploit reference exists, so weaponization risk is real. O3 Security confirms whether GHSA-g2pf-xv49-m2h5 is actually reachable in your code before you act, and blocks exploitation at runtime until you patch.
Rack::Request accepts invalid Host characters, enabling host allowlist bypass
Real-World Exposure
rack💎rackReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects RubyGems packages — download data is not available via public APIs for these ecosystems.
Description
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: [email protected], 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:
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:
[email protected]
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:
req.host.start_with?("myapp.com")
accepts:
[email protected]
and:
req.host.end_with?("myapp.com")
accepts:
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
Hostheader validation at the reverse proxy or load balancer. - Do not rely on prefix or suffix string checks such as
start_with?orend_with?for host allowlisting. - Use exact host allowlists, or exact subdomain boundary checks, after validating that the host is syntactically valid.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 💎RubyGems | rack | ≥ 3.0.0.beta1&&< 3.1.21 | 3.1.21 |
| 💎RubyGems | rack | ≥ 3.2.0&&< 3.2.6 | 3.2.6 |
Research use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for rack. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.
Fix
Update rack to 3.1.21 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-g2pf-xv49-m2h5 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 pinpoints whether GHSA-g2pf-xv49-m2h5 is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.
Tailored to GHSA-g2pf-xv49-m2h5. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-g2pf-xv49-m2h5 in your dependencies?
O3 detects GHSA-g2pf-xv49-m2h5 across RubyGems dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.