]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: mux-fcgi: reject 1xx interim responses from a FCGI server
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 1 Dec 2026 14:13:31 +0000 (15:13 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 12:41:06 +0000 (13:41 +0100)
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.

src/mux_fcgi.c

index 14a8618f36b7426a91cad5fe787321f3d3aa4acf..e6378f046af5679d516d0ebc3a965fa372ee82e6 100644 (file)
@@ -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