]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: payload: fix handshake length off-by-4 in ssl_hello_sni/alpn
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 13 Aug 2026 15:52:25 +0000 (15:52 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 13 Aug 2026 15:54:54 +0000 (17:54 +0200)
commit8f507ae7530bf43b9c0a5604c3c8d97c4e8f8a9a
treef0bd650d8571566b2cc66679a1451054b2dbe946
parent431b6b1cd92a54f4a53b66a5ff27a64381ff9a23
BUG/MINOR: payload: fix handshake length off-by-4 in ssl_hello_sni/alpn

smp_fetch_ssl_hello_sni() and smp_fetch_ssl_hello_alpn() each have
their own copy of the ClientHello preamble parser instead of using the
shared smp_client_hello_parse(). The handshake length ("hs_len") is
compared against "bleft" before "bleft" is decremented for the 4-byte
handshake header (msg_type + 3-byte length), so a ClientHello claiming
a body up to 4 bytes larger than what was actually sent is still
accepted as complete. Every subsequent length-derived bound inherits
this same 4-byte over-count, letting the final read (SNI hostname or
ALPN protocol name) run up to 4 bytes past the received buffer and
disclose uninitialized memory through req.ssl_sni / req.ssl_alpn.

This is the same issue already fixed in smp_client_hello_parse() by
commit 2653936510 ("BUG/MINOR: payload: fix the handshake length
bounds check smp_client_hello_parse()"), just never ported to these
two functions' own duplicated preamble. This applies the same fix:
"data += 4" now comes with "bleft -= 4" before the length check
instead of after it, and the record-layer length is checked as soon
as the handshake is entered.

This must be backported to all supported versions.
src/payload.c