main/nginx: patch CVE-2023-44487

This commit is contained in:
J0WI 2023-10-10 23:22:21 +02:00 committed by omni
parent 83c24fa0e5
commit 0f8a8ec71d
2 changed files with 76 additions and 1 deletions

View File

@ -4,6 +4,8 @@
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
#
# secfixes:
# 1.22.1-r1:
# - CVE-2023-44487
# 1.22.1-r0:
# - CVE-2022-41741
# - CVE-2022-41742
@ -35,7 +37,7 @@ pkgname=nginx
# NOTE: Upgrade only to even-numbered versions (e.g. 1.14.z, 1.16.z)!
# Odd-numbered versions are mainline (development) versions.
pkgver=1.22.1
pkgrel=0
pkgrel=1
# Revision of nginx-tests to use for check().
_tests_hgrev=29f4d48b5b31
_njs_ver=0.7.5
@ -76,6 +78,7 @@ pkggroups="$_grp_ngx $_grp_www"
install="$pkgname.pre-install $pkgname.post-install $pkgname.pre-upgrade $pkgname.post-upgrade"
subpackages="$pkgname-debug $pkgname-doc $pkgname-openrc $pkgname-vim::noarch"
source="https://nginx.org/download/$pkgname-$pkgver.tar.gz
CVE-2023-44487.patch
$pkgname-tests-$_tests_hgrev.tar.gz::https://hg.nginx.org/nginx-tests/archive/$_tests_hgrev.tar.gz
$pkgname-njs-$_njs_ver.tar.gz::https://hg.nginx.org/njs/archive/$_njs_ver.tar.gz
nginx-dav-ext-module~pr-56.patch::https://github.com/arut/nginx-dav-ext-module/pull/56.patch
@ -467,6 +470,7 @@ getvar() {
sha512sums="
1d468dcfa9bbd348b8a5dc514ac1428a789e73a92384c039b73a51ce376785f74bf942872c5594a9fcda6bbf44758bd727ce15ac2395f1aa989c507014647dcc nginx-1.22.1.tar.gz
18b69643648119dfab45101bb9404be667aeb9d550aa3bc9706e63e7da1c2806106e9a6bbfb2d10bd57ef56b9b5b0b524059353ec30a51469b44641cb7dbd8a6 CVE-2023-44487.patch
0acd8bf9aedeabeef590909c83ad9057063b4d3165fe5e0b0ff2205df6e0d1b97f3fcfd27384a55b4816bbe975e93a737e58df9c6ee01baf7e46ceaabc43c64a nginx-tests-29f4d48b5b31.tar.gz
9f0dc6bda06a0db5a92c45b6d8048c2fbb4e2b43a10d050dd3b2de820da425367808d4262bfc8d8e60ed1350bdabb42d1611f373c3da8c88818e266c46f79c78 nginx-njs-0.7.5.tar.gz
4c7a94aaebbb69599b0067e74f9f3db54ec383ca9499292fec5b875bb0b5859aa11dc14cef5664c94dd54aba231f31e85feacddc49f7622aa4d0fdb38709b6e1 nginx-dav-ext-module~pr-56.patch

View File

@ -0,0 +1,71 @@
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1696940019 -10800
# Node ID cdda286c0f1b4b10f30d4eb6a63fefb9b8708ecc
# Parent 3db945fda515014d220151046d02f3960bcfca0a
HTTP/2: per-iteration stream handling limit.
To ensure that attempts to flood servers with many streams are detected
early, a limit of no more than 2 * max_concurrent_streams new streams per one
event loop iteration was introduced. This limit is applied even if
max_concurrent_streams is not yet reached - for example, if corresponding
streams are handled synchronously or reset.
Further, refused streams are now limited to maximum of max_concurrent_streams
and 100, similarly to priority_limit initial value, providing some tolerance
to clients trying to open several streams at the connection start, yet
low tolerance to flooding attempts.
diff -r 3db945fda515 -r cdda286c0f1b src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c Fri Sep 22 19:23:57 2023 +0400
+++ b/src/http/v2/ngx_http_v2.c Tue Oct 10 15:13:39 2023 +0300
@@ -347,6 +347,7 @@
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http2 read handler");
h2c->blocked = 1;
+ h2c->new_streams = 0;
if (c->close) {
c->close = 0;
@@ -1284,6 +1285,14 @@
goto rst_stream;
}
+ if (h2c->new_streams++ >= 2 * h2scf->concurrent_streams) {
+ ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
+ "client sent too many streams at once");
+
+ status = NGX_HTTP_V2_REFUSED_STREAM;
+ goto rst_stream;
+ }
+
if (!h2c->settings_ack
&& !(h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG)
&& h2scf->preread_size < NGX_HTTP_V2_DEFAULT_WINDOW)
@@ -1349,6 +1358,12 @@
rst_stream:
+ if (h2c->refused_streams++ > ngx_max(h2scf->concurrent_streams, 100)) {
+ ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
+ "client sent too many refused streams");
+ return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_NO_ERROR);
+ }
+
if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid, status) != NGX_OK) {
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
}
diff -r 3db945fda515 -r cdda286c0f1b src/http/v2/ngx_http_v2.h
--- a/src/http/v2/ngx_http_v2.h Fri Sep 22 19:23:57 2023 +0400
+++ b/src/http/v2/ngx_http_v2.h Tue Oct 10 15:13:39 2023 +0300
@@ -131,6 +131,8 @@
ngx_uint_t processing;
ngx_uint_t frames;
ngx_uint_t idle;
+ ngx_uint_t new_streams;
+ ngx_uint_t refused_streams;
ngx_uint_t priority_limit;
size_t send_window;