CVE-2025-13372 Potential SQL injection in FilteredRelation column aliases on PostgreSQL
Attackers can execute arbitrary SQL commands via crafted dictionary arguments in Django's FilteredRelation on PostgreSQL, potentially accessing or modifying database contents.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2025-13372?
CVE-2025-13372 is a medium-severity SQL injection vulnerability in Djangoproject Django, published on 2 Dec 2025. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Official description
An issue was discovered in 5.2 before 5.2.9, 5.1 before 5.1.15, and 4.2 before 4.2.27. `FilteredRelation` is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the `**kwargs` passed to `QuerySet.annotate()` or `QuerySet.alias()` on PostgreSQL. Earlier, unsupported Django series (such as 5.0.x, 4.1.x, and 3.2.x) were not evaluated and may also be affected. Django would like to thank Stackered for reporting this issue.
Weakness: CWE-89
Which versions are affected by CVE-2025-13372?
8 open source packages ship an affected version, including django and Django. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
django Bitnami | From 4.2.0 | 4.2.27, 5.1.15, 5.2.9 |
django PyPI | From 4.2 | 4.2.27, 5.1.15, 5.2.9 |
django PyPI | From 4.2a1 | 4.2.27 |
django PyPI | From 5.1a1 | 5.1.15 |
django PyPI | From 5.2a1 | 5.2.9 |
Django PyPI | From 4.2a1 | 4.2.27 |
2 more packages
Django PyPI | From 5.1a1 | 5.1.15 |
Django PyPI | From 5.2a1 | 5.2.9 |
Products include Djangoproject Django.
How do I fix CVE-2025-13372?
Upgrade django to a fixed version for your release line: 4.2.27, 5.1.15 or 5.2.9.
Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.
Is CVE-2025-13372 being exploited?
There is no known exploitation of CVE-2025-13372 in the wild and no public exploit code.
Other vulnerabilities in Djangoproject Django
- CVE-2026-4277 Privilege abuse in GenericInlineModelAdmin
- CVE-2024-53908 Django SQL injection in HasKey(lhs, rhs) on Oracle
- CVE-2024-42005 Django SQL injection vulnerability
- CVE-2023-31047 Django bypasses validation when using one form field to upload multiple files
- CVE-2022-34265 Django `Trunc()` and `Extract()` database functions vulnerable to SQL Injection
Sources
Also known as BIT-django-2025-13372, CLSA-2026-1788348294, CLSA-2026-1789636652, DEBIAN-CVE-2025-13372, ECHO-91c5-85b0-1e52, GHSA-rqw2-ghq9-44m7 and 6 more.