]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: mux-h2: reject non-101 2xx responses to Extended CONNECT
authorOlivier Houchard <ohouchard@haproxy.com>
Mon, 23 Nov 2026 15:13:02 +0000 (16:13 +0100)
committerOlivier Houchard <cognet@ci0.org>
Mon, 23 Nov 2026 15:43:39 +0000 (16:43 +0100)
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.

src/mux_h2.c

index 60e438598a00966e516ec2c0395caf44c5fbddba..1bf9905daa710491f7ae41f57e5d36195af8b19e 100644 (file)
@@ -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;