]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: mux-fcgi: prevent record-length truncation with large bufsize master
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Apr 2026 11:06:46 +0000 (13:06 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 10 Apr 2026 07:40:16 +0000 (09:40 +0200)
commit0aeae230560cab23c575ee611b35ad194880cb68
tree27c61e2e3d2bcf1e4039cd2cac654d492a1b2186
parente6c3660327f11787dddbc43c4efff4226ce88a54
BUG/MEDIUM: mux-fcgi: prevent record-length truncation with large bufsize

FCGI content_length is a 16-bit field but fcgi_set_record_size()
is called with size_t/uint32_t arguments. With tune.bufsize >= 65544
(legal; cfgparse-global.c only enforces <= INT_MAX-16), a single
HTX DATA block or accumulated outbuf can exceed 65535 bytes. The
implicit conversion to uint16_t silently truncates the length field
while b_add(mbuf, outbuf.data) writes the full body.

A client posting ~99000 bytes can craft the body so that bytes
after the truncated length are parsed by PHP-FPM as fresh FCGI
records on the connection: a smuggled BEGIN_REQUEST + PARAMS with
arbitrary SCRIPT_FILENAME / PHP_VALUE bypasses all haproxy ACLs.

Fix the zero-copy path by refusing it when the block exceeds 65535
bytes (falls through to copy). Fix the copy path by capping
outbuf.size to 65535 + header so the data-fill loop naturally
stops at the FCGI maximum and emits the rest in a subsequent record.

The PARAMS path at line 2084 is similarly affected but harder to
trigger (requires combined header+param size > 65535) and is
covered by the same outbuf.size cap pattern if applied there.

This patch must be backported to all stable versions.
src/mux_fcgi.c