[nginx] HTTP/2: reset reusable connection status on stream creat...
Maxim Dounin
mdounin at mdounin.ru
Tue Nov 24 15:44:04 UTC 2026
details: http://freenginx.org/hg/nginx/rev/a0a8537a9e7b
branches:
changeset: 9612:a0a8537a9e7b
user: Roman Arutyunyan <arut at nginx.com>
date: Thu Sep 17 16:10:11 2026 +0400
description:
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.
Obtained from:
https://github.com/nginx/nginx/commit/2df48a501d0fb8212b7d39dffeeff5876332ba59
diffstat:
src/http/v2/ngx_http_v2.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diffs (12 lines):
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -3158,6 +3158,8 @@ ngx_http_v2_create_stream(ngx_http_v2_co
h2c->processing++;
+ ngx_reusable_connection(h2c->connection, 0);
+
h2c->priority_limit += h2scf->concurrent_streams;
if (h2c->connection->read->timer_set) {
More information about the nginx-devel
mailing list