python3-twisted: Fix CVE-2024-41671
PATCH 1/1 python3-twisted: Fix CVE-2024-41671
From: Soumya Sambu <[email protected]>
Twisted is an event-based framework for internet applications, supporting Python 3.6+. The HTTP 1.0 and 1.1 server provided by twisted.web could process pipelined HTTP requests out-of-order, possibly resulting in information disclosure. This vulnerability is fixed in 24.7.0rc1.
References:
https://nvd.nist.gov/vuln/detail/CVE-2024-41671
Upstream-patches:
https://github.com/twisted/twisted/commit/046a164f89a0f08d3239ecebd750360f8914df33
https://github.com/twisted/twisted/commit/4a930de12fb67e88fefcb8822104152f42b27abc
Signed-off-by Soumya Sambu <[email protected]>
--- .../python3-twisted/CVE-2024-41671-0001.patch | 89 +++++++ .../python3-twisted/CVE-2024-41671-0002.patch | 251 ++++++++++++++++++ .../python/python3-twisted_24.3.0.bb | 5 + 3 files changed, 345 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0002.patch
meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch new file +89 -0
@@ -0,0 +1,89 @@ +From 046a164f89a0f08d3239ecebd750360f8914df33 Mon Sep 17 00:00:00 2001 +From: Adi Roiban <[email protected]> +Date: Mon Jul 29 14:28:03 2024 +0100 +Subject: [PATCH] Merge commit from fork + +Added HTML output encoding the "URL" parameter of the "redirectTo" function + +CVE: CVE-2024-41671 + +Upstream-Status: Backport [https://github.com/twisted/twisted/commit/046a164f89a0f08d3239ecebd750360f8914df33] + +Signed-off-by: Soumya Sambu <[email protected]> +--- + src/twisted/web/_template_util.py | 2 +- + src/twisted/web/test/test_util.py | 39 ++++++++++++++++++++++++++++++- + 2 files changed, 39 insertions(+), 2 deletions(-) + +diff --git a/src/twisted/web/_template_util.py b/src/twisted/web/_template_util.py +index 230c33f..7266079 100644 +--- a/src/twisted/web/_template_util.py ++++ b/src/twisted/web/_template_util.py +@@ -92,7 +92,7 @@ def redirectTo(URL: bytes, request: IRequest) -> bytes: + </body> + </html> + """ % { +- b"url": URL ++ b"url": escape(URL.decode("utf-8")).encode("utf-8") + } + return content + +diff --git a/src/twisted/web/test/test_util.py b/src/twisted/web/test/test_util.py +index 1e76300..9847dcb 100644 +--- a/src/twisted/web/test/test_util.py ++++ b/src/twisted/web/test/test_util.py +@@ -5,7 +5,6 @@ + Tests for L{twisted.web.util}. + """ + +- + import gc + + from twisted.internet import defer +@@ -64,6 +63,44 @@ class RedirectToTests(TestCase): + targetURL = "http://target.example.com/4321" + self.assertRaises(TypeError, redirectTo, targetURL, request) + ++ def test_legitimateRedirect(self): ++ """ ++ Legitimate URLs are fully interpolated in the `redirectTo` response body without transformation ++ """ ++ request = DummyRequest([b""]) ++ html = redirectTo(b"https://twisted.org/", request) ++ expected = b""" ++<html> ++ <head> ++ <meta http-equiv=\"refresh\" content=\"0;URL=https://twisted.org/\"> ++ </head> ++ <body bgcolor=\"#FFFFFF\" text=\"#000000\"> ++ <a href=\"https://twisted.org/\">click here</a> ++ </body> ++</html> ++""" ++ self.assertEqual(html, expected) ++ ++ def test_maliciousRedirect(self): ++ """ ++ Malicious URLs are HTML-escaped before interpolating them in the `redirectTo` response body ++ """ ++ request = DummyRequest([b""]) ++ html = redirectTo( ++ b'https://twisted.org/"><script>alert(document.location)</script>', request ++ ) ++ expected = b""" ++<html> ++ <head> ++ <meta http-equiv=\"refresh\" content=\"0;URL=https://twisted.org/"><script>alert(document.location)</script>\"> ++ </head> ++ <body bgcolor=\"#FFFFFF\" text=\"#000000\"> ++ <a href=\"https://twisted.org/"><script>alert(document.location)</script>\">click here</a> ++ </body> ++</html> ++""" ++ self.assertEqual(html, expected) ++ + + class ParentRedirectTests(SynchronousTestCase): + """ +-- +2.40.0
meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0002.patch new file +251 -0
251 lines not on this page · raw message
meta-python/recipes-devtools/python/python3-twisted_24.3.0.bb +5 -0
@@ -6,6 +6,11 @@ HOMEPAGE = "https://twisted.org" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://LICENSE;md5=c1c5d2c2493b848f83864bdedd67bbf5" +SRC_URI += " \ + file://CVE-2024-41671-0001.patch \ + file://CVE-2024-41671-0002.patch \ +" + SRC_URI[sha256sum] = "6b38b6ece7296b5e122c9eb17da2eeab3d98a198f50ca9efd00fb03e5b4fd4ae" inherit pypi python_hatchling
Signature · 1 line
2.40.0