python3-twisted: patch CVE-2022-24801
PATCH 1/5 python3-twisted: patch CVE-2022-24801
Details: https://nvd.nist.gov/vuln/detail/CVE-2022-24801
Pick the commits from the pull request that is referenced by the NVD report.
(The full set is consisting of 13 patches, but the ones that only updated news/readme/typo fixes in comments were not backported)
--- .../python3-twisted/CVE-2022-24801-1.patch | 132 ++++++++++++++++++ .../python3-twisted/CVE-2022-24801-2.patch | 63 +++++++++ .../python3-twisted/CVE-2022-24801-3.patch | 25 ++++ .../python3-twisted/CVE-2022-24801-4.patch | 25 ++++ .../python3-twisted/CVE-2022-24801-5.patch | 71 ++++++++++ .../python3-twisted/CVE-2022-24801-6.patch | 129 +++++++++++++++++ .../python3-twisted/CVE-2022-24801-7.patch | 27 ++++ .../python3-twisted/CVE-2022-24801-8.patch | 108 ++++++++++++++ .../python3-twisted/CVE-2022-24801-9.patch | 25 ++++ .../python/python3-twisted_22.2.0.bb | 16 ++- 10 files changed, 618 insertions(+), 3 deletions(-) create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-1.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-2.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-3.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-4.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-5.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-6.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-7.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-8.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-9.patch
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-1.patch new file +132 -0
@@ -0,0 +1,132 @@ +From 832a878c9c324ad23dde6cf16520b7768c1a8c5c Mon Sep 17 00:00:00 2001 +From: Tom Most <[email protected]> +Date: Sat, 5 Mar 2022 23:26:55 -0800 +Subject: [PATCH] Some tests for GHSA-c2jg-hw38-jrqq + +Upstream-Status: Backport [https://github.com/twisted/twisted/commit/22b067793cbcd0fb5dee04cfd9115fa85a7ca110] +CVE: CVE-2022-24801 +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/twisted/web/test/test_http.py | 102 ++++++++++++++++++++++++++++++ + 1 file changed, 102 insertions(+) + +diff --git a/src/twisted/web/test/test_http.py b/src/twisted/web/test/test_http.py +index 86c85d2..0549ed0 100644 +--- a/src/twisted/web/test/test_http.py ++++ b/src/twisted/web/test/test_http.py +@@ -1843,6 +1843,56 @@ class ParsingTests(unittest.TestCase): + [b"t \ta \tb"], + ) + ++ def test_headerStripWhitespace(self): ++ """ ++ Leading and trailing space and tab characters are stripped from ++ headers. Other forms of whitespace are preserved. ++ ++ See RFC 7230 section 3.2.3 and 3.2.4. ++ """ ++ processed = [] ++ ++ class MyRequest(http.Request): ++ def process(self): ++ processed.append(self) ++ self.finish() ++ ++ requestLines = [ ++ b"GET / HTTP/1.0", ++ b"spaces: spaces were stripped ", ++ b"tabs: \t\ttabs were stripped\t\t", ++ b"spaces-and-tabs: \t \t spaces and tabs were stripped\t \t", ++ b"line-tab: \v vertical tab was preserved\v\t", ++ b"form-feed: \f form feed was preserved \f ", ++ b"", ++ b"", ++ ] ++ ++ self.runRequest(b"\n".join(requestLines), MyRequest, 0) ++ [request] = processed ++ # All leading and trailing whitespace is stripped from the ++ # header-value. ++ self.assertEqual( ++ request.requestHeaders.getRawHeaders(b"spaces"), ++ [b"spaces were stripped"], ++ ) ++ self.assertEqual( ++ request.requestHeaders.getRawHeaders(b"tabs"), ++ [b"tabs were stripped"], ++ ) ++ self.assertEqual( ++ request.requestHeaders.getRawHeaders(b"spaces-and-tabs"), ++ [b"spaces and tabs were stripped"], ++ ) ++ self.assertEqual( ++ request.requestHeaders.getRawHeaders(b"line-tab"), ++ [b"\v vertical tab was preserved\v"], ++ ) ++ self.assertEqual( ++ request.requestHeaders.getRawHeaders(b"form-feed"), ++ [b"\f form feed was preserved \f"], ++ ) ++ + def test_tooManyHeaders(self): + """ + C{HTTPChannel} enforces a limit of C{HTTPChannel.maxHeaders} on the +@@ -2407,6 +2457,58 @@ Hello, + ] + ) + ++ def test_contentLengthMalformed(self): ++ """ ++ A request with a non-integer C{Content-Length} header fails with a 400 ++ response without calling L{Request.process}. ++ """ ++ self.assertRequestRejected( ++ [ ++ b"GET /a HTTP/1.1", ++ b"Content-Length: MORE THAN NINE THOUSAND!", ++ b"Host: host.invalid", ++ b"", ++ b"", ++ b"x" * 9001, ++ ] ++ ) ++ ++ def test_contentLengthTooPositive(self): ++ """ ++ A request with a C{Content-Length} header that begins with a L{+} fails ++ with a 400 response without calling L{Request.process}. ++ ++ This is a potential request smuggling vector: see GHSA-c2jg-hw38-jrqq. ++ """ ++ self.assertRequestRejected( ++ [ ++ b"GET /a HTTP/1.1", ++ b"Content-Length: +100", ++ b"Host: host.invalid", ++ b"", ++ b"", ++ b"x" * 100, ++ ] ++ ) ++ ++ def test_contentLengthNegative(self): ++ """ ++ A request with a C{Content-Length} header that is negative fails with ++ a 400 response without calling L{Request.process}. ++ ++ This is a potential request smuggling vector: see GHSA-c2jg-hw38-jrqq. ++ """ ++ self.assertRequestRejected( ++ [ ++ b"GET /a HTTP/1.1", ++ b"Content-Length: -100", ++ b"Host: host.invalid", ++ b"", ++ b"", ++ b"x" * 200, ++ ] ++ ) ++ + def test_duplicateContentLengthsWithPipelinedRequests(self): + """ + Two pipelined requests, the first of which includes multiple
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-2.patch new file +63 -0
63 lines not on this page · raw message
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-3.patch new file +25 -0
@@ -0,0 +1,25 @@ +From 5897923d523b357f93eb844e386bcc52c5490cdc Mon Sep 17 00:00:00 2001 +From: Tom Most <[email protected]> +Date: Mon, 7 Mar 2022 00:03:50 -0800 +Subject: [PATCH] Strip only spaces and tabs from header values + +Upstream-Status: Backport [https://github.com/twisted/twisted/commit/c3a4e1d015740c1d87a3ec7d57570257e75b0062] +CVE: CVE-2022-24801 +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/twisted/web/http.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/twisted/web/http.py b/src/twisted/web/http.py +index 5491953..262da0b 100644 +--- a/src/twisted/web/http.py ++++ b/src/twisted/web/http.py +@@ -2327,7 +2327,7 @@ class HTTPChannel(basic.LineReceiver, policies.TimeoutMixin): + return False + + header = header.lower() +- data = data.strip() ++ data = data.strip(b" \t") + + if not self._maybeChooseTransferDecoder(header, data): + return False
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-4.patch new file +25 -0
@@ -0,0 +1,25 @@ +From c6838374d0e323b78877ae546e1471c400e4652d Mon Sep 17 00:00:00 2001 +From: Tom Most <[email protected]> +Date: Mon, 7 Mar 2022 00:32:14 -0800 +Subject: [PATCH] Reject non-digit Content-Length + +Upstream-Status: Backport [https://github.com/twisted/twisted/commit/8ebfa8f6577431226e109ff98ba48f5152a2c416] +CVE: CVE-2022-24801 +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/twisted/web/http.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/twisted/web/http.py b/src/twisted/web/http.py +index 262da0b..5316d81 100644 +--- a/src/twisted/web/http.py ++++ b/src/twisted/web/http.py +@@ -2274,6 +2274,8 @@ class HTTPChannel(basic.LineReceiver, policies.TimeoutMixin): + + # Can this header determine the length? + if header == b"content-length": ++ if not data.isdigit(): ++ return fail() + try: + length = int(data) + except ValueError:
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-5.patch new file +71 -0
71 lines not on this page · raw message
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-6.patch new file +129 -0
129 lines not on this page · raw message
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-7.patch new file +27 -0
@@ -0,0 +1,27 @@ +From a2fd35cf03bd3a847fd47a6f1a812e359c2dafda Mon Sep 17 00:00:00 2001 +From: Tom Most <[email protected]> +Date: Sun, 13 Mar 2022 23:57:23 -0700 +Subject: [PATCH] Remove unreachable branch + +Upstream-Status: Backport [https://github.com/twisted/twisted/commit/696bfeaf5a1fa7ff952f860c89e2bdcfacef7d7a] +CVE: CVE-2022-24801 +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/twisted/web/http.py | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/src/twisted/web/http.py b/src/twisted/web/http.py +index 940ff9f..ea77f57 100644 +--- a/src/twisted/web/http.py ++++ b/src/twisted/web/http.py +@@ -1915,9 +1915,7 @@ class _ChunkedTransferDecoder: + except ValueError: + raise _MalformedChunkedDataError("Chunk-size must be an integer.") + +- if length < 0: +- raise _MalformedChunkedDataError("Chunk-size must not be negative.") +- elif length == 0: ++ if length == 0: + self.state = "TRAILER" + else: + self.state = "BODY"
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-8.patch new file +108 -0
108 lines not on this page · raw message
meta-python/recipes-devtools/python/python3-twisted/CVE-2022-24801-9.patch new file +25 -0
@@ -0,0 +1,25 @@ +From 349771026e1eb80cab7a19ceb8b80aa6d1bb3184 Mon Sep 17 00:00:00 2001 +From: Tom Most <[email protected]> +Date: Fri, 1 Apr 2022 20:47:59 -0700 +Subject: [PATCH] Address review feedback + +Upstream-Status: Backport [https://github.com/twisted/twisted/commit/2bbd6c89110f0d44d2bb109c14d787f65bca9df8] +CVE: CVE-2022-24801 +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/twisted/web/http.py | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/twisted/web/http.py b/src/twisted/web/http.py +index 81df437..4a2ce1d 100644 +--- a/src/twisted/web/http.py ++++ b/src/twisted/web/http.py +@@ -420,7 +420,7 @@ def _ishexdigits(b: bytes) -> bool: + for c in b: + if c not in b"0123456789abcdefABCDEF": + return False +- return bool(b) ++ return b != b"" + + + def _hexint(b: bytes) -> int:
meta-python/recipes-devtools/python/python3-twisted_22.2.0.bb +13 -3
@@ -12,9 +12,19 @@ SRC_URI[sha256sum] = "57f32b1f6838facb8c004c89467840367ad38e9e535f8252091345dba5 PYPI_PACKAGE = "Twisted" SRC_URI += "file://CVE-2024-41671-0001.patch \ - file://CVE-2024-41671-0002.patch \ - file://CVE-2024-41810.patch \ - file://CVE-2023-46137.patch" + file://CVE-2024-41671-0002.patch \ + file://CVE-2024-41810.patch \ + file://CVE-2023-46137.patch \ + file://CVE-2022-24801-1.patch \ + file://CVE-2022-24801-2.patch \ + file://CVE-2022-24801-3.patch \ + file://CVE-2022-24801-4.patch \ + file://CVE-2022-24801-5.patch \ + file://CVE-2022-24801-6.patch \ + file://CVE-2022-24801-7.patch \ + file://CVE-2022-24801-8.patch \ + file://CVE-2022-24801-9.patch \ + " inherit pypi python_setuptools_build_meta
PATCH 2/5 python3-django: fix intendation error in CVE patch
This change is for python3-django_2.2.28.
This patch contains an incorrect intendation, making the tests fail. This change fixes that.
--- .../python/python3-django/CVE-2024-41991.patch | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
meta-python/recipes-devtools/python/python3-django/CVE-2024-41991.patch +9 -9
@@ -95,15 +95,15 @@ index 5abab8d..1956655 100644 ), ('[email protected]', '<a href="mailto:[email protected]">[email protected]</a>'), ) -+ ( -+ "test@" + "한.글." * 15 + "aaa", -+ '<a href="mailto:test@' -+ + "xn--6q8b.xn--bj0b." * 15 -+ + 'aaa">' -+ + "test@" -+ + "한.글." * 15 -+ + "aaa</a>", -+ ), ++ ( ++ "test@" + "한.글." * 15 + "aaa", ++ '<a href="mailto:test@' ++ + "xn--6q8b.xn--bj0b." * 15 ++ + 'aaa">' ++ + "test@" ++ + "한.글." * 15 ++ + "aaa</a>", ++ ), for value, output in tests: with self.subTest(value=value): self.assertEqual(urlize(value), output)
PATCH 3/5 python3-django: fix CVE-2023-36053 patch
In reply to Gyorgy SarvariThis change is for python3-django_2.2.28.
The patch was accidentally backported incorrectly. The patch in general introduces a field-length restrictrion on the email input fields, however the patch was backported in a way that the restriction was applied on file input fields instead of email fields.
This change amends the patch in a way to restrict the email field.
--- .../python/python3-django/CVE-2023-36053.patch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
meta-python/recipes-devtools/python/python3-django/CVE-2023-36053.patch +6 -6
@@ -61,16 +61,16 @@ diff --git a/django/forms/fields.py b/django/forms/fields.py index a977256..f939338 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py -@@ -542,6 +542,9 @@ class FileField(Field): - def __init__(self, *, max_length=None, allow_empty_file=False, **kwargs): - self.max_length = max_length - self.allow_empty_file = allow_empty_file +@@ -523,6 +523,9 @@ class EmailField(CharField): + default_validators = [validators.validate_email] + + def __init__(self, **kwargs): + # The default maximum length of an email is 320 characters per RFC 3696 + # section 3. + kwargs.setdefault("max_length", 320) - super().__init__(**kwargs) + super().__init__(strip=True, **kwargs) + - def to_python(self, data): diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 6f76d0d..3a888ef 100644 --- a/docs/ref/forms/fields.txt
PATCH 4/5 python3-django: fix regression from CVE-2024-24680 patch
In reply to Gyorgy SarvariThis change is for python3-django_2.2.28.
The patch that mitigated CVE-2024-246680 accidentally also brought
a regression, some numbers were converted to (human-friendly) string incorrectly.
This backported patch mitigates this problem.
--- ...172-Fixed-intcomma-for-string-floats.patch | 30 +++++++++++++++++++ .../python/python3-django_2.2.28.bb | 1 + 2 files changed, 31 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-django/0001-Fixed-35172-Fixed-intcomma-for-string-floats.patch
meta-python/recipes-devtools/python/python3-django/0001-Fixed-35172-Fixed-intcomma-for-string-floats.patch new file +30 -0
@@ -0,0 +1,30 @@ +From 820af24fcaae817ab7c0733035673afc3b37eeac Mon Sep 17 00:00:00 2001 +From: Gyorgy Sarvari <[email protected]> +Date: Thu, 8 Feb 2024 10:58:54 +0100 +Subject: [PATCH] Fixed #35172 -- Fixed intcomma for string floats. + +From: Mariusz Felisiak <[email protected]> + +Thanks Warwick Brown for the report. + +Regression in 55519d6cf8998fe4c8f5c8abffc2b10a7c3d14e9. + +Upstream-Status: Backport [https://github.com/django/django/commit/2f14c2cedc9c92373471c1f98a80c81ba299584a] +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + django/contrib/humanize/templatetags/humanize.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py +index ee22a45..8490b5e 100644 +--- a/django/contrib/humanize/templatetags/humanize.py ++++ b/django/contrib/humanize/templatetags/humanize.py +@@ -77,6 +77,8 @@ def intcomma(value, use_l10n=True): + if match: + prefix = match[0] + prefix_with_commas = re.sub(r"\d{3}", r"\g<0>,", prefix[::-1])[::-1] ++ # Remove a leading comma, if needed. ++ prefix_with_commas = re.sub(r"^(-?),", r"\1", prefix_with_commas) + result = prefix_with_commas + result[len(prefix) :] + return result +
meta-python/recipes-devtools/python/python3-django_2.2.28.bb +1 -0
@@ -34,6 +34,7 @@ SRC_URI += "file://CVE-2023-31047.patch \ file://CVE-2025-64459.patch \ file://Fix-undefined-_lazy_re_compile.patch \ file://Fix-missing-JSONField-in-django.db.mo.patch \ + file://0001-Fixed-35172-Fixed-intcomma-for-string-floats.patch \ " SRC_URI[sha256sum] = "0200b657afbf1bc08003845ddda053c7641b9b24951e52acd51f6abda33a7413"
PATCH 5/5 python3-django: implement group method for FakeMatch
In reply to Gyorgy SarvariThis change is for python3-django_2.2.28.
This patch is an extension for CVE-2024-27351.patch. The class that patch introduced wasn't completely suitable for this version of the recipe, because it was accessing a function of it that was not implemented (the upstream version that introduced this class did not use that function, it is specific to this old version).
This patch adds the missing implementation to avoid errors.
--- ...implement-group-method-for-FakeMatch.patch | 42 +++++++++++++++++++ .../python/python3-django_2.2.28.bb | 1 + 2 files changed, 43 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-django/0001-implement-group-method-for-FakeMatch.patch
meta-python/recipes-devtools/python/python3-django/0001-implement-group-method-for-FakeMatch.patch new file +42 -0
@@ -0,0 +1,42 @@ +From c78be5dd9f1772a22f3094d8c2cfe56bfb45b122 Mon Sep 17 00:00:00 2001 +From: Gyorgy Sarvari <[email protected]> +Date: Wed, 14 Jan 2026 00:24:12 +0100 +Subject: [PATCH] implement group method for FakeMatch + +FakeMatch class was introduced in a backported CVE patch for this +recipe (CVE-2024-27351). These objects are later accessed in +django/utils/text.py module, in Truncator._truncate_html() method. +It is treated as a regex.search() object. + +This function, at the time when the upstream project introduced this +CVE patch was using array-style access, with brackets, so it +worked, because the FakeMatch class implements the __getitem__() +method. However in version 2.x, it was using group() access to +access the matches - which is not implemented for this class, making +these accesses fail: + +AttributeError: 'FakeMatch' object has no attribute 'group' + +To avoid this issue, this patch implements this method for this class. + +Upstream-Status: Inappropriate [Backport-specific] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + django/utils/text.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/django/utils/text.py b/django/utils/text.py +index e104b60..5033937 100644 +--- a/django/utils/text.py ++++ b/django/utils/text.py +@@ -66,6 +66,9 @@ class FakeMatch: + def __init__(self, text, end): + self._text, self._end = text, end + ++ def group(self, n): ++ return self[n] ++ + + # ----- End security-related performance workaround ----- +
meta-python/recipes-devtools/python/python3-django_2.2.28.bb +1 -0
@@ -35,6 +35,7 @@ SRC_URI += "file://CVE-2023-31047.patch \ file://Fix-undefined-_lazy_re_compile.patch \ file://Fix-missing-JSONField-in-django.db.mo.patch \ file://0001-Fixed-35172-Fixed-intcomma-for-string-floats.patch \ + file://0001-implement-group-method-for-FakeMatch.patch \ " SRC_URI[sha256sum] = "0200b657afbf1bc08003845ddda053c7641b9b24951e52acd51f6abda33a7413"