CVE-2025-13372 Potential SQL injection in FilteredRelation column aliases on PostgreSQL

Medium 4.3 Published Updated

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.

PackageAffectedFixed in
django BitnamiFrom 4.2.04.2.27, 5.1.15, 5.2.9
django PyPIFrom 4.24.2.27, 5.1.15, 5.2.9
django PyPIFrom 4.2a14.2.27
django PyPIFrom 5.1a15.1.15
django PyPIFrom 5.2a15.2.9
Django PyPIFrom 4.2a14.2.27
2 more packages
Django PyPIFrom 5.1a15.1.15
Django PyPIFrom 5.2a15.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.

All Djangoproject Django vulnerabilities

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.

Is CVE-2025-13372 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free