SQL injection in Django - CVE-2020-7471

 

SQL injection in Django - CVE-2020-7471

Published: February 3, 2020 / Updated: September 1, 2021


Vulnerability identifier: #VU24846
CSH Severity: Medium
CVSS v4: 6.3 [CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N]
CVE-ID: CVE-2020-7471
CWE-ID: CWE-89
Exploitation vector: Remote access
Exploit availability: Public exploit is available

Vulnerability details

The vulnerability allows a remote attacker to execute arbitrary SQL queries in database.

The vulnerability exists due to insufficient sanitization of user-supplied data if untrusted data is used as a StringAgg delimiter (e.g., in Django applications that offer downloads of data as a series of rows with a user-specified column delimiter). By passing a suitably crafted delimiter to a contrib.postgres.aggregates.StringAgg instance, it was possible to break escaping and inject malicious SQL in Django 1.11 before 1.11.28, 2.2 before 2.2.10, and 3.0 before 3.0.3. A remote attacker can send a specially crafted request to the affected application and execute arbitrary SQL commands within the application database.

Successful exploitation of this vulnerability may allow a remote attacker to read, delete, modify data in database and gain complete control over the affected application.


Affected software

Django
Gentoo Linux
Arch Linux
Fedora
python-django (Debian package)
py-django (Alpine package)
py3-django (Alpine package)
python-django

How to mitigate CVE-2020-7471

Install update from vendor's website.

Django - addressed in versions 1.11.28, 2.2.10, 3.0.3
python-django (Debian package) - addressed in versions 1:1.10.7-2+deb9u8, 1:1.11.28-1~deb10u1
py-django (Alpine package) - update to 1.11.28-r0
py3-django (Alpine package) - update to 1.11.28-r0
python-django - addressed in versions 2.2.13-1.el8, 2.2.13-1.fc31, 3.0.7-1.fc32

Links to Public Exploits and PoC-codes

External References

Related Security Bulletins