diff mbox series

[meta-webserver,wrynose,05/10] nginx: fix CVE-2026-118899

Message ID 20261125061529.2721522-5-hthakar@cisco.com
State New
Headers show
Series [meta-webserver,wrynose,01/10] nginx: fix CVE-2026-97205 | expand

Commit Message

From: Hetvi Thakar <hthakar@cisco.com>

This patch applies the upstream nginx stable backport for
CVE-2026-118899. The upstream fix commit is referenced in [1],
and the public CVE advisory is referenced in [2].
The individual backported commit links are recorded in the
embedded patch headers.

[1] https://github.com/nginx/nginx/commit/1b723277aa556ba4c6e40cc8f0f0b465e29c0a13
[2] https://ubuntu.com/security/CVE-2026-118899

Signed-off-by: Hetvi Thakar <hthakar@cisco.com>
---
 .../nginx/files/CVE-2026-118899_p1.patch      | 43 +++++++++++++++++++
 .../nginx/files/CVE-2026-118899_p2.patch      | 37 ++++++++++++++++
 .../recipes-httpd/nginx/nginx_1.28.3.bb       |  2 +
 .../recipes-httpd/nginx/nginx_1.29.7.bb       |  2 +
 4 files changed, 84 insertions(+)
 create mode 100644 meta-webserver/recipes-httpd/nginx/files/CVE-2026-118899_p1.patch
 create mode 100644 meta-webserver/recipes-httpd/nginx/files/CVE-2026-118899_p2.patch
diff mbox series

Patch

