SQL Injection Vulnerability in Django

py-django Updated 02 Oct 2025

Summary

09/08/2019
N/A
Yes i
Critical
9.8

CVE-2019-14234: An issue was discovered in Django 1.11.x before 1.11.23, 2.1.x before 2.1.11, and 2.2.x before 2.2.4. Affects py-django across 2 version ranges.

< 1.11.23-r0 >= 58f02c498b659a906e9c30d946bd89bedc4717e5, < 974897759e9afc4cc56fb87e12319fa9697e93c9

Fixed in 1.11.23-r0. How to fix ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Django is a popular open-source web framework written in Python. It provides a set of tools and libraries for building web applications quickly and efficiently. The framework includes various components, such as the django.contrib.postgres.fields.JSONField and django.contrib.postgres.fields.HStoreField, which allow developers to work with JSON and HStore data types in PostgreSQL databases. However, a vulnerability has been discovered in versions 1.11.x, 2.1.x, and 2.2.x of Django, which can lead to SQL injection attacks.

Vulnerability Detail

The SQL injection vulnerability in Django arises from an error in shallow key transformation. Specifically, it affects key and index lookups for the JSONField and key lookups for the HStoreField. An attacker can exploit this vulnerability by crafting a key or index name with malicious SQL code, such as "OR 1=1", to manipulate the database query and potentially retrieve unauthorized data. This can be achieved 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 allows an attacker to execute arbitrary SQL queries and potentially gain unauthorized access to sensitive data.

How To Fix

Minimum fixed version

1.11.23-r0

This is the first release that contains the fix.

sudo apk add --upgrade py-django

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, developers can manually sanitize and validate user input before using it in database queries. This can be achieved by implementing proper input validation and parameterized queries to ensure that user-supplied data is treated as data and not as part of the SQL query itself. Here is an example of how to use parameterized queries in Django to mitigate the SQL injection vulnerability:

from django.db import connection

def get_user_data(username):
    with connection.cursor() as cursor:
        cursor.execute('SELECT * FROM users WHERE username = %s', [username])
        user_data = cursor.fetchall()
    return user_data

Conclusion

The SQL injection vulnerability in Django versions 1.11.x, 2.1.x, and 2.2.x can lead to unauthorized access to sensitive data stored in the database. It is crucial for developers to upgrade their Django installations to the latest patched versions and implement proper input validation and parameterized queries to prevent SQL injection attacks. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for py-django →

Share this vulnerability

FAQ

The SQL injection vulnerability in Django can allow an attacker to execute arbitrary SQL queries and potentially gain unauthorized access to sensitive data stored in the database.

Versions 1.11.x, 2.1.x, and 2.2.x of Django are affected by this SQL injection vulnerability.

You can use the Vulert Playground (https://vulert.com/scanner) to check if your Django application is affected by this SQL injection vulnerability. Simply upload your package-lock.json file to the playground, and it will analyze your dependencies and alert you if any vulnerabilities are found.

While specific exploits for this SQL injection vulnerability in Django have not been disclosed, it is important to promptly apply the recommended patches and follow secure coding practices to mitigate the risk of exploitation.

For more information about this SQL injection vulnerability in Django, you can refer to the official CVE-2019-14234 entry at the National Vulnerability Database (NVD) or the Django project's security advisory.

Related vulnerabilities

Recent vulnerabilities recorded for py-django.

How To Fix

Minimum fixed version

1.11.23-r0

This is the first release that contains the fix.

sudo apk add --upgrade py-django

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback