diff options
| author | Ankur Tyagi <ankur.tyagi85@gmail.com> | 2026-01-25 14:24:02 +1300 |
|---|---|---|
| committer | Anuj Mittal <anuj.mittal@oss.qualcomm.com> | 2026-01-26 10:04:49 +0530 |
| commit | cb4570120b0d033c728a788e04b7c75129529a4e (patch) | |
| tree | 9256184df58feb0c233b346a09957b8f80f56f43 /meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41810.patch | |
| parent | daacf501a1834d0a09b9fca20988b5e28e5bd173 (diff) | |
| download | meta-openembedded-cb4570120b0d033c728a788e04b7c75129529a4e.tar.gz | |
python3-twisted: patch CVE-2024-41810
Though nvd[1] mentions commit[2] as part of the fix for CVE-2024-41671, but
it is actually a fix[3] for CVE-2024-41810.
Rename patch files accordingly.
[1] https://nvd.nist.gov/vuln/detail/CVE-2024-41671
[2] https://github.com/twisted/twisted/commit/046a164f89a0f08d3239ecebd750360f8914df33
[3] https://nvd.nist.gov/vuln/detail/CVE-2024-41810
Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
Signed-off-by: Anuj Mittal <anuj.mittal@oss.qualcomm.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41810.patch')
| -rw-r--r-- | meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41810.patch | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41810.patch b/meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41810.patch new file mode 100644 index 0000000000..e41d9667f0 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-twisted/CVE-2024-41810.patch | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | From 046a164f89a0f08d3239ecebd750360f8914df33 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Adi Roiban <adiroiban@gmail.com> | ||
| 3 | Date: Mon Jul 29 14:28:03 2024 +0100 | ||
| 4 | Subject: [PATCH] Merge commit from fork | ||
| 5 | |||
| 6 | Added HTML output encoding the "URL" parameter of the "redirectTo" function | ||
| 7 | |||
| 8 | CVE: CVE-2024-41810 | ||
| 9 | |||
| 10 | Upstream-Status: Backport [https://github.com/twisted/twisted/commit/046a164f89a0f08d3239ecebd750360f8914df33] | ||
| 11 | |||
| 12 | Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com> | ||
| 13 | |||
| 14 | Dropped newsfragements change from the original commit. | ||
| 15 | |||
| 16 | Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com> | ||
| 17 | --- | ||
| 18 | src/twisted/web/_template_util.py | 2 +- | ||
| 19 | src/twisted/web/test/test_util.py | 39 ++++++++++++++++++++++++++++++- | ||
| 20 | 2 files changed, 39 insertions(+), 2 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/src/twisted/web/_template_util.py b/src/twisted/web/_template_util.py | ||
| 23 | index 230c33f..7266079 100644 | ||
| 24 | --- a/src/twisted/web/_template_util.py | ||
| 25 | +++ b/src/twisted/web/_template_util.py | ||
| 26 | @@ -92,7 +92,7 @@ def redirectTo(URL: bytes, request: IRequest) -> bytes: | ||
| 27 | </body> | ||
| 28 | </html> | ||
| 29 | """ % { | ||
| 30 | - b"url": URL | ||
| 31 | + b"url": escape(URL.decode("utf-8")).encode("utf-8") | ||
| 32 | } | ||
| 33 | return content | ||
| 34 | |||
| 35 | diff --git a/src/twisted/web/test/test_util.py b/src/twisted/web/test/test_util.py | ||
| 36 | index 1e76300..9847dcb 100644 | ||
| 37 | --- a/src/twisted/web/test/test_util.py | ||
| 38 | +++ b/src/twisted/web/test/test_util.py | ||
| 39 | @@ -5,7 +5,6 @@ | ||
| 40 | Tests for L{twisted.web.util}. | ||
| 41 | """ | ||
| 42 | |||
| 43 | - | ||
| 44 | import gc | ||
| 45 | |||
| 46 | from twisted.internet import defer | ||
| 47 | @@ -64,6 +63,44 @@ class RedirectToTests(TestCase): | ||
| 48 | targetURL = "http://target.example.com/4321" | ||
| 49 | self.assertRaises(TypeError, redirectTo, targetURL, request) | ||
| 50 | |||
| 51 | + def test_legitimateRedirect(self): | ||
| 52 | + """ | ||
| 53 | + Legitimate URLs are fully interpolated in the `redirectTo` response body without transformation | ||
| 54 | + """ | ||
| 55 | + request = DummyRequest([b""]) | ||
| 56 | + html = redirectTo(b"https://twisted.org/", request) | ||
| 57 | + expected = b""" | ||
| 58 | +<html> | ||
| 59 | + <head> | ||
| 60 | + <meta http-equiv=\"refresh\" content=\"0;URL=https://twisted.org/\"> | ||
| 61 | + </head> | ||
| 62 | + <body bgcolor=\"#FFFFFF\" text=\"#000000\"> | ||
| 63 | + <a href=\"https://twisted.org/\">click here</a> | ||
| 64 | + </body> | ||
| 65 | +</html> | ||
| 66 | +""" | ||
| 67 | + self.assertEqual(html, expected) | ||
| 68 | + | ||
| 69 | + def test_maliciousRedirect(self): | ||
| 70 | + """ | ||
| 71 | + Malicious URLs are HTML-escaped before interpolating them in the `redirectTo` response body | ||
| 72 | + """ | ||
| 73 | + request = DummyRequest([b""]) | ||
| 74 | + html = redirectTo( | ||
| 75 | + b'https://twisted.org/"><script>alert(document.location)</script>', request | ||
| 76 | + ) | ||
| 77 | + expected = b""" | ||
| 78 | +<html> | ||
| 79 | + <head> | ||
| 80 | + <meta http-equiv=\"refresh\" content=\"0;URL=https://twisted.org/"><script>alert(document.location)</script>\"> | ||
| 81 | + </head> | ||
| 82 | + <body bgcolor=\"#FFFFFF\" text=\"#000000\"> | ||
| 83 | + <a href=\"https://twisted.org/"><script>alert(document.location)</script>\">click here</a> | ||
| 84 | + </body> | ||
| 85 | +</html> | ||
| 86 | +""" | ||
| 87 | + self.assertEqual(html, expected) | ||
| 88 | + | ||
| 89 | |||
| 90 | class ParentRedirectTests(SynchronousTestCase): | ||
| 91 | """ | ||
| 92 | -- | ||
| 93 | 2.40.0 | ||
