]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: tcpcheck: fix out-of-bounds reads on truncated LDAP bind responses
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 10:42:17 +0000 (11:42 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 13:23:52 +0000 (14:23 +0100)
commita62a434a10ea58e5b6026360b97c26bc5e6bbc55
tree3252c63e20bc67080ba09320e6222db661f43929
parentd4e3269b00d3feddf240d269594184fecb532423
BUG/MINOR: tcpcheck: fix out-of-bounds reads on truncated LDAP bind responses

The LDAP health-check relies on the min-recv parameter of the expect rule
matching the first byte of the bind response to guarantee enough data are
received before parsing the message. But this parameter is only honored
while data are still expected: on a FIN or a connection error, the last read
is already reached and the rule is evaluated on the received data only. A
truncated response may thus be parsed with fewer bytes than the parser
assumes:

  - With a single byte received, the message size is read one byte past
    the received data.
  - With a message announcing a size lower than 4, the 4-byte comparison
    on the message ID and the bindResponse tag reads up to 3 bytes past
    the received data.

The bytes past the received data are stale buffer content: the parsing and
the check result are then driven by bytes never sent by the server.

The LDAP parser now validates the received data itself: the message size
must be received, and the message must be at least 5 bytes to cover the
message ID, the bindResponse tag and its length. Shorter responses are
reported as truncated.

It is a read past the received data, inside the check buffer, so it requires
a non-compliant server, which is out of the threat model (servers are
trusted). There is no security impact, only a check status that depends on
stale data.

It should be backported to all supported versions.

(Reported-by: Gleb Lizunov)
reg-tests/checks/ldap-check.vtc
src/tcpcheck.c