CVE-2021-35042 SQL Injection in Django

Critical 9.8 Published Updated

Attackers can execute arbitrary SQL commands via untrusted input in QuerySet.order_by, potentially reading or modifying database contents.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2021-35042?

CVE-2021-35042 is a critical SQL injection vulnerability in Djangoproject Django, published on 2 Jul 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

Django 3.1.x before 3.1.13 and 3.2.x before 3.2.5 allows QuerySet.order_by SQL injection if order_by is untrusted input from a client of a web application.

Weakness: CWE-89

Which versions are affected by CVE-2021-35042?

6 open source packages ship an affected version, including django and Django. It affects 2 products.

PackageAffectedFixed in
django BitnamiFrom 3.1.03.1.13, 3.2.5
django PyPIFrom 3.0a13.1.13
django PyPIFrom 3.13.1.13, 3.2.5
django PyPIFrom 3.2a13.2.5
Django PyPIFrom 3.0a13.1.13
Django PyPIFrom 3.2a13.2.5

Products include Djangoproject Django, Fedoraproject Fedora.

How do I fix CVE-2021-35042?

Upgrade django to a fixed version for your release line: 3.1.13 or 3.2.5.

Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.

Is CVE-2021-35042 being exploited?

There is no known exploitation of CVE-2021-35042 in the wild and no public exploit code.

Public exploit code: 6 proofs of concept on GitHub.

All Djangoproject Django vulnerabilities

Sources

Also known as BIT-django-2021-35042, GHSA-xpfp-f569-q3p2, PYSEC-2021-109.

Is CVE-2021-35042 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free