summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-django/CVE-2025-57833.patch
diff options
context:
space:
mode:
authorSaravanan <saravanan.kadambathursubramaniyam@windriver.com>2025-11-30 17:18:59 +0530
committerGyorgy Sarvari <skandigraun@gmail.com>2025-11-30 15:16:32 +0100
commit21d389c8f9c82be11f50560668591d5f7ae80690 (patch)
treed8fbbee63f20e600a81937238ffece013bd566ed /meta-python/recipes-devtools/python/python3-django/CVE-2025-57833.patch
parent0b554678b68189e14293a8a6a07bb6998ce345c4 (diff)
downloadmeta-openembedded-21d389c8f9c82be11f50560668591d5f7ae80690.tar.gz
python3-django: fix CVE-2025-57833
Reference: https://nvd.nist.gov/vuln/detail/CVE-2025-57833 Upstream-patch: https://github.com/django/django/commit/31334e6965ad136a5e369993b01721499c5d1a92 Signed-off-by: Saravanan <saravanan.kadambathursubramaniyam@windriver.com> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-django/CVE-2025-57833.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-django/CVE-2025-57833.patch95
1 files changed, 95 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-django/CVE-2025-57833.patch b/meta-python/recipes-devtools/python/python3-django/CVE-2025-57833.patch
new file mode 100644
index 0000000000..9d4edb8d7c
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-django/CVE-2025-57833.patch
@@ -0,0 +1,95 @@
1From 31334e6965ad136a5e369993b01721499c5d1a92 Mon Sep 17 00:00:00 2001
2From: Jake Howard <git@theorangeone.net>
3Date: Wed, 13 Aug 2025 14:13:42 +0200
4Subject: [PATCH] Fixed CVE-2025-57833 -- Protected FilteredRelation against
5 SQL injection in column aliases.
6
7Thanks Eyal Gabay (EyalSec) for the report.
8
9Backport of 51711717098d3f469f795dfa6bc3758b24f69ef7 from main.
10
11CVE: CVE-2025-57833
12
13Upstream-Status: Backport
14https://github.com/django/django/commit/31334e6965ad136a5e369993b01721499c5d1a92
15
16Signed-off-by: Jake Howard <git@theorangeone.net>
17Signed-off-by: Saravanan <saravanan.kadambathursubramaniyam@windriver.com>
18
19%% original patch: CVE-2025-57833.patch
20---
21 django/db/models/sql/query.py | 1 +
22 docs/releases/2.2.28.txt | 7 +++++++
23 tests/annotations/tests.py | 18 ++++++++++++++++--
24 3 files changed, 24 insertions(+), 2 deletions(-)
25
26diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
27index 9b054bd..96a6f5f 100644
28--- a/django/db/models/sql/query.py
29+++ b/django/db/models/sql/query.py
30@@ -1369,6 +1369,7 @@ class Query:
31 return target_clause
32
33 def add_filtered_relation(self, filtered_relation, alias):
34+ self.check_alias(alias)
35 filtered_relation.alias = alias
36 lookups = dict(get_children_from_q(filtered_relation.condition))
37 for lookup in chain((filtered_relation.relation_name,), lookups):
38diff --git a/docs/releases/2.2.28.txt b/docs/releases/2.2.28.txt
39index 0e092f0..f3fb298 100644
40--- a/docs/releases/2.2.28.txt
41+++ b/docs/releases/2.2.28.txt
42@@ -117,3 +117,10 @@ which has now been updated to define a ``max_length`` of 39 characters.
43 The :class:`django.db.models.GenericIPAddressField` model field was not
44 affected.
45
46+CVE-2025-57833: Potential SQL injection in ``FilteredRelation`` column aliases
47+==============================================================================
48+
49+:class:`.FilteredRelation` was subject to SQL injection in column aliases,
50+using a suitably crafted dictionary, with dictionary expansion, as the
51+``**kwargs`` passed to :meth:`.QuerySet.annotate` or :meth:`.QuerySet.alias`.
52+
53diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
54index 27cd7eb..cdffb07 100644
55--- a/tests/annotations/tests.py
56+++ b/tests/annotations/tests.py
57@@ -3,8 +3,8 @@ from decimal import Decimal
58
59 from django.core.exceptions import FieldDoesNotExist, FieldError
60 from django.db.models import (
61- BooleanField, CharField, Count, DateTimeField, ExpressionWrapper, F, Func,
62- IntegerField, NullBooleanField, OuterRef, Q, Subquery, Sum, Value,
63+ BooleanField, CharField, Count, DateTimeField, ExpressionWrapper, F, FilteredRelation,
64+ Func, IntegerField, NullBooleanField, OuterRef, Q, Subquery, Sum, Value,
65 )
66 from django.db.models.expressions import RawSQL
67 from django.db.models.functions import Length, Lower
68@@ -608,6 +608,15 @@ class NonAggregateAnnotationTestCase(TestCase):
69 with self.assertRaisesMessage(ValueError, msg):
70 Book.objects.annotate(**{crafted_alias: Value(1)})
71
72+ def test_alias_filtered_relation_sql_injection(self):
73+ crafted_alias = """injected_name" from "annotations_book"; --"""
74+ msg = (
75+ "Column aliases cannot contain whitespace characters, quotation marks, "
76+ "semicolons, or SQL comments."
77+ )
78+ with self.assertRaisesMessage(ValueError, msg):
79+ Book.objects.annotate(**{crafted_alias: FilteredRelation("author")})
80+
81 def test_alias_forbidden_chars(self):
82 tests = [
83 'al"ias',
84@@ -632,3 +641,8 @@ class NonAggregateAnnotationTestCase(TestCase):
85 with self.subTest(crafted_alias):
86 with self.assertRaisesMessage(ValueError, msg):
87 Book.objects.annotate(**{crafted_alias: Value(1)})
88+
89+ with self.assertRaisesMessage(ValueError, msg):
90+ Book.objects.annotate(
91+ **{crafted_alias: FilteredRelation("authors")}
92+ )
93--
942.40.0
95