SQL Injection Vulnerability in Django Package: python-django Affects QuerySet Methods
Summary
UBUNTU-CVE-2024-42005: An issue was discovered in Django 5.0 before 5.0.8 and 4.2 before 4.2.15. Affects python-django versions < 2:3.2.12-2ubuntu1.13. Fixed in 2:3.2.12-2ubuntu1.13. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The python-django package is a widely used web framework that enables developers to build robust web applications quickly and efficiently. It provides a high-level Python API for database interactions, including the use of JSONField for storing and querying JSON data. However, certain versions of Django have been found vulnerable to SQL injection attacks when using QuerySet.values() and values_list() methods with JSONField, which can compromise application security.
Vulnerability Detail
An issue was discovered in Django versions 5.0 before 5.0.8 and 4.2 before 4.2.15. The vulnerability arises when the QuerySet.values() and values_list() methods are used on models with a JSONField. Attackers can exploit this vulnerability by crafting a malicious JSON object key as a passed argument, leading to potential SQL injection in column aliases. This could allow unauthorized access to sensitive data or manipulation of the database, posing significant risks to application integrity.
How To Fix
Minimum fixed version
2:3.2.12-2ubuntu1.13
This is the first release that contains the fix.
sudo apt-get install --only-upgrade python-django
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading is not immediately feasible, consider avoiding the use of QuerySet.values() and values_list() methods with JSONField until the package is updated. Additionally, ensure that user inputs are properly sanitized to mitigate the risk of SQL injection.
Conclusion
The SQL injection vulnerability in the python-django package poses significant risks to applications utilizing affected versions. It is crucial to update to the patched versions to safeguard against potential attacks. Additionally, utilizing tools like Vulert can help in monitoring and managing vulnerabilities effectively.
See every vulnerability recorded for python-django →
FAQ
The CVSS score of this vulnerability is 7.3, indicating a high severity level.
Django versions 5.0 before 5.0.8 and 4.2 before 4.2.15 are affected by this vulnerability.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.
Exploitation of this vulnerability can lead to unauthorized access to sensitive data, database manipulation, and overall compromise of application security.
Yes, Vulert allows you to monitor and alert in real-time for open-source vulnerabilities using just a manifest file like package-lock.json.
References
Related vulnerabilities
Recent vulnerabilities recorded for python-django.