From patchwork Fri Dec 4 07:17: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: 107267 Received: from aer-iport-8.cisco.com (aer-iport-8.cisco.com [173.38.203.70]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.2952.1796368665002324359 for ; Thu, 03 Dec 2026 23:17: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=VOSqogUc; spf=pass (domain: cisco.com, ip: 173.38.203.70, mailfrom: braychur@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=9259; q=dns/txt; s=iport01; t=1796368665; x=1797578265; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=S+P+GsvUjugJ93TiliEiijzLQOzBG97YI/wiBeUr0nQ=; b=VOSqogUcg2DkeFR72dJTtcQ3U1MW4c0GWGx7YoDAoz8GqttNkc8NSfFc 9EFipL3qqQKub4MqNJT3GKVbafQrrQgcLAoa2w4aqG7l1wQZ1SNevvv+F fgb48dLYR3Ii8d9UrNh39jrWJnvFDVVT12wqgCF2B9pJQAaqCmLbkdcGB u882ODWhUOwDynIBrcgRCpruuSrvDxkVWVppvKw4r5AMogQuGXu8ONylm IwKp6wO1de/hhvdMPO0V//fng6QyMujqBA5BbBxs6hnf+VBk04QAi7oj5 NjA7ZOppvrElRbVweHJTriIeSh1facR0M44xakTF+KgzLh+QvqeOCDkK5 g==; X-CSE-ConnectionGUID: 6DVi9ABSRt6ruhNFznKr/g== X-CSE-MsgGUID: v8GOQYyyTqGAzCWWCOwS5A== X-IPAS-Result: A0AcAAC0ZxJr/85K/pBaHAEBAQEBAQcBARIBAQQEAQGBfAcBAQsBglZ1YUJJjHSHOIIhA4ETilMQkjSBfg8BAQEPRA0EAQGEP0YCjiQCJjQJDgECBAMCAwEBAQE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Tu4TTWJSgrJc2j0BWs4FmTucToghimcddHfFG/3rsw6LGJ/UQUEBAQWF6xrPW1h0L7V99BJ kg8/is1sbN081SmSNT4VRC0rHOI+BkGVLJt//YS4QyXj66R6AGDCy1cE3hKaccts4k9QjlCO kK1ou4FzAdH6NW9IU9xPJ/Nxd9uEUD59VM/WBI= IronPort-HdrOrdr: A9a23:KU7zlaGs9pdJnnHmpLqExMeALOsnbusQ8zAXPidKOHhom6Oj+f xG8M536fawskdzZJhCo6HkBED/exLhHPdOiOF7V4tKHjOW2ldAR7sM0WKN+VHd8lXFltJ15O NHb7V0DsH2ABxRiMb35xT9LvMbqeP3l5xBQYzlvg5QpcYAUdAH0ztE X-Talos-CUID: 9a23:kSpatGAjlu9ONef6E3dLyk9FM+oeSGGD1mrQBWGqD0VzD7LAHA== X-Talos-MUID: 9a23:zTwa+AwNTjB1wGaGJGWkQSoni9WaqLr+J2c0oIQXh9CrHD5bBAi2qyuMH6Zyfw== X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.29,78,1794873600"; d="scan'208";a="61990927" Received: from aer-l-core-05.cisco.com ([144.254.74.206]) by aer-iport-8.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 04 Dec 2026 07:17:43 +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-05.cisco.com (Postfix) with ESMTPS id AFF3A1800020B for ; Fri, 4 Dec 2026 07:17:42 +0000 (GMT) Received: by sjc-ads-22316.cisco.com (Postfix, from userid 1893719) id 61513CC1289; Thu, 3 Dec 2026 23:17:41 -0800 (PST) From: Bansi Raychura To: openembedded-devel@lists.openembedded.org Subject: [meta-python][wrynose][PATCH 2/2] python3-gunicorn: fix CVE-2026-134821 Date: Thu, 3 Dec 2026 23:17:40 -0800 Message-Id: <20261204071740.1640834-2-braychur@cisco.com> X-Mailer: git-send-email 2.35.6 In-Reply-To: <20261204071740.1640834-1-braychur@cisco.com> References: <20261204071740.1640834-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-05.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:17:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/134011 Backport the Gunicorn 27.0.0 fixes for CVE-2026-134821 to 25.3.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 | 217 ++++++++++++++++++ .../python/python3-gunicorn_25.3.0.bb | 1 + 2 files changed, 218 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..70e952c982 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-gunicorn/CVE-2026-134821.patch @@ -0,0 +1,217 @@ +From 0c7614b60a153bf0a4f400b419191dddc1d69e1e 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: +- Check configured and disabled-limit fallback bounds with raw requests; + retain upstream trailer-count and split-read regression cases. +- Insert the bounds constants after the exception declarations because + 25.3.0 lacks the newer request-target constant. Preserve the same + two blank lines before the parser class, adding one separator line + relative to the upstream diff. + +Signed-off-by: Bansi Raychura +--- + gunicorn/asgi/parser.py | 52 +++++++++++++++++++++++++--- + tests/test_asgi_parser_validation.py | 51 +++++++++++++++++++++++++++ + 2 files changed, 98 insertions(+), 5 deletions(-) + +diff --git a/gunicorn/asgi/parser.py b/gunicorn/asgi/parser.py +index ed0ff4c..ed0744f 100644 +--- a/gunicorn/asgi/parser.py ++++ b/gunicorn/asgi/parser.py +@@ -94,6 +94,13 @@ class ChunkMissingTerminator(ParseError): + """Chunk data not followed by the required CRLF per RFC 9112.""" + + ++# 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). + +@@ -119,7 +126,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', + ) + +@@ -152,6 +159,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 +@@ -236,6 +244,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. +@@ -434,9 +443,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 + +@@ -490,7 +521,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 + +@@ -678,7 +711,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 + +@@ -750,7 +785,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 + +@@ -765,6 +802,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") ++ + return False + + def _is_valid_method(self, method): +diff --git a/tests/test_asgi_parser_validation.py b/tests/test_asgi_parser_validation.py +index 912aced..b3f2f06 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, ++ LimitRequestHeaders, + ChunkMissingTerminator, + UnsupportedTransferCoding, + ParseError, +@@ -529,3 +530,53 @@ class TestHeaderNameWhitespace: + b" Content-Length: 10\r\n" + b"\r\n" + ) ++ ++ ++@pytest.mark.parametrize("limit", [0, 32]) ++@pytest.mark.parametrize("kind, fallback, error_name", [ ++ ("request", 1_048_576, "LimitRequestLine"), ++ ("header", 8190, "LimitRequestHeaders"), ++ ("chunk-size", 8190, "InvalidChunkSize"), ++ ("trailer", 8190, "LimitRequestHeaders"), ++]) ++def test_unterminated_lines_rejected_from_request(limit, kind, fallback, error_name): ++ from gunicorn.asgi import parser as parser_module ++ ++ parser = PythonProtocol(limit_request_line=limit, limit_request_field_size=limit) ++ chunked = ( ++ b"POST / HTTP/1.1\r\n" ++ b"Transfer-Encoding: chunked\r\n\r\n" ++ ) ++ if kind == "request": ++ prefix, line = b"", b"G" ++ elif kind == "header": ++ prefix, line = b"GET / HTTP/1.1\r\n", b"X:" ++ elif kind == "chunk-size": ++ prefix, line = chunked, b"a" ++ else: ++ prefix, line = chunked + b"0\r\n", b"X:" ++ ++ bound = limit or fallback ++ parser.feed(prefix + line + b"a" * (bound + 1 - len(line))) ++ assert not parser.is_complete ++ with pytest.raises(getattr(parser_module, error_name)): ++ parser.feed(b"a") ++ ++ ++ ++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_25.3.0.bb b/meta-python/recipes-devtools/python/python3-gunicorn_25.3.0.bb index 39ef057e1b..4bd067932c 100644 --- a/meta-python/recipes-devtools/python/python3-gunicorn_25.3.0.bb +++ b/meta-python/recipes-devtools/python/python3-gunicorn_25.3.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