BUG/MAJOR: http/htx: prevent unbounded loop in http_manage_server_side_cookies
authorAndrew McDermott <aim@frobware.com>
Fri, 11 Feb 2022 18:26:49 +0000 (18:26 +0000)
committerSalvatore Bonaccorso <carnil@debian.org>
Sat, 23 Dec 2023 10:02:19 +0000 (11:02 +0100)
commit1a03b7933a347fbcdcd17be4540f50f49a560d7e
tree21fe886218c5ee964a59b7b32fa748c4d14cfb62
parent51e572b43982c2fa3ff3bb0943f0a077bbe3f4cb
BUG/MAJOR: http/htx: prevent unbounded loop in http_manage_server_side_cookies

Origin: https://git.haproxy.org/?p=haproxy-2.2.git;a=commit;h=eb1bdcb7cf6e7bd1690f7dcc6d97de3d79b54cdc
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2022-0711

Ensure calls to http_find_header() terminate. If a "Set-Cookie2"
header is found then the while(1) loop in
http_manage_server_side_cookies() will never terminate, resulting in
the watchdog firing and the process terminating via SIGABRT.

The while(1) loop becomes unbounded because an unmatched call to
http_find_header("Set-Cookie") will leave ctx->blk=NULL. Subsequent
calls to check for "Set-Cookie2" will now enumerate from the beginning
of all the blocks and will once again match on subsequent
passes (assuming a match first time around), hence the loop becoming
unbounded.

This issue was introduced with HTX and this fix should be backported
to all versions supporting HTX.

Many thanks to Grant Spence (gspence@redhat.com) for working through
this issue with me.

(cherry picked from commit bfb15ab34ead85f64cd6da0e9fb418c9cd14cee8)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit d8ce72f63e115fa0952e6a58e81c3d15dfc0a509)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 86032c309b1f42177826deaa39f7c26903a074ca)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3cd203d61609fd427234fdb4f793193980860348)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
Gbp-Pq: Name 0001-BUG-MAJOR-http-htx-prevent-unbounded-loop-in-http_ma.patch
src/http_ana.c