]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: tcpcheck: fix out-of-bounds reads on truncated SPOP hello frames
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 10:42:38 +0000 (11:42 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 13:23:52 +0000 (14:23 +0100)
commitb2a5bc68e77e100a6f7b32fc518cb4782d546c97
tree079bb1f2643cef0634a3f54c331fbb0c0906bdd5
parenta62a434a10ea58e5b6026360b97c26bc5e6bbc55
BUG/MINOR: tcpcheck: fix out-of-bounds reads on truncated SPOP hello frames

The SPOP health-check parser reads the frame header, then dispatches on the
frame type with a read right after the 11-byte header, and decodes the K/V
items of the payload. Nothing prevents these reads to go past the received
data:

  - With a frame announcing no payload (flen == 0) and a received data
    exactly covering the header, the frame type is read one byte past
    the received data. It is fully deterministic and does not even
    require the connection to be closed by the server.
  - When a K/V item key name ends exactly at the end of the received
    data, the type byte of the item value is read one byte past it.
  - The frame length check may also overflow: it is computed as
    4 + flen on a 32-bit value read from the wire, which wraps for a
    length close to UINT32_MAX.

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 SPOP parser now validates the received data itself: a frame with no
payload is invalid (both the AGENT-HELLO and AGENT-DISCONNECT frames carry
at least one K/V item), the length comparison is made overflow-safe, and the
type byte of every K/V item value is only read when the payload is not fully
consumed. Truncated frames are reported as invalid instead of being parsed
from bytes never received.

It is a read past the received data, inside the check buffer, so it requires
a non-compliant agent, 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/spop-check.vtc
src/tcpcheck.c