summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-django-5.0.14
diff options
context:
space:
mode:
authorHaixiao Yan <haixiao.yan.cn@windriver.com>2026-04-10 15:04:59 +0800
committerAnuj Mittal <anuj.mittal@oss.qualcomm.com>2026-04-15 14:10:33 +0530
commit151e634ed297eec8d9b269c2b08001fd76f4cc62 (patch)
tree2cc93ce861031d31ac3dcbf6e28df3d01b3bf02e /meta-python/recipes-devtools/python/python3-django-5.0.14
parentc14dcffcd77b7b9d0d1f3473f98d51ffe2b166e9 (diff)
downloadmeta-openembedded-151e634ed297eec8d9b269c2b08001fd76f4cc62.tar.gz
python3-django: fix CVE-2025-64459
The methods QuerySet.filter(), QuerySet.exclude(), and QuerySet.get(), and the class Q() were subject to SQL injection when using a suitably crafted dictionary, with dictionary expansion, as the _connector argument. Reference: https://nvd.nist.gov/vuln/detail/CVE-2025-64459 https://shivasurya.me/security/django/2025/11/07/django-sql-injection-CVE-2025-64459.html Upstream-patch: https://github.com/django/django/commit/72d2c87431f2ae0431d65d0ec792047f078c8241 https://github.com/django/django/commit/4624ed769c0f7caea0d48ac824a75fa6b6f17671 Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com> Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com> Signed-off-by: Anuj Mittal <anuj.mittal@oss.qualcomm.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-django-5.0.14')
-rw-r--r--meta-python/recipes-devtools/python/python3-django-5.0.14/CVE-2025-64459-1.patch57
-rw-r--r--meta-python/recipes-devtools/python/python3-django-5.0.14/CVE-2025-64459-2.patch63
2 files changed, 120 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-django-5.0.14/CVE-2025-64459-1.patch b/meta-python/recipes-devtools/python/python3-django-5.0.14/CVE-2025-64459-1.patch
new file mode 100644
index 0000000000..6c42adfa42
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-django-5.0.14/CVE-2025-64459-1.patch
@@ -0,0 +1,57 @@
1From 45f5d17986f70f0aaf4a666b2d71ae6750beeb88 Mon Sep 17 00:00:00 2001
2From: Jacob Walls <jacobtylerwalls@gmail.com>
3Date: Wed, 24 Sep 2025 15:54:51 -0400
4Subject: [PATCH] [5.1.x] Fixed CVE-2025-64459 -- Prevented SQL injections
5 in Q/QuerySet via the _connector kwarg.
6
7Thanks cyberstan for the report, Sarah Boyce, Adam Johnson, Simon
8Charette, and Jake Howard for the reviews.
9
10Backport of c880530ddd4fabd5939bab0e148bebe36699432a from main.
11
12CVE: CVE-2025-64459
13
14Upstream-Status: Backport [https://github.com/django/django/commit/72d2c87431f2ae0431d65d0ec792047f078c8241]
15
16Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com>
17---
18 django/db/models/query_utils.py | 4 ++++
19 tests/queries/test_q.py | 5 +++++
20 2 files changed, 9 insertions(+)
21
22diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
23index a04bbad5e7f8..d8610bc54d46 100644
24--- a/django/db/models/query_utils.py
25+++ b/django/db/models/query_utils.py
26@@ -47,8 +47,12 @@ class Q(tree.Node):
27 XOR = "XOR"
28 default = AND
29 conditional = True
30+ connectors = (None, AND, OR, XOR)
31
32 def __init__(self, *args, _connector=None, _negated=False, **kwargs):
33+ if _connector not in self.connectors:
34+ connector_reprs = ", ".join(f"{conn!r}" for conn in self.connectors[1:])
35+ raise ValueError(f"_connector must be one of {connector_reprs}, or None.")
36 super().__init__(
37 children=[*args, *sorted(kwargs.items())],
38 connector=_connector,
39diff --git a/tests/queries/test_q.py b/tests/queries/test_q.py
40index f7192a430a12..b21ec929a2ec 100644
41--- a/tests/queries/test_q.py
42+++ b/tests/queries/test_q.py
43@@ -264,6 +264,11 @@ class QTests(SimpleTestCase):
44 Q(*items, _connector=connector),
45 )
46
47+ def test_connector_validation(self):
48+ msg = f"_connector must be one of {Q.AND!r}, {Q.OR!r}, {Q.XOR!r}, or None."
49+ with self.assertRaisesMessage(ValueError, msg):
50+ Q(_connector="evil")
51+
52 def test_referenced_base_fields(self):
53 # Make sure Q.referenced_base_fields retrieves all base fields from
54 # both filters and F expressions.
55--
562.34.1
57
diff --git a/meta-python/recipes-devtools/python/python3-django-5.0.14/CVE-2025-64459-2.patch b/meta-python/recipes-devtools/python/python3-django-5.0.14/CVE-2025-64459-2.patch
new file mode 100644
index 0000000000..5a207f8f11
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-django-5.0.14/CVE-2025-64459-2.patch
@@ -0,0 +1,63 @@
1From 415912be531179e90e69f0be2e8bca301de53765 Mon Sep 17 00:00:00 2001
2From: Jacob Walls <jacobtylerwalls@gmail.com>
3Date: Wed, 24 Sep 2025 15:56:03 -0400
4Subject: [PATCH] [5.1.x] Refs CVE-2025-64459 -- Avoided propagating
5 invalid arguments to Q on dictionary expansion.
6
7Backport of 3c3f46357718166069948625354b8315a8505262 from main.
8
9CVE: CVE-2025-64459
10
11Upstream-Status: Backport [https://github.com/django/django/commit/4624ed769c0f7caea0d48ac824a75fa6b6f17671]
12
13Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com>
14---
15 django/db/models/query.py | 5 +++++
16 tests/queries/tests.py | 8 ++++++++
17 2 files changed, 13 insertions(+)
18
19diff --git a/django/db/models/query.py b/django/db/models/query.py
20index 153fb1193ebf..3308cd48db00 100644
21--- a/django/db/models/query.py
22+++ b/django/db/models/query.py
23@@ -42,6 +42,8 @@ MAX_GET_RESULTS = 21
24 # The maximum number of items to display in a QuerySet.__repr__
25 REPR_OUTPUT_SIZE = 20
26
27+PROHIBITED_FILTER_KWARGS = frozenset(["_connector", "_negated"])
28+
29
30 class BaseIterable:
31 def __init__(
32@@ -1495,6 +1497,9 @@ class QuerySet(AltersData):
33 return clone
34
35 def _filter_or_exclude_inplace(self, negate, args, kwargs):
36+ if invalid_kwargs := PROHIBITED_FILTER_KWARGS.intersection(kwargs):
37+ invalid_kwargs_str = ", ".join(f"'{k}'" for k in sorted(invalid_kwargs))
38+ raise TypeError(f"The following kwargs are invalid: {invalid_kwargs_str}")
39 if negate:
40 self._query.add_q(~Q(*args, **kwargs))
41 else:
42diff --git a/tests/queries/tests.py b/tests/queries/tests.py
43index 20665ab2cda3..5df231949194 100644
44--- a/tests/queries/tests.py
45+++ b/tests/queries/tests.py
46@@ -4481,6 +4481,14 @@ class TestInvalidValuesRelation(SimpleTestCase):
47 Annotation.objects.filter(tag__in=[123, "abc"])
48
49
50+class TestInvalidFilterArguments(TestCase):
51+ def test_filter_rejects_invalid_arguments(self):
52+ school = School.objects.create()
53+ msg = "The following kwargs are invalid: '_connector', '_negated'"
54+ with self.assertRaisesMessage(TypeError, msg):
55+ School.objects.filter(pk=school.pk, _negated=True, _connector="evil")
56+
57+
58 class TestTicket24605(TestCase):
59 def test_ticket_24605(self):
60 """
61--
622.34.1
63