From: Christopher Faulet Date: Tue, 1 Dec 2026 14:13:31 +0000 (+0100) Subject: BUG/MINOR: mux-fcgi: reject 1xx interim responses from a FCGI server X-Git-Url: https://git.kaiwu.me/web/http/static/%7B@url%7D?a=commitdiff_plain;h=b9ebe1dc5c389735409ae2a848a8b1abe3f4171b;p=haproxy.git BUG/MINOR: mux-fcgi: reject 1xx interim responses from a FCGI server There is no way to handle an interim (1xx) response from a FCGI server: the FCGI protocol has no notion of interim response, the request is fully processed before the response is emitted. If one was relayed as-is, the client would receive an orphan interim response followed by an error, without any final response. The H1 parser does not complete a 1xx message (no EOM, waiting for the final response), so such a response was previously forwarded to the HTX layer and then to the client if the application closed the connection without sending a final response: the client received a "100 Continue" with a bogus "status: 100" header, followed by a 502. Now the response is rejected as soon as the headers are parsed and the client only gets the 502. This may be backported to all supported versions. --- diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 14a8618f3..e6378f046 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -3556,6 +3556,7 @@ static size_t fcgi_strm_parse_headers(struct fcgi_strm *fstrm, struct h1m *h1m, struct buffer *buf, size_t *ofs, size_t max) { int ret; + struct htx_blk *blk; TRACE_ENTER(FCGI_EV_RSP_DATA|FCGI_EV_RSP_HDRS, fstrm->fconn->conn, fstrm, 0, (size_t[]){max}); ret = h1_parse_msg_hdrs(h1m, NULL, htx, buf, *ofs, max); @@ -3570,6 +3571,20 @@ static size_t fcgi_strm_parse_headers(struct fcgi_strm *fstrm, struct h1m *h1m, goto end; } + /* Reject 1xx interim responses. There is no way to handle an interim + * response from a FCGI server. + */ + blk = htx_get_head_blk(htx); + if (blk && htx_get_blk_type(blk) == HTX_BLK_RES_SL && + ((const struct htx_sl *)htx_get_blk_ptr(htx, blk))->info.res.status < 200) { + htx->flags |= HTX_FL_PARSING_ERROR; + TRACE_ERROR("1xx interim response not supported", FCGI_EV_RSP_DATA|FCGI_EV_RSP_HDRS|FCGI_EV_FSTRM_ERR, fstrm->fconn->conn, fstrm); + fcgi_strm_error(fstrm); + fcgi_strm_capture_bad_message(fstrm->fconn, fstrm, h1m, buf); + ret = 0; + goto end; + } + /* Reject any message with an unknown transfer-encoding. In fact if any * encoding other than "chunked". A 422-Unprocessable-Content is * returned for an invalid request, a 502-Bad-Gateway for an invalid