CVE-2020-7471: Django SQL Injection Vulnerability

django Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Critical
Not published

CVE-2020-7471: Django 1.11 before 1.11.28, 2.2 before 2.2.10, and 3.0 before 3.0.3 allows SQL Injection if untrusted data is used as a StringAgg delimiter (e.g., in Django applications that offer downloads of data as a series of rows w... Affects django across 3 version ranges.

>= 1.11.0, < 1.11.28 >= 2.2.0, < 2.2.10 >= 3.0.0, < 3.0.3

Fixed in 1.11.28, 2.2.10 or 3.0.3, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2020-7471 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

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

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 high-level development environment for building secure and scalable web applications. The vulnerability identified as CVE-2020-7471 affects Django versions 1.11 to 1.11.28, 2.2 to 2.2.10, and 3.0 to 3.0.3. This vulnerability allows for SQL Injection when untrusted data is used as a StringAgg delimiter in Django applications that offer downloads of data as a series of rows with a user-specified column delimiter. By exploiting this vulnerability, an attacker can inject malicious SQL queries by passing a specially crafted delimiter to a contrib.postgres.aggregates.StringAgg instance, bypassing escaping mechanisms.

Vulnerability Detail

The vulnerability arises from a lack of proper input validation and sanitization when using untrusted data as a delimiter in the StringAgg class. This can lead to SQL Injection attacks, where an attacker can manipulate the SQL queries executed by the application. The impact of this vulnerability can be severe, allowing an attacker to extract sensitive data, modify or delete data, or even execute arbitrary commands on the underlying database server. It is crucial to address this vulnerability promptly to prevent potential data breaches and unauthorized access.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • >= 1.11.0, < 1.11.28 1.11.28
  • >= 2.2.0, < 2.2.10 2.2.10
  • >= 3.0.0, < 3.0.3 3.0.3

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, developers can manually validate and sanitize the delimiter input before passing it to the StringAgg class. This can be done by implementing a custom validation function that checks for any potentially malicious characters or patterns in the delimiter. Additionally, it is recommended to enforce strict input validation and sanitization practices throughout the application to mitigate the risk of other potential vulnerabilities.

Conclusion

The Django SQL Injection vulnerability (CVE-2020-7471) poses a significant risk to applications utilizing affected versions of Django. It is crucial to promptly upgrade to the patched versions and implement proper input validation and sanitization practices to prevent potential SQL Injection attacks. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for django →

Share this vulnerability

FAQ

The vulnerability allows for SQL Injection attacks, which can lead to unauthorized access, data manipulation, and potential data breaches.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply upload your package-lock.json file to the playground, and it will analyze and alert you if any open-source vulnerabilities, including CVE-2020-7471, are detected.

At the time of this report, there are no known public exploits for this vulnerability. However, it is crucial to address it promptly to prevent potential exploitation.

Yes, patches have been released to address this vulnerability. It is recommended to upgrade Django to the latest patched version as mentioned in the 'how_to_fix' section.

While implementing strict input validation is essential, it is not sufficient to mitigate this vulnerability entirely. Upgrading to the patched versions of Django is necessary to ensure the proper fix is in place.

Related vulnerabilities

Recent vulnerabilities recorded for django.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • >= 1.11.0, < 1.11.28 1.11.28
  • >= 2.2.0, < 2.2.10 2.2.10
  • >= 3.0.0, < 3.0.3 3.0.3

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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