diff --git a/meta-webserver/recipes-httpd/nginx/files/CVE-2026-118899_p1.patch b/meta-webserver/recipes-httpd/nginx/files/CVE-2026-118899_p1.patch
new file mode 100644
index 0000000000..797e7a59e1
--- /dev/null
+++ b/meta-webserver/recipes-httpd/nginx/files/CVE-2026-118899_p1.patch
@@ -0,0 +1,43 @@ 
+From 1b723277aa556ba4c6e40cc8f0f0b465e29c0a13 Mon Sep 17 00:00:00 2001
+From: Maxim Dounin <mdounin@mdounin.ru>
+Date: Sat, 30 Mar 2024 05:06:59 +0300
+Subject: [PATCH] Request body: explicit handling of NGX_AGAIN.
+
+Request body reading indirectly uses the "do { c->recv() } while
+(c->read->ready)" form, which is not really correct, as for example with
+SSL c->read->ready may be still set when c->recv() returns NGX_AGAIN due
+to SSL_ERROR_WANT_WRITE (see 7351:2b5528023f6b), and therefore this form
+might be an infinite loop.
+
+Added explicit NGX_AGAIN handling for the sake of correctness.
+
+CVE: CVE-2026-118899
+Upstream-Status: Backport [https://github.com/nginx/nginx/commit/1b723277aa556ba4c6e40cc8f0f0b465e29c0a13]
+
+Signed-off-by: Elijah Zupancic <e.zupancic@f5.com>
+Origin: <https://freenginx.org/hg/nginx/rev/392e8e2fd22a8461e75a67d5d33d85c07974e1e3>
+Signed-off-by: Hetvi Thakar <hthakar@cisco.com>
+---
+ src/http/ngx_http_request_body.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
+index 93c69220c5..6e24131518 100644
+--- a/src/http/ngx_http_request_body.c
++++ b/src/http/ngx_http_request_body.c
+@@ -307,6 +307,7 @@ ngx_http_do_read_client_request_body(ngx_http_request_t *r)
+     c = r->connection;
+     rb = r->request_body;
+     flush = 1;
++    n = NGX_AGAIN;
+ 
+     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+                    "http read client request body");
+@@ -432,7 +433,7 @@ ngx_http_do_read_client_request_body(ngx_http_request_t *r)
+             break;
+         }
+ 
+-        if (!c->read->ready || rb->rest == 0) {
++        if (n == NGX_AGAIN || !c->read->ready || rb->rest == 0) {
+ 
+             clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+             ngx_add_timer(c->read, clcf->client_body_timeout);
diff --git a/meta-webserver/recipes-httpd/nginx/files/CVE-2026-118899_p2.patch b/meta-webserver/recipes-httpd/nginx/files/CVE-2026-118899_p2.patch
new file mode 100644
index 0000000000..3f524f15ad
--- /dev/null
+++ b/meta-webserver/recipes-httpd/nginx/files/CVE-2026-118899_p2.patch
@@ -0,0 +1,37 @@ 
+From d1640655f46c5a2d32fefc2c818583f203e47536 Mon Sep 17 00:00:00 2001
+From: Roman Arutyunyan <arut@nginx.com>
+Date: Tue, 27 Oct 2026 15:02:12 +0400
+Subject: [PATCH] HTTP/3: explicit handling of NGX_AGAIN
+
+Following the previous change, this change adds explicit handling
+of NGX_AGAIN while reading HTTP/3 request body for the sake of
+correctness.
+
+CVE: CVE-2026-118899
+Upstream-Status: Backport [https://github.com/nginx/nginx/commit/d1640655f46c5a2d32fefc2c818583f203e47536]
+
+Signed-off-by: Hetvi Thakar <hthakar@cisco.com>
+---
+ src/http/v3/ngx_http_v3_request.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
+index 7bb61311d9..2685af53f7 100644
+--- a/src/http/v3/ngx_http_v3_request.c
++++ b/src/http/v3/ngx_http_v3_request.c
+@@ -1351,6 +1351,7 @@ ngx_http_v3_do_read_client_request_body(ngx_http_request_t *r)
+     c = r->connection;
+     rb = r->request_body;
+     flush = 1;
++    n = NGX_AGAIN;
+ 
+     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+                    "http3 read client request body");
+@@ -1474,7 +1475,7 @@ ngx_http_v3_do_read_client_request_body(ngx_http_request_t *r)
+             break;
+         }
+ 
+-        if (!c->read->ready || rb->rest == 0) {
++        if (n == NGX_AGAIN || !c->read->ready || rb->rest == 0) {
+ 
+             clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+             ngx_add_timer(c->read, clcf->client_body_timeout);
diff --git a/meta-webserver/recipes-httpd/nginx/nginx_1.28.3.bb b/meta-webserver/recipes-httpd/nginx/nginx_1.28.3.bb
index d6a30764ab..5110a2a0f7 100644
--- a/meta-webserver/recipes-httpd/nginx/nginx_1.28.3.bb
+++ b/meta-webserver/recipes-httpd/nginx/nginx_1.28.3.bb
@@ -23,6 +23,8 @@  SRC_URI:append = " \
     file://CVE-2026-123640_p1.patch \
     file://CVE-2026-123640_p2.patch \
     file://CVE-2026-120967.patch \
+    file://CVE-2026-118899_p1.patch \
+    file://CVE-2026-118899_p2.patch \
 "
 
 LIC_FILES_CHKSUM = "file://LICENSE;md5=3dc49537b08b14c8b66ad247bb4c4593"
diff --git a/meta-webserver/recipes-httpd/nginx/nginx_1.29.7.bb b/meta-webserver/recipes-httpd/nginx/nginx_1.29.7.bb
index d38199ba49..c9e7a9095f 100644
--- a/meta-webserver/recipes-httpd/nginx/nginx_1.29.7.bb
+++ b/meta-webserver/recipes-httpd/nginx/nginx_1.29.7.bb
@@ -23,6 +23,8 @@  SRC_URI:append = " \
     file://CVE-2026-123640_p1.patch \
     file://CVE-2026-123640_p2.patch \
     file://CVE-2026-120967.patch \
+    file://CVE-2026-118899_p1.patch \
+    file://CVE-2026-118899_p2.patch \
 "
 
 # 1.28.x branch is the current stable branch, the recommended default