summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch
diff options
context:
space:
mode:
authorSoumya Sambu <soumya.sambu@windriver.com>2024-08-25 18:41:03 +0000
committerArmin Kuster <akuster808@gmail.com>2024-08-25 15:15:10 -0400
commit1235dd4ed4a57e67683c045ad76b6a0f9e896b45 (patch)
tree65920197df4ef699c5a8fb83b369a8e2a443714f /meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch
parent399b7b9051bb985dc37850c153a1029e1d3491bd (diff)
downloadmeta-openembedded-1235dd4ed4a57e67683c045ad76b6a0f9e896b45.tar.gz
python3-twisted: Fix CVE-2024-41671
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 <soumya.sambu@windriver.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch b/meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch
new file mode 100644
index 0000000000..1f6bf6bbfc
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41671-0001.patch
@@ -0,0 +1,89 @@
1From 046a164f89a0f08d3239ecebd750360f8914df33 Mon Sep 17 00:00:00 2001
2From: Adi Roiban <adiroiban@gmail.com>
3Date: Mon Jul 29 14:28:03 2024 +0100
4Subject: [PATCH] Merge commit from fork
5
6Added HTML output encoding the "URL" parameter of the "redirectTo" function
7
8CVE: CVE-2024-41671
9
10Upstream-Status: Backport [https://github.com/twisted/twisted/commit/046a164f89a0f08d3239ecebd750360f8914df33]
11
12Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
13---
14 src/twisted/web/_template_util.py | 2 +-
15 src/twisted/web/test/test_util.py | 39 ++++++++++++++++++++++++++++++-
16 2 files changed, 39 insertions(+), 2 deletions(-)
17
18diff --git a/src/twisted/web/_template_util.py b/src/twisted/web/_template_util.py
19index 230c33f..7266079 100644
20--- a/src/twisted/web/_template_util.py
21+++ b/src/twisted/web/_template_util.py
22@@ -92,7 +92,7 @@ def redirectTo(URL: bytes, request: IRequest) -> bytes:
23 </body>
24 </html>
25 """ % {
26- b"url": URL
27+ b"url": escape(URL.decode("utf-8")).encode("utf-8")
28 }
29 return content
30
31diff --git a/src/twisted/web/test/test_util.py b/src/twisted/web/test/test_util.py
32index 1e76300..9847dcb 100644
33--- a/src/twisted/web/test/test_util.py
34+++ b/src/twisted/web/test/test_util.py
35@@ -5,7 +5,6 @@
36 Tests for L{twisted.web.util}.
37 """
38
39-
40 import gc
41
42 from twisted.internet import defer
43@@ -64,6 +63,44 @@ class RedirectToTests(TestCase):
44 targetURL = "http://target.example.com/4321"
45 self.assertRaises(TypeError, redirectTo, targetURL, request)
46
47+ def test_legitimateRedirect(self):
48+ """
49+ Legitimate URLs are fully interpolated in the `redirectTo` response body without transformation
50+ """
51+ request = DummyRequest([b""])
52+ html = redirectTo(b"https://twisted.org/", request)
53+ expected = b"""
54+<html>
55+ <head>
56+ <meta http-equiv=\"refresh\" content=\"0;URL=https://twisted.org/\">
57+ </head>
58+ <body bgcolor=\"#FFFFFF\" text=\"#000000\">
59+ <a href=\"https://twisted.org/\">click here</a>
60+ </body>
61+</html>
62+"""
63+ self.assertEqual(html, expected)
64+
65+ def test_maliciousRedirect(self):
66+ """
67+ Malicious URLs are HTML-escaped before interpolating them in the `redirectTo` response body
68+ """
69+ request = DummyRequest([b""])
70+ html = redirectTo(
71+ b'https://twisted.org/"><script>alert(document.location)</script>', request
72+ )
73+ expected = b"""
74+<html>
75+ <head>
76+ <meta http-equiv=\"refresh\" content=\"0;URL=https://twisted.org/&quot;&gt;&lt;script&gt;alert(document.location)&lt;/script&gt;\">
77+ </head>
78+ <body bgcolor=\"#FFFFFF\" text=\"#000000\">
79+ <a href=\"https://twisted.org/&quot;&gt;&lt;script&gt;alert(document.location)&lt;/script&gt;\">click here</a>
80+ </body>
81+</html>
82+"""
83+ self.assertEqual(html, expected)
84+
85
86 class ParentRedirectTests(SynchronousTestCase):
87 """
88--
892.40.0