]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: tcpcheck: fix out-of-bounds read on the MySQL server version
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 10:16:25 +0000 (11:16 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 15:56:26 +0000 (16:56 +0100)
commitb4e427bda9073816767005d51f5b1ceaab73905b
tree91ccb176766744f7abd1a6042cf86422fd7500da
parentedaac42ff119b30163ccf651d5241655832af53a
BUG/MINOR: tcpcheck: fix out-of-bounds read on the MySQL server version

On success, the MySQL health-check stores the server version, read at offset
5 of the received buffer, as the check description. The version is a
NUL-terminated string, but nothing guarantees the string is terminated,
neither inside the received data nor past its end. And the version pointer
is directly passed to set_server_check_status(), which copies it with
strncpy() up to 127 bytes, stopping at the first NUL byte. With a
non-compliant server sending a handshake with an unterminated version and no
NUL byte in the rest of the received data, the copy reads past the received
data, into the remaining content of the buffer chunk, and the stale bytes
are disclosed in the check status, visible in the logs, the stats page and
'show servers state'.

To fix it, the version is bounded to the received data before being copied
into the check status, like the plugin name of an auth switch request. This
is a rework of the out-of-bounds reads fixed by 3bbfc3bd7 ('BUG/MINOR:
tcpcheck: fix out-of-bounds reads on short MySQL error packets'), which
covered the error packets but not the success path.

This is a read past the received data, so it requires a non-compliant
server, which is out of the threat model (servers are trusted). Thus there
is no security impact here, only a potential information leak in the check
status.

This patch should fix the issue #3596. It should be backported to all
supported versions.
reg-tests/checks/mysql-check.vtc
src/tcpcheck.c