SQL Injection in Django FilteredRelation Column Aliases
CVE-2025-13372 is an SQL injection vulnerability in Django's FilteredRelation support when used with PostgreSQL. Django versions 5.2 before 5.2.9, 5.1 before 5.1.15, and 4.2 before 4.2.27 permit injection through column aliases when a suitably crafted dictionary is expanded as **kwargs and passed to QuerySet.annotate() or QuerySet.alias(). Unsupported Django branches, including 5.0.x, 4.1.x, and 3.2.x, were not evaluated and may also be affected.
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
What an attacker gets, and what they’ve been doing with it.
Successful exploitation enables SQL injection in affected Django applications using PostgreSQL. Depending on the application context and database privileges, this can permit unauthorized query manipulation, exposure of database data, modification of records, or other database-level effects.
If you can’t patch tonight, do this now.
No workaround is provided. Before upgrading, avoid expanding untrusted or user-controlled dictionaries as **kwargs into QuerySet.annotate() or QuerySet.alias() where FilteredRelation and PostgreSQL are used. Review code paths that dynamically construct column aliases.
Patch, then assume compromise.
Upgrade Django to a fixed release: 5.2.9 or later for the 5.2 series, 5.1.15 or later for the 5.1 series, or 4.2.27 or later for the 4.2 series. Earlier unsupported Django series were not evaluated and may also be affected; migrate them to a supported, fixed release.
2 exploits validated by Mallory's analysis.
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
10 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.