From patchwork Fri Dec 4 07:23:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bansi Raychura X-Patchwork-Id: 107269 Received: from aer-iport-3.cisco.com (aer-iport-3.cisco.com [173.38.203.53]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.3035.1796369024722333477 for ; Thu, 03 Dec 2026 23:23:45 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=RdqZHZVv; spf=pass (domain: cisco.com, ip: 173.38.203.53, mailfrom: braychur@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=17775; q=dns/txt; s=iport01; t=1796369024; x=1797578624; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=vFyucTskPaEJCCjI/V/TgdHjnD+ia9zpGolGfXAiin4=; b=RdqZHZVvVeI9k89K2PPniRrF/rUr4Wb6tab4U+0OE65Ihtj8Cx6GdF4x mN/X+5LH+CSaSHmuyfx3V7CmjiyzBusWFkoAkDF/zayFegTVynBdXT8x3 XKj4T+s6wXfA/Dc6hi9G67Y6a/UvKubgrQM+nF3Ub+ZuwJfCKOrIfhmm8 xq1QkkXz72ML3pqfDJ3KhM9ih1jbm2yLKbeM62Z60a4vDzePfevgq7hdL ODDVksqk0WGgZZ3ycZ6rinrNx75l4S5uCgSq2hVTzNbp9dTyDTwyIBv2D fI48XtcY1cQoFnbXp2N737E/hq8/3Uuoz8I3TkIYsowubr5AWODA/AJFE Q==; X-CSE-ConnectionGUID: wz2lHSULTUSMoglejTx7ZA== X-CSE-MsgGUID: 6ZDBemBsSHmmfB9hIMAGRg== X-IPAS-Result: A0AcAAD3aBJr/9RK/pBaHAEBAQEBAQcBARIBAQQEAQGBfAcBAQsBghc/dWFCSYx0hziCIYt5hVuMWYF+DwEBAQ9EDQQBAYQ/RgKOJAImNAkOAQIEAwIDAQ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Hp0Lxh3wS mTuoVbVKBwfHsek6T+A/Fj9hs7qtAzBV9dHfFG/3rsw6LGJ/UQUEBAQWF6xrPW1h0L7V99BJ kg8/is1sbN081SmSNT4VRC0rHOI+BkGVLJt//YS4QyXj66R6AGDCy1dF3hKaccts4k9QjlCO kK1ou4FzAdH6NW9IU9xPJ/Nxd9uEUD59VM/WBI= IronPort-HdrOrdr: A9a23:UXiota6Zt2rUcsaqXQPXwPjXdLJyesId70hD6qkXc202TiX2ra 6TdZgguCMc6wxhO03I5+rgBEDoexq1nvRICOIqUotKMjOLhILRFuFfxLqn5SH8ECvj8eMY/6 Jhf69iTODUNzFB/KPHCM3SKadG/DFBm5rY4dvj8w== X-Talos-CUID: 9a23:Vjv4BWocekU9a8D5OSimm33mUd83KHn990r0H3KDLGFmTLCXdU/Pyooxxg== X-Talos-MUID: 9a23:uTxFVw4W2VuTx7HMh++++pTGxow20YiEBUUniq4mvsyKH31wGhK0ow64F9o= X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.29,78,1794873600"; d="scan'208";a="62230603" Received: from aer-l-core-11.cisco.com ([144.254.74.212]) by aer-iport-3.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 04 Dec 2026 07:23:42 +0000 Received: from sjc-ads-22316.cisco.com (sjc-ads-22316.cisco.com [171.70.24.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-11.cisco.com (Postfix) with ESMTPS id 65091180007D7 for ; Fri, 4 Dec 2026 07:23:42 +0000 (GMT) Received: by sjc-ads-22316.cisco.com (Postfix, from userid 1893719) id 173C9CC1288; Thu, 3 Dec 2026 23:23:41 -0800 (PST) From: Bansi Raychura To: openembedded-devel@lists.openembedded.org Subject: [meta-python][blacksail][PATCH 1/2] python3-gunicorn: fix CVE-2026-134820 Date: Thu, 3 Dec 2026 23:23:39 -0800 Message-Id: <20261204072340.1645263-1-braychur@cisco.com> X-Mailer: git-send-email 2.35.6 MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-22316.cisco.com [171.70.24.48];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 171.70.24.48, sjc-ads-22316.cisco.com X-Outbound-Node: aer-l-core-11.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 04 Dec 2026 07:23:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/134013 Backport the four Gunicorn 27.0.0 fixes for CVE-2026-134820 to 26.2.0. References [1] through [4] are in patch application order. NVD [5] lists [1], [3], and [4] and links to upstream PR [6]. That PR also contains [2], which tightens HTTP whitespace normalization in the Python ASGI and WSGI parsers. Gunicorn 26.2.0 contains the affected normalization, so [2] is needed for the full framing fix. It is also the immediate upstream parent of [3]. The python3-gunicorn package built successfully with this patch, and its ptest suite passed. [1] https://github.com/benoitc/gunicorn/commit/6f4c2193a7f68106c88635933c2be5772fae1f3d [2] https://github.com/benoitc/gunicorn/commit/a284791c0b03d752a6b2e3d1f176c6c80d5f70f2 [3] https://github.com/benoitc/gunicorn/commit/400f5ec95abf3aac0f1f0f0bc9a6a001660085c4 [4] https://github.com/benoitc/gunicorn/commit/8e00028d37261500557c04ceb68ae7de01f56a28 [5] https://nvd.nist.gov/vuln/detail/CVE-2026-134820 [6] https://github.com/benoitc/gunicorn/pull/3786 Signed-off-by: Bansi Raychura --- .../python3-gunicorn/CVE-2026-134820_p1.patch | 95 +++++++++++++++ .../python3-gunicorn/CVE-2026-134820_p2.patch | 107 +++++++++++++++++ .../python3-gunicorn/CVE-2026-134820_p3.patch | 79 +++++++++++++ .../python3-gunicorn/CVE-2026-134820_p4.patch | 109 ++++++++++++++++++ .../python/python3-gunicorn_26.2.0.bb | 4 + 5 files changed, 394 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p1.patch create mode 100644 meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p2.patch create mode 100644 meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p3.patch create mode 100644 meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p4.patch diff --git a/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p1.patch b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p1.patch new file mode 100644 index 0000000000..a74ed4e7fd --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p1.patch @@ -0,0 +1,95 @@ +From 93b91e5ae72061ff25b6847c66476ead96564862 Mon Sep 17 00:00:00 2001 +From: zayeem shaikh +Date: Wed, 14 Oct 2026 16:45:55 +0530 +Subject: [PATCH] reject whitespace between header name and colon in asgi + PythonProtocol + +CVE: CVE-2026-134820 +Upstream-Status: Backport [https://github.com/benoitc/gunicorn/commit/6f4c2193a7f68106c88635933c2be5772fae1f3d] + +Signed-off-by: Bansi Raychura +--- + gunicorn/asgi/parser.py | 10 ++++++- + tests/test_asgi_parser_validation.py | 41 ++++++++++++++++++++++++++++ + 2 files changed, 50 insertions(+), 1 deletion(-) + +diff --git a/gunicorn/asgi/parser.py b/gunicorn/asgi/parser.py +index 665088a..c1eecca 100644 +--- a/gunicorn/asgi/parser.py ++++ b/gunicorn/asgi/parser.py +@@ -580,7 +580,15 @@ class PythonProtocol: + if colon == -1: + raise InvalidHeader("Missing colon in header") + +- name = line[:colon].strip() ++ # RFC 9112 section 5.1: no whitespace is allowed between the field ++ # name and the colon, and a server must reject a message that has ++ # it. Do not strip the name: a stripped "Transfer-Encoding :" or a ++ # leading-space " Content-Length:" would be read as a framing header ++ # here while the WSGI parser (TOKEN_RE) and a well-behaved proxy ++ # reject or fold it, which desyncs the two and smuggles a request. ++ # _is_valid_token already rejects SP/HTAB, so leaving them in place ++ # makes such a name fail validation instead of being accepted. ++ name = line[:colon] + if not self._is_valid_token(name): + raise InvalidHeaderName(name.decode('latin-1')) + +diff --git a/tests/test_asgi_parser_validation.py b/tests/test_asgi_parser_validation.py +index 48d5d0b..06be6a9 100644 +--- a/tests/test_asgi_parser_validation.py ++++ b/tests/test_asgi_parser_validation.py +@@ -13,6 +13,7 @@ import pytest + from gunicorn.asgi.parser import ( + PythonProtocol, + InvalidHeader, ++ InvalidHeaderName, + InvalidChunkSize, + UnsupportedTransferCoding, + ParseError, +@@ -416,3 +417,43 @@ class TestMultipleTransferEncodingHeaders: + b"Transfer-Encoding: chunked\r\n" + b"\r\n" + ) ++ ++ ++class TestHeaderNameWhitespace: ++ """Whitespace between field name and colon must be rejected (RFC 9112 5.1).""" ++ ++ def test_space_before_colon_rejected(self): ++ """A space before the colon must not be stripped into a valid name.""" ++ parser = PythonProtocol() ++ ++ with pytest.raises(InvalidHeaderName): ++ parser.feed( ++ b"POST /test HTTP/1.1\r\n" ++ b"Host: localhost\r\n" ++ b"Transfer-Encoding : chunked\r\n" ++ b"\r\n" ++ ) ++ ++ def test_tab_before_colon_rejected(self): ++ """A tab before the colon must not be stripped into a valid name.""" ++ parser = PythonProtocol() ++ ++ with pytest.raises(InvalidHeaderName): ++ parser.feed( ++ b"POST /test HTTP/1.1\r\n" ++ b"Host: localhost\r\n" ++ b"Content-Length\t: 10\r\n" ++ b"\r\n" ++ ) ++ ++ def test_leading_whitespace_name_rejected(self): ++ """A leading-space line must not be accepted as a framing header.""" ++ parser = PythonProtocol() ++ ++ with pytest.raises(InvalidHeaderName): ++ parser.feed( ++ b"POST /test HTTP/1.1\r\n" ++ b"Host: localhost\r\n" ++ b" Content-Length: 10\r\n" ++ b"\r\n" ++ ) +-- +2.35.6 + diff --git a/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p2.patch b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p2.patch new file mode 100644 index 0000000000..cc2808ac58 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p2.patch @@ -0,0 +1,107 @@ +From febdfbf55f7cff318074e60960d227d6bb7b9c02 Mon Sep 17 00:00:00 2001 +From: aoright <102943475+aoright@users.noreply.github.com> +Date: Fri, 11 Sep 2026 16:17:51 +0800 +Subject: [PATCH] Fix HTTP request smuggling via unsafe whitespace stripping + +CVE: CVE-2026-134820 +Upstream-Status: Backport [https://github.com/benoitc/gunicorn/commit/a284791c0b03d752a6b2e3d1f176c6c80d5f70f2] + +Backport Changes: +- Fold in the upstream whitespace regression tests from + https://github.com/benoitc/gunicorn/commit/614508e5c4169d32fc294e3745e5bef9ffb52bb7. + The cited fix commit does not include tests. + +Signed-off-by: Bansi Raychura +--- + gunicorn/asgi/parser.py | 4 ++-- + gunicorn/http/message.py | 2 +- + tests/test_asgi_parser_validation.py | 14 ++++++++++++++ + tests/test_http.py | 15 +++++++++++++++ + 4 files changed, 32 insertions(+), 3 deletions(-) + +diff --git a/gunicorn/asgi/parser.py b/gunicorn/asgi/parser.py +index c1eecca..3c2abc2 100644 +--- a/gunicorn/asgi/parser.py ++++ b/gunicorn/asgi/parser.py +@@ -592,7 +592,7 @@ class PythonProtocol: + if not self._is_valid_token(name): + raise InvalidHeaderName(name.decode('latin-1')) + +- value = line[colon + 1:].strip() ++ value = line[colon + 1:].strip(b" \t") + if self._has_invalid_header_chars(value): + raise InvalidHeader("Invalid characters in header value") + +@@ -646,7 +646,7 @@ class PythonProtocol: + elif name == b'transfer-encoding': + # Properly parse comma-separated Transfer-Encoding values + # per RFC 9112 Section 6.1 +- vals = [v.strip() for v in value.split(b',')] ++ vals = [v.strip(b" \t") for v in value.split(b',')] + for val in vals: + val_lower = val.lower() + if val_lower == b'chunked': +diff --git a/gunicorn/http/message.py b/gunicorn/http/message.py +index a155cbb..c5ccbe9 100644 +--- a/gunicorn/http/message.py ++++ b/gunicorn/http/message.py +@@ -413,7 +413,7 @@ class Message(HeaderPolicy): + elif name == "TRANSFER-ENCODING": + # T-E can be a list + # https://datatracker.ietf.org/doc/html/rfc9112#name-transfer-encoding +- vals = [v.strip() for v in value.split(',')] ++ vals = [v.strip(" \t") for v in value.split(',')] + for val in vals: + if val.lower() == "chunked": + # DANGER: transfer codings stack, and stacked chunking is never intended +diff --git a/tests/test_asgi_parser_validation.py b/tests/test_asgi_parser_validation.py +index 06be6a9..74d0ff3 100644 +--- a/tests/test_asgi_parser_validation.py ++++ b/tests/test_asgi_parser_validation.py +@@ -262,6 +262,20 @@ class TestTransferEncodingValidation: + assert parser.is_complete + + ++ @pytest.mark.parametrize("ws", [b"\x0b", b"\x0c", b"\x85", b"\xa0"]) ++ def test_non_http_whitespace_rejected(self, ws): ++ """Only SP/HTAB are whitespace around Transfer-Encoding tokens.""" ++ parser = PythonProtocol() ++ ++ with pytest.raises(ParseError): ++ parser.feed( ++ b"POST /test HTTP/1.1\r\n" ++ b"Host: localhost\r\n" ++ b"Transfer-Encoding: chunked" + ws + b"\r\n" ++ b"\r\n" ++ b"0\r\n\r\n" ++ ) ++ + class TestChunkSizeValidation: + """Test strict validation of chunk sizes.""" + +diff --git a/tests/test_http.py b/tests/test_http.py +index f31e794..5fc859c 100644 +--- a/tests/test_http.py ++++ b/tests/test_http.py +@@ -480,3 +480,18 @@ def test_normal_response_unaffected(): + assert resp.response_length == 5 + resp.write(b"hello") + assert resp.sent == 5 ++ ++ ++@pytest.mark.parametrize("ws", [b"\x0b", b"\x0c", b"\x85", b"\xa0"]) ++def test_transfer_encoding_non_http_whitespace_rejected(ws): ++ """Only SP/HTAB are whitespace around Transfer-Encoding tokens.""" ++ from gunicorn.config import Config ++ from gunicorn.http.errors import UnsupportedTransferCoding ++ from gunicorn.http.parser import RequestParser ++ ++ cfg = Config() ++ cfg.set('http_parser', 'python') ++ data = (b"POST / HTTP/1.1\r\nHost: x\r\nTransfer-Encoding: chunked" + ws ++ + b"\r\n\r\n0\r\n\r\n") ++ with pytest.raises((InvalidHeader, UnsupportedTransferCoding)): ++ next(RequestParser(cfg, [data], None)) +-- +2.35.6 + diff --git a/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p3.patch b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p3.patch new file mode 100644 index 0000000000..d0db79f81f --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p3.patch @@ -0,0 +1,79 @@ +From b3ad3ac0c23cfff5591b9ab4a4398b34d983b49b Mon Sep 17 00:00:00 2001 +From: zayeem shaikh +Date: Tue, 6 Oct 2026 10:06:13 +0530 +Subject: [PATCH] require digits only in Content-Length in the asgi python + parser + +CVE: CVE-2026-134820 +Upstream-Status: Backport [https://github.com/benoitc/gunicorn/commit/400f5ec95abf3aac0f1f0f0bc9a6a001660085c4] + +Backport Changes: +- Retain the 26.2.0 ValueError-to-InvalidHeader handling after the digit + check so conversion failures remain parser errors. + +Signed-off-by: Bansi Raychura +--- + gunicorn/asgi/parser.py | 10 ++++++---- + tests/test_asgi_parser_validation.py | 15 ++++++++++++++- + 2 files changed, 20 insertions(+), 5 deletions(-) + +diff --git a/gunicorn/asgi/parser.py b/gunicorn/asgi/parser.py +index 3c2abc2..e6a12e9 100644 +--- a/gunicorn/asgi/parser.py ++++ b/gunicorn/asgi/parser.py +@@ -635,13 +635,15 @@ class PythonProtocol: + # Reject duplicate Content-Length headers (request smuggling vector) + if content_length is not None: + raise InvalidHeader("Duplicate Content-Length header") ++ # RFC 9110 section 8.6: Content-Length = 1*DIGIT. int() on ++ # its own also takes a sign and underscores, which a proxy ++ # framing by the same header will not. ++ if not value.isdigit(): ++ raise InvalidHeader("Invalid Content-Length value") + try: +- cl_value = int(value) ++ content_length = int(value) + except ValueError: + raise InvalidHeader("Invalid Content-Length value") +- if cl_value < 0: +- raise InvalidHeader("Negative Content-Length") +- content_length = cl_value + + elif name == b'transfer-encoding': + # Properly parse comma-separated Transfer-Encoding values +diff --git a/tests/test_asgi_parser_validation.py b/tests/test_asgi_parser_validation.py +index 74d0ff3..28b2597 100644 +--- a/tests/test_asgi_parser_validation.py ++++ b/tests/test_asgi_parser_validation.py +@@ -97,7 +97,7 @@ class TestDuplicateContentLength: + """Negative Content-Length must be rejected.""" + parser = PythonProtocol() + +- with pytest.raises(InvalidHeader, match="Negative Content-Length"): ++ with pytest.raises(InvalidHeader, match="Invalid Content-Length"): + parser.feed( + b"POST /test HTTP/1.1\r\n" + b"Host: localhost\r\n" +@@ -130,6 +130,19 @@ class TestDuplicateContentLength: + ) + + ++ @pytest.mark.parametrize("value", [b"+5", b"1_0"]) ++ def test_non_digit_cl_rejected(self, value): ++ """Content-Length is 1*DIGIT; forms int() alone would take are rejected.""" ++ parser = PythonProtocol() ++ ++ with pytest.raises(InvalidHeader, match="Invalid Content-Length"): ++ parser.feed( ++ b"POST /test HTTP/1.1\r\n" ++ b"Host: localhost\r\n" ++ b"Content-Length: " + value + b"\r\n" ++ b"\r\n" ++ ) ++ + class TestChunkedInHTTP10: + """Test rejection of chunked encoding in HTTP/1.0.""" + +-- +2.35.6 + diff --git a/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p4.patch b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p4.patch new file mode 100644 index 0000000000..ed63068c47 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134820_p4.patch @@ -0,0 +1,109 @@ +From 94bdf79fcc9df6c89fc552e6d707d102d7e5ed1e Mon Sep 17 00:00:00 2001 +From: zayeem shaikh +Date: Thu, 8 Oct 2026 22:07:26 +0530 +Subject: [PATCH] validate chunk data terminator is CRLF in PythonProtocol + +CVE: CVE-2026-134820 +Upstream-Status: Backport [https://github.com/benoitc/gunicorn/commit/8e00028d37261500557c04ceb68ae7de01f56a28] + +Signed-off-by: Bansi Raychura +--- + gunicorn/asgi/parser.py | 12 +++++++- + tests/test_asgi_parser_validation.py | 45 ++++++++++++++++++++++++++++ + 2 files changed, 56 insertions(+), 1 deletion(-) + +diff --git a/gunicorn/asgi/parser.py b/gunicorn/asgi/parser.py +index e6a12e9..e02a590 100644 +--- a/gunicorn/asgi/parser.py ++++ b/gunicorn/asgi/parser.py +@@ -103,6 +103,10 @@ class InvalidChunkExtension(ParseError): + """Invalid chunk extension per RFC 9112.""" + + ++class ChunkMissingTerminator(ParseError): ++ """Chunk data not followed by the required CRLF per RFC 9112.""" ++ ++ + # RFC 9110 section 5.3: fields whose grammar admits only a single member, so a + # second occurrence cannot be merged and makes the message ambiguous. Lowercase + # because that is how _finalize_headers() stores names. content-length belongs +@@ -811,9 +815,15 @@ class PythonProtocol: + self._chunk_state = 'crlf' + + elif self._chunk_state == 'crlf': +- # Skip CRLF after chunk data ++ # RFC 9112 7.1: chunk-data is terminated by CRLF. Accepting ++ # anything else here lets a peer frame the body one way while a ++ # strict upstream frames it another (request smuggling vector), ++ # so the two bytes must be exactly CRLF. + if len(self._buffer) < 2: + return False ++ if self._buffer[:2] != b'\r\n': ++ raise ChunkMissingTerminator( ++ "chunk data not terminated by CRLF") + del self._buffer[:2] # Skip \r\n + self._chunk_state = 'size' + +diff --git a/tests/test_asgi_parser_validation.py b/tests/test_asgi_parser_validation.py +index 28b2597..e80ceda 100644 +--- a/tests/test_asgi_parser_validation.py ++++ b/tests/test_asgi_parser_validation.py +@@ -15,6 +15,7 @@ from gunicorn.asgi.parser import ( + InvalidHeader, + InvalidHeaderName, + InvalidChunkSize, ++ ChunkMissingTerminator, + UnsupportedTransferCoding, + ParseError, + ) +@@ -484,3 +485,47 @@ class TestHeaderNameWhitespace: + b" Content-Length: 10\r\n" + b"\r\n" + ) ++ ++ ++class TestChunkTerminator: ++ """Test strict validation of the CRLF that terminates chunk data.""" ++ ++ def test_bad_chunk_terminator_rejected(self): ++ """Non-CRLF bytes after chunk data must be rejected, not skipped.""" ++ body_chunks = [] ++ parser = PythonProtocol( ++ on_body=lambda chunk: body_chunks.append(chunk), ++ ) ++ ++ parser.feed( ++ b"POST /test HTTP/1.1\r\n" ++ b"Host: localhost\r\n" ++ b"Transfer-Encoding: chunked\r\n" ++ b"\r\n" ++ ) ++ ++ # "hello" is 5 bytes, followed by "XX" instead of CRLF. A lax parser ++ # would treat "XX" as the terminator and keep reading "3\r\nABC..." ++ # as a second chunk, framing the body differently from a strict peer. ++ with pytest.raises(ChunkMissingTerminator): ++ parser.feed(b"5\r\nhelloXX3\r\nABC\r\n0\r\n\r\n") ++ ++ def test_valid_chunk_terminator_accepted(self): ++ """A proper CRLF terminator between chunks still works.""" ++ body_chunks = [] ++ parser = PythonProtocol( ++ on_body=lambda chunk: body_chunks.append(chunk), ++ ) ++ ++ parser.feed( ++ b"POST /test HTTP/1.1\r\n" ++ b"Host: localhost\r\n" ++ b"Transfer-Encoding: chunked\r\n" ++ b"\r\n" ++ b"5\r\nhello\r\n" ++ b"3\r\nABC\r\n" ++ b"0\r\n\r\n" ++ ) ++ ++ assert parser.is_complete ++ assert b"".join(body_chunks) == b"helloABC" +-- +2.35.6 + diff --git a/meta-python/recipes-devtools/python/python3-gunicorn_26.2.0.bb b/meta-python/recipes-devtools/python/python3-gunicorn_26.2.0.bb index e19be89360..1ec1c92809 100644 --- a/meta-python/recipes-devtools/python/python3-gunicorn_26.2.0.bb +++ b/meta-python/recipes-devtools/python/python3-gunicorn_26.2.0.bb @@ -11,6 +11,10 @@ CVE_PRODUCT = "gunicorn" SRC_URI += " \ file://run-ptest \ + file://CVE-2026-134820_p1.patch \ + file://CVE-2026-134820_p2.patch \ + file://CVE-2026-134820_p3.patch \ + file://CVE-2026-134820_p4.patch \ " # python-misc for wsgiref From patchwork Fri Dec 4 07:23:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bansi Raychura X-Patchwork-Id: 107270 Received: from aer-iport-1.cisco.com (aer-iport-1.cisco.com [173.38.203.51]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.3036.1796369026457032493 for ; Thu, 03 Dec 2026 23:23:47 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=WocnIT0m; spf=pass (domain: cisco.com, ip: 173.38.203.51, mailfrom: braychur@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=9832; q=dns/txt; s=iport01; t=1796369026; x=1797578626; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ZBPcsm/bCDWGsE+3cqj1aBkauJhEGW8HxC5TdWML/k0=; b=WocnIT0mIjS7g+x2K9TcPfOb1UlhMJfg3VWG1Ar9+nZiUgJBb6ntpMjR FdpsnkeMAeystg2A+LvsUy/G+KAifH7oSlRdTMUsAGaG9gyLiHcGJszsn XMCc0XDlpZWjN2E4eD+9JNZ5AJrvueP1K0COaWYR8MTkYW60+5AyBWdwg Z4vHY6hdcZNaMI69Gkj/8OZkTtFDgDARo4qQChQ9QsLasSUZgLKiBsUon DgM/3A5sFUZHxFMReSMracm9tX8jsrHuXC4zelBmSeTf5nSLew1lZoGVg NVJXoXXNg0QmU7OtELtihsTu2aDY27Bxbbmq3we4lNMVYwFUC0tXQIQ5Y Q==; X-CSE-ConnectionGUID: 35P54BzoQwGCxWjnq76Nmw== X-CSE-MsgGUID: +2ydj/F/RJup8avxNoamlg== X-IPAS-Result: A0AoAAD3aBJr/9VK/pBaHQEBAQEJARIBBQUBgXwIAQsBglZ1YUJJjHSHOIIhA4tmEJI0gX4PAQEBD0QNBAEBhD9GAo4kAiY0CQ4BAgQDAgMBAQEBAQEBAQEBAQEKAQEFAQEBAgEHBYEOE4ZPDZASAQIBAzIBGAE9HAMBAi8gCyMIEAmDAgGCOgM3AgERuHWCLIEBgykBPwJDUNhMDXKBaAELFAGBOAGFQYMAhSddGAGEficbgUlEgRWDaoEFgRpCAQGBOIZuBIMugVSNEQKBSIlVSIEeA1ksAVUTDQoLBwWBaAM1EioVbjIdgSM7F4EHGwYFgRyBHoESgQNbgSsm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ZSRFFG/Fw8P re+MjzuiWbtN98YhwdcJW7Scq9qBDnhPtICPcqXItKNTOO0ADDEGgh1/qB/9SKIULDH4BmuZ uIC5IfNPTASX5nkM39/A60V/wkwNWB7eSUoN229QYLcemvAJsQljuQzW2gYytLeDU= X-Talos-CUID: 9a23:XHlkAG02C6iPT3J78Yjpo7xfQZ0dLyH33nDpPGCTGVlrTqTKF3mV5/Yx X-Talos-MUID: 9a23:ri+JtwY8bBKz8OBT9GX9iDMlGoBSwbm2WEkTgbMBssyAOnkl X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.29,78,1794873600"; d="scan'208";a="64552633" Received: from aer-l-core-12.cisco.com ([144.254.74.213]) by aer-iport-1.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 04 Dec 2026 07:23:42 +0000 Received: from sjc-ads-22316.cisco.com (sjc-ads-22316.cisco.com [171.70.24.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-12.cisco.com (Postfix) with ESMTPS id 76E7518000210 for ; Fri, 4 Dec 2026 07:23:42 +0000 (GMT) Received: by sjc-ads-22316.cisco.com (Postfix, from userid 1893719) id 1C2AECC1289; Thu, 3 Dec 2026 23:23:41 -0800 (PST) From: Bansi Raychura To: openembedded-devel@lists.openembedded.org Subject: [meta-python][blacksail][PATCH 2/2] python3-gunicorn: fix CVE-2026-134821 Date: Thu, 3 Dec 2026 23:23:40 -0800 Message-Id: <20261204072340.1645263-2-braychur@cisco.com> X-Mailer: git-send-email 2.35.6 In-Reply-To: <20261204072340.1645263-1-braychur@cisco.com> References: <20261204072340.1645263-1-braychur@cisco.com> MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-22316.cisco.com [171.70.24.48];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 171.70.24.48, sjc-ads-22316.cisco.com X-Outbound-Node: aer-l-core-12.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 04 Dec 2026 07:23:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/134014 Backport the Gunicorn 27.0.0 fixes for CVE-2026-134821 to 26.2.0. The upstream fixes are in [1] and the public CVE record is in [2]. The embedded patches preserve individual commit provenance. The python3-gunicorn package built successfully with this patch, and its ptest suite passed. [1] https://github.com/benoitc/gunicorn/commit/3007d5240e55190f85fff7180168d5aaa8377f30 [2] https://nvd.nist.gov/vuln/detail/CVE-2026-134821 Signed-off-by: Bansi Raychura --- .../python3-gunicorn/CVE-2026-134821.patch | 222 ++++++++++++++++++ .../python/python3-gunicorn_26.2.0.bb | 1 + 2 files changed, 223 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134821.patch diff --git a/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134821.patch b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134821.patch new file mode 100644 index 0000000000..784dfedbc0 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134821.patch @@ -0,0 +1,222 @@ +From b3a3520f173b6f5f80b7e5c532e10f4dc20126c7 Mon Sep 17 00:00:00 2001 +From: Benoit Chesneau +Date: Sat, 7 Nov 2026 19:17:21 +0100 +Subject: [PATCH] asgi: bound lines that never get their CRLF + +PythonProtocol buffered a request line, header, chunk-size line or trailer +until a CRLF arrived, with no limit, and rescanned the whole buffer on every +read. Apply the request limits before the terminator, scan only new bytes, +and count trailer lines against limit_request_fields. + +CVE: CVE-2026-134821 +Upstream-Status: Backport [https://github.com/benoitc/gunicorn/commit/3007d5240e55190f85fff7180168d5aaa8377f30] + +Backport Changes: +- Backported upstream commit 3007d5240e55190f85fff7180168d5aaa8377f30. + The From hash identifies this adapted 26.2.0 backport commit. +- Adapt the line-limit tests to 26.2.0 using independent configured + and fallback bounds plus raw unterminated requests. + +Signed-off-by: Bansi Raychura +--- + gunicorn/asgi/parser.py | 51 +++++++++++++++++++++--- + tests/test_asgi_parser_validation.py | 59 ++++++++++++++++++++++++++++ + 2 files changed, 105 insertions(+), 5 deletions(-) + +diff --git a/gunicorn/asgi/parser.py b/gunicorn/asgi/parser.py +index e02a590..fb6af2d 100644 +--- a/gunicorn/asgi/parser.py ++++ b/gunicorn/asgi/parser.py +@@ -116,6 +116,12 @@ RFC9110_5_3_SINGLETON_FIELDS = frozenset(( + b'content-type', + )) + ++# Bounds used while waiting for a line terminator when the matching limit is ++# 0 (unlimited): the same values the WSGI parser and the C parser fall back to. ++MAX_UNLIMITED_REQUEST_LINE = 1024 * 1024 ++DEFAULT_MAX_FIELD_LINE = 8190 ++DEFAULT_MAX_FIELDS = 32768 ++ + + class PythonProtocol: + """Callback-based HTTP/1.1 parser (pure Python fallback). +@@ -142,7 +148,7 @@ class PythonProtocol: + '_chunk_state', '_chunk_size', '_chunk_remaining', + '_limit_request_line', '_limit_request_fields', '_limit_request_field_size', + '_permit_unconventional_http_method', '_permit_unconventional_http_version', +- '_header_count', ++ '_header_count', '_scan_from', + '_proxy_protocol', '_proxy_protocol_info', '_proxy_protocol_done', + ) + +@@ -175,6 +181,7 @@ class PythonProtocol: + self._permit_unconventional_http_method = permit_unconventional_http_method + self._permit_unconventional_http_version = permit_unconventional_http_version + self._header_count = 0 ++ self._scan_from = 0 + + # Proxy protocol + self._proxy_protocol = proxy_protocol +@@ -276,6 +283,7 @@ class PythonProtocol: + self._chunk_size = 0 + self._chunk_remaining = 0 + self._header_count = 0 ++ self._scan_from = 0 + + def finish(self): + """Mark parsing complete for EOF handling. +@@ -491,9 +499,31 @@ class PythonProtocol: + self._state = 'request_line' + return True + ++ def _find_line(self, limit, error): ++ """Return the index of the next CRLF in the buffer, or -1. ++ ++ Only bytes not scanned on a previous call are scanned again, and a ++ buffer that can no longer hold a line of at most ``limit`` bytes ++ raises ``error`` instead of growing until a terminator arrives. ++ """ ++ idx = self._buffer.find(b'\r\n', self._scan_from) ++ if idx == -1: ++ if len(self._buffer) > limit + 1: ++ raise error ++ # keep a trailing CR: it may be the start of the terminator ++ self._scan_from = max(len(self._buffer) - 1, 0) ++ return -1 ++ self._scan_from = 0 ++ return idx ++ ++ def _line_limit(self): ++ return self._limit_request_field_size or DEFAULT_MAX_FIELD_LINE ++ + def _parse_request_line(self): + """Parse request line, return True if complete.""" +- idx = self._buffer.find(b'\r\n') ++ idx = self._find_line( ++ self._limit_request_line or MAX_UNLIMITED_REQUEST_LINE, ++ LimitRequestLine("Request line is too large")) + if idx == -1: + return False + +@@ -558,7 +588,9 @@ class PythonProtocol: + def _parse_headers(self): + """Parse headers, return True if headers are complete.""" + while True: +- idx = self._buffer.find(b'\r\n') ++ idx = self._find_line( ++ self._line_limit(), ++ LimitRequestHeaders("Request header field is too large")) + if idx == -1: + return False + +@@ -757,7 +789,9 @@ class PythonProtocol: + while self._buffer: + if self._chunk_state == 'size': + # Looking for chunk size line +- idx = self._buffer.find(b'\r\n') ++ idx = self._find_line( ++ self._line_limit(), ++ InvalidChunkSize("chunk size line has no terminator")) + if idx == -1: + return False + +@@ -829,7 +863,9 @@ class PythonProtocol: + + elif self._chunk_state == 'trailer': + # Skip trailer headers +- idx = self._buffer.find(b'\r\n') ++ idx = self._find_line( ++ self._line_limit(), ++ LimitRequestHeaders("Request trailer field is too large")) + if idx == -1: + return False + +@@ -844,6 +880,11 @@ class PythonProtocol: + self._on_message_complete() + return True + ++ # Trailer lines count against the same field limit as headers. ++ self._header_count += 1 ++ if self._header_count > (self._limit_request_fields or DEFAULT_MAX_FIELDS): ++ raise LimitRequestHeaders("Too many trailer fields") ++ + # RFC 9110 section 6.5.1: reject fields that must not appear + # in trailers. + colon = line.find(b':') +diff --git a/tests/test_asgi_parser_validation.py b/tests/test_asgi_parser_validation.py +index e80ceda..6b7fa1d 100644 +--- a/tests/test_asgi_parser_validation.py ++++ b/tests/test_asgi_parser_validation.py +@@ -14,6 +14,7 @@ from gunicorn.asgi.parser import ( + PythonProtocol, + InvalidHeader, + InvalidHeaderName, ++ LimitRequestHeaders, + InvalidChunkSize, + ChunkMissingTerminator, + UnsupportedTransferCoding, +@@ -529,3 +530,61 @@ class TestChunkTerminator: + + assert parser.is_complete + assert b"".join(body_chunks) == b"helloABC" ++ ++ ++@pytest.mark.parametrize("limit", [0, 32]) ++@pytest.mark.parametrize("step, chunk_state, fallback, error_name", [ ++ ("_parse_request_line", None, 1_048_576, "LimitRequestLine"), ++ ("_parse_headers", None, 8190, "LimitRequestHeaders"), ++ ("_parse_chunked_body", "size", 8190, "InvalidChunkSize"), ++ ("_parse_chunked_body", "trailer", 8190, "LimitRequestHeaders"), ++]) ++def test_line_readers_enforce_bounds(limit, step, chunk_state, fallback, error_name): ++ from gunicorn.asgi import parser as parser_module ++ ++ protocol = PythonProtocol(limit_request_line=limit, limit_request_field_size=limit) ++ if chunk_state is not None: ++ protocol._chunk_state = chunk_state ++ # One extra byte may be the first byte of a split separator. ++ protocol._buffer = bytearray(b"X" * ((limit or fallback) + 1)) ++ read_line = getattr(protocol, step) ++ assert read_line() is False ++ ++ protocol._buffer.extend(b"X") ++ with pytest.raises(getattr(parser_module, error_name)): ++ read_line() ++ ++ ++@pytest.mark.parametrize("raw_request,error_name", [ ++ (b"X" * 34, "LimitRequestLine"), ++ (b"GET / HTTP/1.1\r\nHost: a\r\nX-Long: " + b"X" * 34, ++ "LimitRequestHeaders"), ++ (b"POST / HTTP/1.1\r\nHost: a\r\nTransfer-Encoding: chunked\r\n\r\n" ++ + b"F" * 34, "InvalidChunkSize"), ++ (b"POST / HTTP/1.1\r\nHost: a\r\nTransfer-Encoding: chunked\r\n\r\n" ++ b"0\r\nX-Long: " + b"X" * 34, "LimitRequestHeaders"), ++]) ++def test_unterminated_lines_rejected_from_requests(raw_request, error_name): ++ from gunicorn.asgi import parser as parser_module ++ ++ parser = PythonProtocol(limit_request_line=32, limit_request_field_size=32) ++ with pytest.raises(getattr(parser_module, error_name)): ++ parser.feed(raw_request) ++ ++ ++class TestUnterminatedLineBounds: ++ def test_trailer_count(self): ++ parser = PythonProtocol(limit_request_fields=10) ++ parser.feed(b"POST / HTTP/1.1\r\nHost: a\r\n" ++ b"Transfer-Encoding: chunked\r\n\r\n0\r\n") ++ with pytest.raises(LimitRequestHeaders): ++ for _ in range(20): ++ parser.feed(b"X: 1\r\n") ++ ++ def test_line_split_across_feeds(self): ++ """A terminator split between two reads is still found.""" ++ done = [] ++ parser = PythonProtocol(on_message_complete=lambda: done.append(1)) ++ for byte in b"GET / HTTP/1.1\r\nHost: a\r\n\r\n": ++ parser.feed(bytes([byte])) ++ assert done == [1] +-- +2.35.6 + diff --git a/meta-python/recipes-devtools/python/python3-gunicorn_26.2.0.bb b/meta-python/recipes-devtools/python/python3-gunicorn_26.2.0.bb index 1ec1c92809..b9c3d52667 100644 --- a/meta-python/recipes-devtools/python/python3-gunicorn_26.2.0.bb +++ b/meta-python/recipes-devtools/python/python3-gunicorn_26.2.0.bb @@ -15,6 +15,7 @@ SRC_URI += " \ file://CVE-2026-134820_p2.patch \ file://CVE-2026-134820_p3.patch \ file://CVE-2026-134820_p4.patch \ + file://CVE-2026-134821.patch \ " # python-misc for wsgiref