summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarpat Mali <narpat.mali@windriver.com>2023-09-26 11:24:28 +0000
committerArmin Kuster <akuster808@gmail.com>2023-09-27 10:23:14 -0400
commitab9a31fabcb959129798644cdac61e4606daf75c (patch)
tree781c679ac21f8547592e10e13fd6929800c2bdc9
parentb25e6a9e9111cbc0fc71e0e96c560c5cd2ee845d (diff)
downloadmeta-openembedded-ab9a31fabcb959129798644cdac61e4606daf75c.tar.gz
python3-django: fix CVE-2023-41164
In Django 3.2 before 3.2.21, 4 before 4.1.11, and 4.2 before 4.2.5, ``django.utils.encoding.uri_to_iri()`` was subject to potential denial of service attack via certain inputs with a very large number of Unicode characters. Since, there is no ptest available for python3-django so have not tested the patch changes at runtime. References: https://security-tracker.debian.org/tracker/CVE-2023-41164 https://www.djangoproject.com/weblog/2023/sep/04/security-releases/ Signed-off-by: Narpat Mali <narpat.mali@windriver.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-python/recipes-devtools/python/python3-django/CVE-2023-41164.patch105
-rw-r--r--meta-python/recipes-devtools/python/python3-django_2.2.28.bb1
2 files changed, 106 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-django/CVE-2023-41164.patch b/meta-python/recipes-devtools/python/python3-django/CVE-2023-41164.patch
new file mode 100644
index 0000000000..9bc38b0cca
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-django/CVE-2023-41164.patch
@@ -0,0 +1,105 @@
1From 9c95e8fec62153f8dfcc45a70b8a68d74333a66f Mon Sep 17 00:00:00 2001
2From: Mariusz Felisiak <felisiak.mariusz@gmail.com>
3Date: Tue, 26 Sep 2023 10:23:30 +0000
4Subject: [PATCH] Fixed CVE-2023-41164 -- Fixed potential DoS in
5 django.utils.encoding.uri_to_iri().
6
7Thanks MProgrammer (https://hackerone.com/mprogrammer) for the report.
8
9Co-authored-by: nessita <124304+nessita@users.noreply.github.com>
10
11CVE: CVE-2023-41164
12
13Upstream-Status: Backport [https://github.com/django/django/commit/3f41d6d62929dfe53eda8109b3b836f26645bdce]
14
15Signed-off-by: Narpat Mali <narpat.mali@windriver.com>
16---
17 django/utils/encoding.py | 6 ++++--
18 docs/releases/2.2.28.txt | 9 +++++++++
19 tests/utils_tests/test_encoding.py | 21 ++++++++++++++++++++-
20 3 files changed, 33 insertions(+), 3 deletions(-)
21
22diff --git a/django/utils/encoding.py b/django/utils/encoding.py
23index 98da647..3769702 100644
24--- a/django/utils/encoding.py
25+++ b/django/utils/encoding.py
26@@ -225,6 +225,7 @@ def repercent_broken_unicode(path):
27 repercent-encode any octet produced that is not part of a strictly legal
28 UTF-8 octet sequence.
29 """
30+ changed_parts = []
31 while True:
32 try:
33 path.decode()
34@@ -232,9 +233,10 @@ def repercent_broken_unicode(path):
35 # CVE-2019-14235: A recursion shouldn't be used since the exception
36 # handling uses massive amounts of memory
37 repercent = quote(path[e.start:e.end], safe=b"/#%[]=:;$&()+,!?*@'~")
38- path = path[:e.start] + force_bytes(repercent) + path[e.end:]
39+ changed_parts.append(path[: e.start] + repercent.encode())
40+ path = path[e.end :]
41 else:
42- return path
43+ return b"".join(changed_parts) + path
44
45
46 def filepath_to_uri(path):
47diff --git a/docs/releases/2.2.28.txt b/docs/releases/2.2.28.txt
48index ab4884b..40eb230 100644
49--- a/docs/releases/2.2.28.txt
50+++ b/docs/releases/2.2.28.txt
51@@ -47,3 +47,12 @@ CVE-2023-36053: Potential regular expression denial of service vulnerability in
52 ``EmailValidator`` and ``URLValidator`` were subject to potential regular
53 expression denial of service attack via a very large number of domain name
54 labels of emails and URLs.
55+
56+Backporting the CVE-2023-41164 fix on Django 2.2.28.
57+
58+CVE-2023-41164: Potential denial of service vulnerability in ``django.utils.encoding.uri_to_iri()``
59+===================================================================================================
60+
61+``django.utils.encoding.uri_to_iri()`` was subject to potential denial of
62+service attack via certain inputs with a very large number of Unicode
63+characters.
64diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py
65index ea7ba5f..93a3162 100644
66--- a/tests/utils_tests/test_encoding.py
67+++ b/tests/utils_tests/test_encoding.py
68@@ -1,8 +1,9 @@
69 import datetime
70+import inspect
71 import sys
72 import unittest
73 from unittest import mock
74-from urllib.parse import quote_plus
75+from urllib.parse import quote, quote_plus
76
77 from django.test import SimpleTestCase
78 from django.utils.encoding import (
79@@ -100,6 +101,24 @@ class TestEncodingUtils(SimpleTestCase):
80 except RecursionError:
81 self.fail('Unexpected RecursionError raised.')
82
83+ def test_repercent_broken_unicode_small_fragments(self):
84+ data = b"test\xfctest\xfctest\xfc"
85+ decoded_paths = []
86+
87+ def mock_quote(*args, **kwargs):
88+ # The second frame is the call to repercent_broken_unicode().
89+ decoded_paths.append(inspect.currentframe().f_back.f_locals["path"])
90+ return quote(*args, **kwargs)
91+
92+ with mock.patch("django.utils.encoding.quote", mock_quote):
93+ self.assertEqual(repercent_broken_unicode(data), b"test%FCtest%FCtest%FC")
94+
95+ # decode() is called on smaller fragment of the path each time.
96+ self.assertEqual(
97+ decoded_paths,
98+ [b"test\xfctest\xfctest\xfc", b"test\xfctest\xfc", b"test\xfc"],
99+ )
100+
101
102 class TestRFC3987IEncodingUtils(unittest.TestCase):
103
104--
1052.40.0
diff --git a/meta-python/recipes-devtools/python/python3-django_2.2.28.bb b/meta-python/recipes-devtools/python/python3-django_2.2.28.bb
index ec65a985da..c35323f455 100644
--- a/meta-python/recipes-devtools/python/python3-django_2.2.28.bb
+++ b/meta-python/recipes-devtools/python/python3-django_2.2.28.bb
@@ -7,6 +7,7 @@ inherit setuptools3
7 7
8SRC_URI += "file://CVE-2023-31047.patch \ 8SRC_URI += "file://CVE-2023-31047.patch \
9 file://CVE-2023-36053.patch \ 9 file://CVE-2023-36053.patch \
10 file://CVE-2023-41164.patch \
10 " 11 "
11 12
12SRC_URI[sha256sum] = "0200b657afbf1bc08003845ddda053c7641b9b24951e52acd51f6abda33a7413" 13SRC_URI[sha256sum] = "0200b657afbf1bc08003845ddda053c7641b9b24951e52acd51f6abda33a7413"