[nginx] HTTP/2: improved window updates checking.

Maxim Dounin mdounin at mdounin.ru
Tue Nov 24 15:44:35 UTC 2026


details:   http://freenginx.org/hg/nginx/rev/7227e48681f7
branches:  stable-1.30
changeset: 9623:7227e48681f7
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Tue Nov 24 06:19:19 2026 +0300
description:
HTTP/2: improved window updates checking.

Window updates are now rejected as long as the current send window is
larger than NGX_HTTP_V2_MAX_WINDOW minus the window update sent by the
client, so no overflows or underflows are possible.  Additionally, the
check on the window update itself ensures it is no larger than the
maximum (which is not possible per protocol, so the check is provided
for clarity).

This ensures that window updates are properly rejected even if the
current send window happens to be larger than NGX_HTTP_V2_MAX_WINDOW for
some reason.

diffstat:

 src/http/v2/ngx_http_v2.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (27 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
@@ -2491,8 +2491,10 @@ ngx_http_v2_state_window_update(ngx_http
 
         stream = node->stream;
 
-        if (window > (size_t) (NGX_HTTP_V2_MAX_WINDOW - stream->send_window)) {
-
+        if (window > NGX_HTTP_V2_MAX_WINDOW
+            || stream->send_window
+               > (ssize_t) (NGX_HTTP_V2_MAX_WINDOW - window))
+        {
             ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
                           "client violated flow control for stream %ui: "
                           "received WINDOW_UPDATE frame "
@@ -2529,7 +2531,9 @@ ngx_http_v2_state_window_update(ngx_http
         return ngx_http_v2_state_complete(h2c, pos, end);
     }
 
-    if (window > NGX_HTTP_V2_MAX_WINDOW - h2c->send_window) {
+    if (window > NGX_HTTP_V2_MAX_WINDOW
+        || h2c->send_window > NGX_HTTP_V2_MAX_WINDOW - window)
+    {
         ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
                       "client violated connection flow control: "
                       "received WINDOW_UPDATE frame "


More information about the nginx-devel mailing list