]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: h1: reject absolute http(s) URIs with an empty host
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Oct 2026 14:05:00 +0000 (16:05 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Oct 2026 17:10:27 +0000 (19:10 +0200)
commit4aa4c3d27b622f9da3910c548ff6b2027a21e5f4
tree05ecee46c3c7d5b9d66b226b3a348cb162db43e8
parent30dd1c05f5d73f4d9f753b3e6f93208a9260d1d1
BUG/MEDIUM: h1: reject absolute http(s) URIs with an empty host

An absolute-form request target with the http or https scheme and an empty
host was accepted and forwarded verbatim to H1 servers, for instance:

    GET http:///admin.internal/x HTTP/1.1\r\n\r\n
    GET http://:8080/x HTTP/1.1\r\n\r\n
    GET http://@/x HTTP/1.1\r\n\r\n

RFC9110#4.2.1 says that a recipient must reject such URIs as invalid. Here
the rules see an empty host (or ":8080") and the path "/admin.internal/x",
while servers relying on WHATWG-style URL parsers (e.g. NodeJS) take
"admin.internal" as the host and "/x" as the path. It's a parser
differential that may be used to bypass host or path based rules, depending
on the server.

Let's reject these requests, unless unsafe violations are accepted (then the
error is only captured). A reg-test was added for this.

Note that the "strange cases" C32 to C35 of the h1_host_normalization
reg-test explicitly verified that "GET http://:" with "host: :80" (or
"https://:" and "host: :443" / "host: :") were accepted and normalized to
"http:///" with an empty host. These cases are now rejected with a 400, so
the test was updated accordingly. Developers may want to double-check that
there was no other reason to accept them.

The validation of the request target was introduced by commit 25bcdb1d9
("BUG/MAJOR: h1: Be stricter on request target validation during message
parsing") in 3.0-dev12, which didn't cover this case. This should be
backported as far as 3.0.
doc/configuration.txt
reg-tests/http-messaging/h1_absolute_uri_empty_host.vtc [new file with mode: 0644]
reg-tests/http-messaging/h1_host_normalization.vtc
src/h1.c