Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

CVE-2025-13372: CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') in djangoproject Django

0
Medium
VulnerabilityCVE-2025-13372cvecve-2025-13372cwe-89
Published: Tue Dec 02 2025 (12/02/2025, 15:13:35 UTC)
Source: CVE Database V5
Vendor/Project: djangoproject
Product: Django

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.

AI-Powered Analysis

AILast updated: 12/02/2025, 15:57:59 UTC

Technical Analysis

CVE-2025-13372 is a vulnerability in the Django web framework impacting versions 4.2 prior to 4.2.27, 5.1 prior to 5.1.15, and 5.2 prior to 5.2.9. The issue arises from improper neutralization of special elements in SQL commands (CWE-89), specifically within the FilteredRelation feature when used with PostgreSQL databases. The vulnerability is triggered when developers use dictionary expansion (**kwargs) to pass dynamic column aliases to QuerySet.annotate() or QuerySet.alias(). By crafting a malicious dictionary, an attacker can inject SQL code into the column aliases, which are not properly sanitized before being incorporated into the SQL query. This can lead to SQL injection attacks that expose confidential data. The vulnerability does not require authentication but does require user interaction, such as submitting crafted input that reaches the vulnerable code path. The CVSS score is 4.3 (medium), reflecting a network attack vector with low complexity and no privileges required, but user interaction is necessary. The flaw affects PostgreSQL backends specifically, and earlier unsupported Django versions may also be vulnerable but were not evaluated. No public exploits have been reported yet. The Django project has acknowledged the issue and released patches in the specified versions to remediate the vulnerability.

Potential Impact

For European organizations, this vulnerability poses a risk primarily to web applications built on affected Django versions using PostgreSQL databases. The SQL injection could allow attackers to extract sensitive data from the database, compromising confidentiality. Although the vulnerability does not affect integrity or availability directly, data leakage can have serious regulatory and reputational consequences, especially under GDPR. Organizations in sectors such as finance, healthcare, and government, which often handle sensitive personal or financial data, are at higher risk. The requirement for user interaction means phishing or social engineering could be used to trigger the exploit. The medium severity indicates that while the risk is not critical, it is significant enough to warrant prompt attention to avoid data breaches. The lack of known exploits in the wild reduces immediate urgency but does not eliminate the threat, as attackers may develop exploits over time.

Mitigation Recommendations

The primary mitigation is to upgrade Django installations to versions 4.2.27, 5.1.15, 5.2.9 or later where the vulnerability is patched. Organizations should audit their codebases for usage of FilteredRelation with dynamic dictionary expansion in QuerySet.annotate() or QuerySet.alias() and refactor to avoid passing untrusted input as column aliases. Implement strict input validation and sanitization on any user-supplied data that could influence query construction. Employ database activity monitoring to detect unusual or anomalous SQL queries indicative of injection attempts. Use Web Application Firewalls (WAFs) with rules tailored to detect SQL injection patterns specific to PostgreSQL. Conduct security testing, including static code analysis and penetration testing focused on ORM query construction. Educate developers about secure use of Django ORM features and the risks of dynamic query components. Finally, maintain an incident response plan to quickly address any detected exploitation attempts.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.2
Assigner Short Name
DSF
Date Reserved
2025-11-18T18:34:58.688Z
Cvss Version
null
State
PUBLISHED

Threat ID: 692f093f16d939a309c3099b

Added to database: 12/2/2025, 3:43:59 PM

Last enriched: 12/2/2025, 3:57:59 PM

Last updated: 12/2/2025, 4:53:21 PM

Views: 12

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats