new file mode 100644
@@ -0,0 +1,222 @@
+From b3a3520f173b6f5f80b7e5c532e10f4dc20126c7 Mon Sep 17 00:00:00 2001
+From: Benoit Chesneau <bchesneau@gmail.com>
+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 <braychur@cisco.com>
+---
+ 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
+
@@ -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
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 <braychur@cisco.com> --- .../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