CVE-2025-64459: CWE-89 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') in djangoproject Django
An issue was discovered in 5.1 before 5.1.14, 4.2 before 4.2.26, and 5.2 before 5.2.8. The methods `QuerySet.filter()`, `QuerySet.exclude()`, and `QuerySet.get()`, and the class `Q()`, are subject to SQL injection when using a suitably crafted dictionary, with dictionary expansion, as the `_connector` argument. 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 cyberstan for reporting this issue.
AI Analysis
Technical Summary
CVE-2025-64459 is a critical SQL injection vulnerability identified in the Django web framework affecting versions 5.1 before 5.1.14, 4.2 before 4.2.26, and 5.2 before 5.2.8. The vulnerability arises from improper neutralization of special elements in SQL commands (CWE-89) when using certain ORM methods—specifically QuerySet.filter(), QuerySet.exclude(), QuerySet.get(), and the Q() class—when a crafted dictionary with dictionary expansion is passed as the _connector argument. This flaw allows an attacker to inject arbitrary SQL code into database queries constructed by Django's ORM, potentially leading to unauthorized data retrieval, modification, or deletion. The issue stems from insufficient sanitization or validation of the _connector argument when it is a dictionary expanded into the query conditions. Although earlier unsupported Django series (5.0.x, 4.1.x, 3.2.x) were not evaluated, they may also be vulnerable. No CVSS score has been assigned yet, and no known exploits have been reported in the wild. The vulnerability was responsibly disclosed by a researcher named cyberstan. Given Django's widespread use in web applications globally, this vulnerability poses a significant risk to applications that do not upgrade or implement additional safeguards. Attackers exploiting this vulnerability do not require authentication or user interaction, increasing the risk profile. The flaw can be exploited remotely if user input is passed unsafely to the affected ORM methods, making it a critical concern for web application security.
Potential Impact
For European organizations, the impact of CVE-2025-64459 can be severe. Many enterprises, government agencies, and service providers in Europe use Django for developing web applications that handle sensitive personal data, financial information, and critical business processes. Successful exploitation could lead to unauthorized access to confidential data, data corruption, or complete compromise of backend databases. This can result in data breaches violating GDPR and other data protection regulations, leading to legal penalties and reputational damage. The integrity and availability of applications may also be affected if attackers modify or delete data. Since exploitation does not require authentication or user interaction, attackers can remotely target vulnerable applications exposed to the internet. This increases the attack surface for European organizations, especially those with public-facing Django-based services. Additionally, the absence of known exploits currently provides a window for proactive mitigation, but also means organizations must act swiftly to patch before attackers develop and deploy exploits.
Mitigation Recommendations
1. Upgrade all affected Django installations to the fixed versions: 5.1.14, 4.2.26, 5.2.8 or later as soon as possible. 2. Conduct a thorough code audit to identify any usage of QuerySet.filter(), QuerySet.exclude(), QuerySet.get(), and Q() with dictionary expansion in the _connector argument, and refactor unsafe code to avoid passing user-controlled data in this manner. 3. Implement strict input validation and sanitization on all user inputs that may influence ORM queries, especially those that could be expanded into dictionary arguments. 4. Employ Web Application Firewalls (WAFs) with rules designed to detect and block SQL injection attempts targeting Django ORM patterns. 5. Monitor application logs for unusual query patterns or errors that may indicate attempted exploitation. 6. Educate development teams about secure ORM usage and the risks of dictionary expansion in query connectors. 7. For legacy or unsupported Django versions that cannot be immediately upgraded, consider isolating affected applications behind additional security layers and restricting access to trusted users only. 8. Maintain an incident response plan to quickly address any detected exploitation attempts.
Affected Countries
Germany, United Kingdom, France, Netherlands, Sweden, Italy, Spain
CVE-2025-64459: CWE-89 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') in djangoproject Django
Description
An issue was discovered in 5.1 before 5.1.14, 4.2 before 4.2.26, and 5.2 before 5.2.8. The methods `QuerySet.filter()`, `QuerySet.exclude()`, and `QuerySet.get()`, and the class `Q()`, are subject to SQL injection when using a suitably crafted dictionary, with dictionary expansion, as the `_connector` argument. 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 cyberstan for reporting this issue.
AI-Powered Analysis
Technical Analysis
CVE-2025-64459 is a critical SQL injection vulnerability identified in the Django web framework affecting versions 5.1 before 5.1.14, 4.2 before 4.2.26, and 5.2 before 5.2.8. The vulnerability arises from improper neutralization of special elements in SQL commands (CWE-89) when using certain ORM methods—specifically QuerySet.filter(), QuerySet.exclude(), QuerySet.get(), and the Q() class—when a crafted dictionary with dictionary expansion is passed as the _connector argument. This flaw allows an attacker to inject arbitrary SQL code into database queries constructed by Django's ORM, potentially leading to unauthorized data retrieval, modification, or deletion. The issue stems from insufficient sanitization or validation of the _connector argument when it is a dictionary expanded into the query conditions. Although earlier unsupported Django series (5.0.x, 4.1.x, 3.2.x) were not evaluated, they may also be vulnerable. No CVSS score has been assigned yet, and no known exploits have been reported in the wild. The vulnerability was responsibly disclosed by a researcher named cyberstan. Given Django's widespread use in web applications globally, this vulnerability poses a significant risk to applications that do not upgrade or implement additional safeguards. Attackers exploiting this vulnerability do not require authentication or user interaction, increasing the risk profile. The flaw can be exploited remotely if user input is passed unsafely to the affected ORM methods, making it a critical concern for web application security.
Potential Impact
For European organizations, the impact of CVE-2025-64459 can be severe. Many enterprises, government agencies, and service providers in Europe use Django for developing web applications that handle sensitive personal data, financial information, and critical business processes. Successful exploitation could lead to unauthorized access to confidential data, data corruption, or complete compromise of backend databases. This can result in data breaches violating GDPR and other data protection regulations, leading to legal penalties and reputational damage. The integrity and availability of applications may also be affected if attackers modify or delete data. Since exploitation does not require authentication or user interaction, attackers can remotely target vulnerable applications exposed to the internet. This increases the attack surface for European organizations, especially those with public-facing Django-based services. Additionally, the absence of known exploits currently provides a window for proactive mitigation, but also means organizations must act swiftly to patch before attackers develop and deploy exploits.
Mitigation Recommendations
1. Upgrade all affected Django installations to the fixed versions: 5.1.14, 4.2.26, 5.2.8 or later as soon as possible. 2. Conduct a thorough code audit to identify any usage of QuerySet.filter(), QuerySet.exclude(), QuerySet.get(), and Q() with dictionary expansion in the _connector argument, and refactor unsafe code to avoid passing user-controlled data in this manner. 3. Implement strict input validation and sanitization on all user inputs that may influence ORM queries, especially those that could be expanded into dictionary arguments. 4. Employ Web Application Firewalls (WAFs) with rules designed to detect and block SQL injection attempts targeting Django ORM patterns. 5. Monitor application logs for unusual query patterns or errors that may indicate attempted exploitation. 6. Educate development teams about secure ORM usage and the risks of dictionary expansion in query connectors. 7. For legacy or unsupported Django versions that cannot be immediately upgraded, consider isolating affected applications behind additional security layers and restricting access to trusted users only. 8. Maintain an incident response plan to quickly address any detected exploitation attempts.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- DSF
- Date Reserved
- 2025-11-04T14:35:57.527Z
- Cvss Version
- null
- State
- PUBLISHED
Threat ID: 690b6b8d39a16b4c6e53b82e
Added to database: 11/5/2025, 3:21:49 PM
Last enriched: 11/5/2025, 3:23:17 PM
Last updated: 11/5/2025, 5:46:46 PM
Views: 5
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Related Threats
CVE-2025-10713: CWE-611 Improper Restriction of XML External Entity Reference in WSO2 WSO2 Enterprise Integrator
MediumCVE-2025-43990: CWE-250: Execution with Unnecessary Privileges in Dell Command Monitor (DCM)
HighCVE-2025-46366: CWE-256: Plaintext Storage of a Password in Dell CloudLink
MediumCVE-2025-57244: n/a
HighCVE-2025-46364: CWE-269: Improper Privilege Management in Dell CloudLin
CriticalActions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.