]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: h3: reject frames with truncated header
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 24 Sep 2026 16:06:02 +0000 (18:06 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 7 Oct 2026 08:41:18 +0000 (10:41 +0200)
The following patch ensures that H3 frames with a truncated payload are
now properly rejected with H3_FRAME_ERROR.

  86a4ebc761a278838e8cb06f3a292282ba704c65
  BUG/MAJOR: h3: reject H3 truncated frames

However, this fix is not complete as it did not detect H3 frame
truncated at the header boundary. This happens when one of the two
fields varint cannot be decoded and FIN is reported as well.

This patch corrects this by reporting a connection error H3_FRAME_ERROR
in this condition. This allows to quickly teardown the connection
instead of waiting for the stream timeout without any error.

This must be backported to all stable releases.

src/h3.c

index 2768c779ab99dd2fd9dd2138104a1ee2103c3890..c0d310d96811cb67bb00af15e82dc415cfa00a0d 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -1984,6 +1984,13 @@ static ssize_t h3_rcv_buf(struct qcs *qcs, struct buffer *b, int fin)
                        /* Switch to a new frame. */
                        size_t hlen = h3_decode_frm_header(&ftype, &flen, b);
                        if (!hlen) {
+                               if (fin) {
+                                       TRACE_ERROR("truncated H3 frame header", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
+                                       qcc_set_error(qcs->qcc, H3_ERR_FRAME_ERROR, 1, muxc_tevt_type_proto_err);
+                                       qcc_report_glitch(qcs->qcc, 1);
+                                       goto err;
+                               }
+
                                TRACE_PROTO("pause parsing on incomplete frame header", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
                                break;
                        }