]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: mux-h1: never forward more data than announced in a chunk
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 19 Nov 2026 08:05:00 +0000 (09:05 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Nov 2026 13:50:40 +0000 (14:50 +0100)
commite582abe8ad24cd3e606b1939bf699b5d569f099f
treeda67929767c136868b8d8aecbd33831d175fc13f
parenta32e3c8bb84e19a3b3b3e1530e3ad8b8f2d7e3f9
BUG/MEDIUM: mux-h1: never forward more data than announced in a chunk

When a chunked message is sent and a new chunk is started in the zero-copy
path of h1_make_data(), the chunk size is taken from the <kop> hint of the
sedesc when it is set:

    h1m->curr_len = (h1s->sd->kop ? h1s->sd->kop : count);

<kop> is the known output payload length, and by contract it is a minimal
guarantee: at least this size will be forwarded. When it is set, the H1 mux
announces it as the size of the chunk and consumes it. 0 means the output
payload length is unknown, and in this case only the size of the data block
is announced.

But nothing checked that the data sent with the chunk did not exceed the
announced size: h1m->curr_len was blindly decremented, possibly wrapping,
and the remaining bytes of the block were emitted without any chunk framing.

Such a violation could be observed when a data filter was used on the
request, before the previous patch fixed its root: the <kip> hint was
forwarded to <kop> on a stream not committed to forward its data, and a
stale value could then be announced for a data block, possibly smaller than
the block itself.

The copy path already reported an error for messages with a content-length
when more data than announced was met. The same check is now done in the
zero-copy path, for chunked messages: report an error and close the stream
instead of silently emitting an unframed payload. This is a guard for extra
safety, on top of the previous patch which fixes the issue at its root, in
the stream connectors.

Both patches must be backported as far as 3.3. On the stable branches, this
one must be applied on top of the other one, otherwise valid messages may be
rejected when a data filter alters the payload size and a stale <kip> hint
was moved to <kop>.
src/mux_h1.c