]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: h3: reject interim responses ending the stream
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 19 Nov 2026 15:45:45 +0000 (16:45 +0100)
committerOlivier Houchard <cognet@ci0.org>
Thu, 19 Nov 2026 15:58:22 +0000 (16:58 +0100)
On the backend side, a HEADERS frame carrying a 1xx status with the FIN
bit is converted into an interim response ending the message with the
EOM flag, which the H1 and H2 muxes never do. The stream forwards it as
an interim response and the client then gets a 502 once the end of the
stream is reported, while such a response is malformed since a final
response must follow an interim one.

Let's reject it as a malformed response with H3_ERR_MESSAGE_ERROR, as
the H2 mux does with an END_STREAM flag on a 1xx response, so the client
only gets a 502.

This was introduced with the backend side support by commit f79effa30
("MINOR: h3: convert HTTP/3 response into HTX for backend side support")
in 3.3-dev2, so it must be backported to 3.3.

src/h3.c

index 514a1c1c882ae1dfcd7551e6d054d1d0c3d7ad36..49e847a91378a228e474190bc4ac0d5663e22a23 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -1422,6 +1422,15 @@ static ssize_t h3_resp_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
                goto out;
        }
 
+       /* a final response must follow an interim one */
+       if (h == 1 && fin) {
+               TRACE_ERROR("interim response ending the stream", H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);
+               h3s->err = H3_ERR_MESSAGE_ERROR;
+               qcc_report_glitch(qcs->qcc, 1);
+               len = -1;
+               goto out;
+       }
+
        sl = htx_add_stline(htx, HTX_BLK_RES_SL, flags, ist("HTTP/3.0"), status, ist(""));
        if (!sl) {
                TRACE_ERROR("cannot allocate HTX start-line", H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);