]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: h3: properly encode response after interim one in same buf
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 21 Oct 2025 13:06:39 +0000 (15:06 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 21 Oct 2025 13:51:48 +0000 (15:51 +0200)
commitbece70412810b47e5eb98eda059252bf535b2992
treef522d507b68da46ff7a6fcaa88d92b6351a81805
parent18ece2b4249956cb759552ff831d3822b664f223
BUG/MEDIUM: h3: properly encode response after interim one in same buf

Recently, proper support for interim responses forwarding to HTTP/3
client has been implemented. However, there was still an issue if two
responses are both encoded in the same snd_buf() iteration.

The issue is caused due to H3 HEADERS frame encoding method : 5 bytes
are reserved in front of the buffer to encode both H3 frame type and
varint length field. After proper headers encoding, output buffer head
is adjusted so that length can be encoded using the minimal varint size.

However, if the buffer is not empty due to a previous response already
encoded but not yet emitted, messing with the buffer head will corrupt
the entire H3 message. This only happens when encoding of both responses
is done in the same snd_buf() iteration, or at least without emission to
quic_conn layer in between.

The result of this bug is that the HTTP/3 client will be unable to parse
the response, most of the time reporting a formatting error. This can
be reproduced using the following netcat as HTTP/1 server to haproxy :

$ while sleep 0.2; do \
    printf "HTTP/1.1 100 continue\r\n\r\nHTTP/1.1 200 ok\r\nContent-length: 5\r\nConnection: close\r\n\r\nblah\n" | nc -lp8002
  done

To fix this, only adjust buffer head if content is empty. If this is not
the case, frame length is simply encoded as a 4-bytes varint size so
that messages are contiguous in the buffer.

This must be backported up to 2.6.
src/h3.c