From: Olivier Houchard Date: Mon, 23 Nov 2026 15:13:02 +0000 (+0100) Subject: BUG/MEDIUM: mux-h2: reject non-101 2xx responses to Extended CONNECT X-Git-Url: https://git.kaiwu.me/http/%22../static/%7B@url%7D?a=commitdiff_plain;h=ab845daab727f6f04017fe5155fc37b8a790fb98;p=haproxy.git BUG/MEDIUM: mux-h2: reject non-101 2xx responses to Extended CONNECT An Extended CONNECT (RFC8441) is converted to an upgrade request for an H1 server, and a 101 response is converted to a 200, meaning that the tunnel is established. But if the server ignores the upgrade and returns a regular 2xx, it was forwarded as-is, so the client considered the tunnel as established and took the payload for tunneled data. Let's handle such a response as an error, as is already done for a 101 without Extended CONNECT. This was introduced in 2.4 by commit efe2276a9 ("MEDIUM: mux_h2: generate Extended CONNECT response") and must be backported to all supported versions. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 60e438598..1bf9905da 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -6941,6 +6941,12 @@ static size_t h2s_snd_fhdrs(struct h2s *h2s, struct htx *htx) goto fail; } } + else if (unlikely(h2s->flags & H2_SF_EXT_CONNECT_RCVD) && + h2s->status >= 200 && h2s->status < 300) { + /* no 101 from the server: a 2xx would mean the tunnel is established */ + TRACE_ERROR("upgrade not performed by the server, reject the 2xx response to Extended CONNECT", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s); + goto fail; + } else if ((h2s->flags & H2_SF_BODY_TUNNEL) && h2s->status >= 300) { /* Abort the tunnel attempt */ h2s->flags &= ~H2_SF_BODY_TUNNEL;