]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: http: fix authority parsing for absolute-form URI with empty path master
authorMani Goyal <goyalmani709@gmail.com>
Wed, 12 Aug 2026 06:56:22 +0000 (12:26 +0530)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Aug 2026 08:39:35 +0000 (10:39 +0200)
commit778bba5d30dc08ea42332390227fdd20aaf038e7
treef0991f39e7b261d6ea3ba4183e4a507828c1d241
parent59690ae14281d155311cb5c373ddefb37923968d
BUG/MEDIUM: http: fix authority parsing for absolute-form URI with empty path

http_parse_authority() only stopped scanning at '/', not '?' or '#'.
For an absolute-form request-target with no path but a query string
(e.g. "http://host?token=..."), the authority scan ran to the end of
the URI and swallowed the query string into the authority. This
caused http_scheme_based_normalize() to see an empty path and append
'/' after the query string instead of between the host and the
query, corrupting the request on the wire. The same corruption
happens with a literal '#' in the request-target when HTTP
violations are tolerated (option accept-unsafe-violations-in-http-
request), since it is not rejected by the request-line parser in
that mode either.

Per RFC 3986 section 3.2, authority terminates at '/', '?', or '#',
or at the end of the URI, so also stop at these two delimiters.

Add cases to h1_host_normalization.vtc covering an empty path with a
query string, with and without a port needing normalization. Add a
new h1_authority_fragment_char.vtc covering the '#' terminator
specifically, since it requires accept-unsafe-violations-in-http-
request to reach the parser at all and doesn't belong in the shared
frontend used by the other host-normalization cases.

This should be backported to all stable versions.

Should fix issue #3460.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
reg-tests/http-messaging/h1_authority_fragment_char.vtc [new file with mode: 0644]
reg-tests/http-messaging/h1_host_normalization.vtc
src/http.c