diff options
| author | Saravanan <saravanan.kadambathursubramaniyam@windriver.com> | 2025-11-30 17:18:59 +0530 |
|---|---|---|
| committer | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-11-30 15:16:32 +0100 |
| commit | 21d389c8f9c82be11f50560668591d5f7ae80690 (patch) | |
| tree | d8fbbee63f20e600a81937238ffece013bd566ed /meta-python | |
| parent | 0b554678b68189e14293a8a6a07bb6998ce345c4 (diff) | |
| download | meta-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')
4 files changed, 207 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-django-3.2.25/CVE-2025-57833.patch b/meta-python/recipes-devtools/python/python3-django-3.2.25/CVE-2025-57833.patch new file mode 100644 index 0000000000..f5252329b6 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-django-3.2.25/CVE-2025-57833.patch | |||
| @@ -0,0 +1,110 @@ | |||
| 1 | From 31334e6965ad136a5e369993b01721499c5d1a92 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jake Howard <git@theorangeone.net> | ||
| 3 | Date: Wed, 13 Aug 2025 14:13:42 +0200 | ||
| 4 | Subject: [PATCH] Fixed CVE-2025-57833 -- Protected FilteredRelation against | ||
| 5 | SQL injection in column aliases. | ||
| 6 | |||
| 7 | Thanks Eyal Gabay (EyalSec) for the report. | ||
| 8 | |||
| 9 | Backport of 51711717098d3f469f795dfa6bc3758b24f69ef7 from main. | ||
| 10 | |||
| 11 | CVE: CVE-2025-57833 | ||
| 12 | |||
| 13 | Upstream-Status: Backport | ||
| 14 | https://github.com/django/django/commit/31334e6965ad136a5e369993b01721499c5d1a92 | ||
| 15 | |||
| 16 | Signed-off-by: Jake Howard <git@theorangeone.net> | ||
| 17 | Signed-off-by: Saravanan <saravanan.kadambathursubramaniyam@windriver.com> | ||
| 18 | --- | ||
| 19 | django/db/models/sql/query.py | 1 + | ||
| 20 | docs/releases/3.2.25.txt | 7 +++++++ | ||
| 21 | tests/annotations/tests.py | 25 ++++++++++++++++++++++++- | ||
| 22 | 3 files changed, 32 insertions(+), 1 deletion(-) | ||
| 23 | |||
| 24 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py | ||
| 25 | index 230b6fa..e56ff81 100644 | ||
| 26 | --- a/django/db/models/sql/query.py | ||
| 27 | +++ b/django/db/models/sql/query.py | ||
| 28 | @@ -1466,6 +1466,7 @@ class Query(BaseExpression): | ||
| 29 | return target_clause | ||
| 30 | |||
| 31 | def add_filtered_relation(self, filtered_relation, alias): | ||
| 32 | + self.check_alias(alias) | ||
| 33 | filtered_relation.alias = alias | ||
| 34 | lookups = dict(get_children_from_q(filtered_relation.condition)) | ||
| 35 | relation_lookup_parts, relation_field_parts, _ = self.solve_lookup_type(filtered_relation.relation_name) | ||
| 36 | diff --git a/docs/releases/3.2.25.txt b/docs/releases/3.2.25.txt | ||
| 37 | index 93ab341..a2a58b5 100644 | ||
| 38 | --- a/docs/releases/3.2.25.txt | ||
| 39 | +++ b/docs/releases/3.2.25.txt | ||
| 40 | @@ -33,6 +33,13 @@ which has now been updated to define a ``max_length`` of 39 characters. | ||
| 41 | The :class:`django.db.models.GenericIPAddressField` model field was not | ||
| 42 | affected. | ||
| 43 | |||
| 44 | +CVE-2025-57833: Potential SQL injection in ``FilteredRelation`` column aliases | ||
| 45 | +============================================================================== | ||
| 46 | + | ||
| 47 | +:class:`.FilteredRelation` was subject to SQL injection in column aliases, | ||
| 48 | +using a suitably crafted dictionary, with dictionary expansion, as the | ||
| 49 | +``**kwargs`` passed to :meth:`.QuerySet.annotate` or :meth:`.QuerySet.alias`. | ||
| 50 | + | ||
| 51 | Bugfixes | ||
| 52 | ======== | ||
| 53 | |||
| 54 | diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py | ||
| 55 | index 8082c7a..00d4ee6 100644 | ||
| 56 | --- a/tests/annotations/tests.py | ||
| 57 | +++ b/tests/annotations/tests.py | ||
| 58 | @@ -4,7 +4,7 @@ from decimal import Decimal | ||
| 59 | from django.core.exceptions import FieldDoesNotExist, FieldError | ||
| 60 | from django.db.models import ( | ||
| 61 | BooleanField, Case, CharField, Count, DateTimeField, DecimalField, Exists, | ||
| 62 | - ExpressionWrapper, F, FloatField, Func, IntegerField, Max, | ||
| 63 | + ExpressionWrapper, F, FilteredRelation, FloatField, Func, IntegerField, Max, | ||
| 64 | NullBooleanField, OuterRef, Q, Subquery, Sum, Value, When, | ||
| 65 | ) | ||
| 66 | from django.db.models.expressions import RawSQL | ||
| 67 | @@ -775,6 +775,15 @@ class NonAggregateAnnotationTestCase(TestCase): | ||
| 68 | with self.assertRaisesMessage(ValueError, msg): | ||
| 69 | Book.objects.annotate(**{crafted_alias: Value(1)}) | ||
| 70 | |||
| 71 | + def test_alias_filtered_relation_sql_injection(self): | ||
| 72 | + crafted_alias = """injected_name" from "annotations_book"; --""" | ||
| 73 | + msg = ( | ||
| 74 | + "Column aliases cannot contain whitespace characters, quotation marks, " | ||
| 75 | + "semicolons, or SQL comments." | ||
| 76 | + ) | ||
| 77 | + with self.assertRaisesMessage(ValueError, msg): | ||
| 78 | + Book.objects.annotate(**{crafted_alias: FilteredRelation("author")}) | ||
| 79 | + | ||
| 80 | def test_alias_forbidden_chars(self): | ||
| 81 | tests = [ | ||
| 82 | 'al"ias', | ||
| 83 | @@ -800,6 +809,11 @@ class NonAggregateAnnotationTestCase(TestCase): | ||
| 84 | with self.assertRaisesMessage(ValueError, msg): | ||
| 85 | Book.objects.annotate(**{crafted_alias: Value(1)}) | ||
| 86 | |||
| 87 | + with self.assertRaisesMessage(ValueError, msg): | ||
| 88 | + Book.objects.annotate( | ||
| 89 | + **{crafted_alias: FilteredRelation("authors")} | ||
| 90 | + ) | ||
| 91 | + | ||
| 92 | |||
| 93 | class AliasTests(TestCase): | ||
| 94 | @classmethod | ||
| 95 | @@ -1039,3 +1053,12 @@ class AliasTests(TestCase): | ||
| 96 | ) | ||
| 97 | with self.assertRaisesMessage(ValueError, msg): | ||
| 98 | Book.objects.alias(**{crafted_alias: Value(1)}) | ||
| 99 | + | ||
| 100 | + def test_alias_filtered_relation_sql_injection(self): | ||
| 101 | + crafted_alias = """injected_name" from "annotations_book"; --""" | ||
| 102 | + msg = ( | ||
| 103 | + "Column aliases cannot contain whitespace characters, quotation marks, " | ||
| 104 | + "semicolons, or SQL comments." | ||
| 105 | + ) | ||
| 106 | + with self.assertRaisesMessage(ValueError, msg): | ||
| 107 | + Book.objects.alias(**{crafted_alias: FilteredRelation("authors")}) | ||
| 108 | -- | ||
| 109 | 2.40.0 | ||
| 110 | |||
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 @@ | |||
| 1 | From 31334e6965ad136a5e369993b01721499c5d1a92 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jake Howard <git@theorangeone.net> | ||
| 3 | Date: Wed, 13 Aug 2025 14:13:42 +0200 | ||
| 4 | Subject: [PATCH] Fixed CVE-2025-57833 -- Protected FilteredRelation against | ||
| 5 | SQL injection in column aliases. | ||
| 6 | |||
| 7 | Thanks Eyal Gabay (EyalSec) for the report. | ||
| 8 | |||
| 9 | Backport of 51711717098d3f469f795dfa6bc3758b24f69ef7 from main. | ||
| 10 | |||
| 11 | CVE: CVE-2025-57833 | ||
| 12 | |||
| 13 | Upstream-Status: Backport | ||
| 14 | https://github.com/django/django/commit/31334e6965ad136a5e369993b01721499c5d1a92 | ||
| 15 | |||
| 16 | Signed-off-by: Jake Howard <git@theorangeone.net> | ||
| 17 | Signed-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 | |||
| 26 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py | ||
| 27 | index 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): | ||
| 38 | diff --git a/docs/releases/2.2.28.txt b/docs/releases/2.2.28.txt | ||
| 39 | index 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 | + | ||
| 53 | diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py | ||
| 54 | index 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 | -- | ||
| 94 | 2.40.0 | ||
| 95 | |||
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 f4b8da69b5..82cdcb2328 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 | |||
| @@ -27,6 +27,7 @@ SRC_URI += "file://CVE-2023-31047.patch \ | |||
| 27 | file://CVE-2024-27351.patch \ | 27 | file://CVE-2024-27351.patch \ |
| 28 | file://CVE-2025-26699.patch \ | 28 | file://CVE-2025-26699.patch \ |
| 29 | file://CVE-2024-56374.patch \ | 29 | file://CVE-2024-56374.patch \ |
| 30 | file://CVE-2025-57833.patch \ | ||
| 30 | " | 31 | " |
| 31 | 32 | ||
| 32 | SRC_URI[sha256sum] = "0200b657afbf1bc08003845ddda053c7641b9b24951e52acd51f6abda33a7413" | 33 | SRC_URI[sha256sum] = "0200b657afbf1bc08003845ddda053c7641b9b24951e52acd51f6abda33a7413" |
diff --git a/meta-python/recipes-devtools/python/python3-django_3.2.25.bb b/meta-python/recipes-devtools/python/python3-django_3.2.25.bb index 452f2f87a6..fe438016f9 100644 --- a/meta-python/recipes-devtools/python/python3-django_3.2.25.bb +++ b/meta-python/recipes-devtools/python/python3-django_3.2.25.bb | |||
| @@ -9,6 +9,7 @@ RDEPENDS:${PN} += "\ | |||
| 9 | SRC_URI += "\ | 9 | SRC_URI += "\ |
| 10 | file://CVE-2025-26699.patch \ | 10 | file://CVE-2025-26699.patch \ |
| 11 | file://CVE-2024-56374.patch \ | 11 | file://CVE-2024-56374.patch \ |
| 12 | file://CVE-2025-57833.patch \ | ||
| 12 | " | 13 | " |
| 13 | 14 | ||
| 14 | # Set DEFAULT_PREFERENCE so that the LTS version of django is built by | 15 | # Set DEFAULT_PREFERENCE so that the LTS version of django is built by |
