diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-11-17 17:09:54 -0500 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2025-12-02 09:44:19 -0300 |
| commit | f997037b235f6b5c9e7c4a501491ec45f3400f3d (patch) | |
| tree | b58c8b171a4b169a7a0b25af30d13eb8d36b9bba /tests/annotations | |
| parent | 4b5dcc96f2996150ff2675233ec0a69f67b7dc9b (diff) | |
[4.2.x] Fixed CVE-2025-13372 -- Protected FilteredRelation against SQL injection in column aliases on PostgreSQL.
Follow-up to CVE-2025-57833.
Thanks Stackered for the report, and Simon Charette and Mariusz Felisiak
for the reviews.
Backport of 5b90ca1e7591fa36fccf2d6dad67cf1477e6293e from main.
Diffstat (limited to 'tests/annotations')
| -rw-r--r-- | tests/annotations/tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py index 4879f19a78..d876e3a6f5 100644 --- a/tests/annotations/tests.py +++ b/tests/annotations/tests.py @@ -2,6 +2,7 @@ import datetime from decimal import Decimal from django.core.exceptions import FieldDoesNotExist, FieldError +from django.db import connection from django.db.models import ( BooleanField, Case, @@ -1443,3 +1444,14 @@ class AliasTests(TestCase): ) with self.assertRaisesMessage(ValueError, msg): Book.objects.alias(**{crafted_alias: FilteredRelation("authors")}) + + def test_alias_filtered_relation_sql_injection_dollar_sign(self): + qs = Book.objects.alias( + **{"crafted_alia$": FilteredRelation("authors")} + ).values("name", "crafted_alia$") + if connection.vendor == "postgresql": + msg = "Dollar signs are not permitted in column aliases on PostgreSQL." + with self.assertRaisesMessage(ValueError, msg): + list(qs) + else: + self.assertEqual(qs.first()["name"], self.b1.name) |
