CVE-2025-13372 is a medium-severity (CVSS 4.3) SQL Injection vulnerability in django. A fix is available for django — see the affected versions and patch details below.
Potential SQL injection in FilteredRelation column aliases on PostgreSQL
Exploitation Status
No confirmed exploitation observed yet
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for CVE-2025-13372.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
django🐍django🐍djangoReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | django | ≥ 5.2a1&&< 5.2.9 | 5.2.9pip install --upgrade 'django==5.2.9' |
| 🐍PyPI | django | ≥ 5.1a1&&< 5.1.15 | 5.1.15pip install --upgrade 'django==5.1.15' |
| 🐍PyPI | django | ≥ 4.2a1&&< 4.2.27 | 4.2.27pip install --upgrade 'django==4.2.27' |
Affected Products
djangodjangoprojectDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for django, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update django to 5.2.9 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2025-13372 is resolved across your whole dependency graph.
Workarounds
Until you can upgrade, make sure every query built from user input uses parameterised statements or a prepared-statement API rather than string concatenation, and reduce the database account's privileges so an injected query cannot read or alter data beyond what the feature needs.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
This vulnerability is rated Moderate for Red Hat products. It affects Django applications utilizing PostgreSQL with `FilteredRelation` and specifically crafted dictionaries passed to `QuerySet.annotate()` or `QuerySet.alias()`. Red Hat products shipping affected Django versions that meet these conditions are impacted.
Mitigation for this issue is either not available or the currently available options do not meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base, or stability.Source: Red Hat security advisory for CVE-2025-13372 (CC BY 4.0)
Frequently Asked Questions
Is CVE-2025-13372 in your dependencies?
Find it across PyPI, including transitive dependencies.