CVE-2025-59681
7.1Django · Django
Django is vulnerable to SQL injection in QuerySet methods when using crafted dictionaries for column aliases on MySQL and MariaDB databases, potentially allowing unauthorized data access.
Executive summary
A high-severity SQL injection vulnerability in Django allows authenticated users to execute arbitrary SQL queries, potentially leading to unauthorized data exposure.
Vulnerability
The vulnerability exists within the QuerySet.annotate, QuerySet.alias, QuerySet.aggregate, and QuerySet.extra methods. An authenticated attacker can trigger this flaw by providing a maliciously crafted dictionary via keyword argument expansion when using MySQL or MariaDB backends.
Business impact
Successful exploitation allows an attacker to manipulate database queries, which may result in the exfiltration of sensitive information or unauthorized modification of database records. Given the CVSS score of 7.1, this represents a significant risk to application integrity and data confidentiality, particularly for systems handling proprietary or regulated user data.
Remediation
Immediate Action: Upgrade to Django versions 4.2.25, 5.1.13, or 5.2.7 immediately to incorporate the security patches provided by the vendor.
Proactive Monitoring: Review database query logs for unusual syntax or unexpected parameter structures that deviate from standard application behavior.
Compensating Controls: Implement strict input validation on all user-supplied data used in QuerySet construction and ensure that database users operate with the principle of least privilege.
Exploitation status
Public Exploit Available: No (exploit_available: false)
Analyst recommendation
This vulnerability presents a clear risk to the data layer of applications using Django with MySQL or MariaDB. Security teams should prioritize the deployment of the specified patched versions across all development and production environments. Failure to update may leave the application backend susceptible to sophisticated SQL injection attacks.