CVE-2019-14234: SQL Injection in Django
Summary
CVE-2019-14234: SQL Injection in Django. Affects django across 3 version ranges.
>= 1.11a1, < 1.11.23
>= 2.1a1, < 2.1.11
>= 2.2a1, < 2.2.4
Fixed in 1.11.23, 2.1.11 or 2.2.4, depending on the release line you run. How to fix ↓
Also tracked for
- py-django · Alpine:v3.10
The same CVE-2019-14234 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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
Django is a popular Python web framework known for its simplicity and scalability. It provides a comprehensive set of tools and libraries for building web applications. The vulnerability identified as CVE-2019-14234 affects Django versions 1.11.x, 2.1.x, and 2.2.x. This vulnerability specifically impacts the django.contrib.postgres.fields.JSONField and django.contrib.postgres.fields.HStoreField, allowing for SQL injection attacks. By exploiting this vulnerability, an attacker could execute arbitrary SQL queries, potentially gaining unauthorized access to the database or retrieving sensitive information.
Vulnerability Detail
The vulnerability arises from an error in shallow key transformation within Django. This flaw allows for SQL injection attacks when performing key and index lookups on the affected fields. For example, an attacker could inject malicious code such as "OR 1=1" into a key or index name, resulting in the retrieval of all records from the database. This vulnerability can be exploited by passing a suitably crafted dictionary with dictionary expansion as the **kwargs parameter to the QuerySet.filter() function. The impact of this vulnerability can be severe, as it enables unauthorized access to the database and potential data leakage.
How To Fix
Latest published version: 6.1.2 as of 22 Oct 2026
pip install --upgrade "django==6.1.2"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
>= 1.11a1, < 1.11.231.11.23pip install --upgrade "django==1.11.23" -
>= 2.1a1, < 2.1.112.1.11pip install --upgrade "django==2.1.11" -
>= 2.2a1, < 2.2.42.2.4pip install --upgrade "django==2.2.4"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a temporary workaround, users can sanitize user input by validating and escaping any user-supplied data used in key or index lookups. It is recommended to use Django's built-in query parameterization to prevent SQL injection attacks. Here is an example of how to use query parameterization with the QuerySet.filter() function:
# Sanitize user input
user_input = request.GET.get('user_input')
# Perform query using query parameterization
queryset = MyModel.objects.filter(key__exact=user_input)
By using query parameterization, the user input is automatically escaped, preventing SQL injection attacks.
Conclusion
The SQL Injection vulnerability in Django can have severe consequences, including unauthorized access to the database and potential data leakage. It is crucial to upgrade Django to the patched versions to mitigate this vulnerability. Additionally, sanitizing user input and using query parameterization can serve as temporary workarounds. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for django →
FAQ
The vulnerability allows for SQL injection attacks, potentially leading to unauthorized access to the database and data leakage.
Django versions 1.11.x, 2.1.x, and 2.2.x are affected by this vulnerability.
To fix this vulnerability, upgrade Django to the patched versions: 1.11.23, 2.1.11, or 2.2.4.
As a temporary workaround, sanitize user input and use query parameterization to prevent SQL injection attacks.
You can find more information about this vulnerability in the official Django security advisory: [link to advisory]
References
Related vulnerabilities
Recent vulnerabilities recorded for django.