PT-2026-29913 · Rubygems · Rack
Publicado
2026-04-02
·
Atualizado
2026-04-02
CVSS v3.1
4.8
Média
| Vetor | AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N |
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
/xThe 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.comApplications 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.comand:
ruby
req.host.end with?("myapp.com")accepts:
text
evil.com/myapp.comWhen 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.
Exploit
Correção
Encontrou algum problema na descrição? Tem algo a acrescentar? Fique à vontade para nos escrever 👾
Enumeração de Fraquezas
Identificadores relacionados
Produtos afetados
Rack