SQL injection in Django - CVE-2020-7471
Published: February 3, 2020 / Updated: September 1, 2021
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
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
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
- Exploit #6677 - CVE-2020-7471 (Reproduce CVE-2020-7471) (September 1, 2021)
- Exploit #5520 - CVE-2020-7471-Django (PoC for the SQL injection vulnerability in PostgreSQL with Django, found in Django 1.11 before 1.11.28, 2.2 before 2.2.10, and 3.0 before 3.0.3) (June 3, 2021)
- Exploit #4546 - cve-2020-7471-Time_Blind_SQLi- () (September 1, 2020)
- Exploit #3931 - CTF_CVE-2020-7471 () (August 10, 2020)
- Exploit #2844 - DjVul_StringAgg (Django StringAgg SQL Injection (CVE-2020-7471)) (June 3, 2020)
- Exploit #2845 - CVE-2020-7471 (django 漏洞:CVE-2020-7471 Potential SQL injection via StringAgg(delimiter) 的漏洞环境和 POC) (June 3, 2020)
- Exploit #2857 - CVE-2020-7471 (CVE-2020-7471 Potential SQL injection via StringAgg(delimiter)) (June 3, 2020)
External References
Related Security Bulletins
- SQL injection in Django
- Arch Linux update for python-django
- Debian update for python-django
- Gentoo update for Django
- SQL injection in py-django (Alpine package)
- SQL injection in py3-django (Alpine package)
- Fedora 32 update for python-django
- Fedora 31 update for python-django
- Fedora EPEL 8 update for python-django