BUG/MAJOR: h2: verify that :path starts with a '/' before concatenating it
authorWilly Tarreau <w@1wt.eu>
Tue, 10 Aug 2021 14:30:55 +0000 (16:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 17 Aug 2021 08:37:14 +0000 (10:37 +0200)
commiteb2535f5bd3f315839d431d3996aed7bfad85cbb
treeccec18e346edb7af000236aa06f8b8ea453b2730
parent41a27122e6bd8635522da8006998c9f1af98d31c
BUG/MAJOR: h2: verify that :path starts with a '/' before concatenating it

Tim Düsterhus found that while the H2 path is checked for non-emptiness,
invalid chars and '*', a test is missing to verify that except for '*',
it always starts with exactly one '/'. During the reconstruction of the
full URI when passing to HTX, this missing test allows to affect the
apparent authority by appending a port number or a suffix name.

This only affects H2-to-H2 communications, as H2-to-H1 do not use the
full URI. Like for previous fix, the following rule inserted before
other ones in the frontend is sufficient to renormalize the internal
URI and let haproxy see the same authority as the target server:

    http-request set-uri %[url]

This needs to be backported to 2.2. Earlier versions do not rebuild a
full URI using the authority and will fail on the malformed path at the
HTTP layer, so they are safe.

(cherry picked from commit 4b8852c70d8c4b7e225e24eb58258a15eb54c26e)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 6c6b9a5f6de8f13a2242fedfb8c9eb1d5fe51db9)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/h2.c