From: Roman Arutyunyan Date: Thu, 17 Sep 2026 12:10:11 +0000 (+0400) Subject: HTTP/2: reset reusable connection status on stream creation X-Git-Tag: release-1.31.9~17 X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/%7B@url%7D?a=commitdiff_plain;h=2df48a501d0fb8212b7d39dffeeff5876332ba59;p=nginx.git HTTP/2: reset reusable connection status on stream creation Previously, an HTTP/2 connection could be reusable while having streams. This could result in an attempt to drain the connection while processing one if its streams, for example when connecting to an upstream. After recognizing that the connection has streams, an attempt to send the GOAWAY frame was made. On send failure, the connection was immediately closed and its pool released. This triggered a use-after-free up the stack. Having an HTTP/2 connection with streams registered as reusable became possible after 76672e650. A connection with no streams and a partial frame read from client was registered as reusable to avoid DoS attacks. So if a client sends only the first HEADERS frame byte, the connection becomes reusable. Later, when the remaining HEADERS bytes are received and a new stream is created, the reusable status is not reset until the connection becomes idle. Fix is to mark the connection non-reusable upon stream creation. Reported by Albert @ Vexera AI. --- diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c index b4297e929..c308bdfcb 100644 --- a/src/http/v2/ngx_http_v2.c +++ b/src/http/v2/ngx_http_v2.c @@ -3192,6 +3192,8 @@ ngx_http_v2_create_stream(ngx_http_v2_connection_t *h2c) h2c->processing++; + ngx_reusable_connection(h2c->connection, 0); + if (h2c->connection->read->timer_set) { ngx_del_timer(h2c->connection->read); }