CVE-2022-34265 Django `Trunc()` and `Extract()` database functions vulnerable to SQL Injection

Critical 9.8 Published Updated

Attackers can execute arbitrary SQL commands via untrusted input in Django's Trunc and Extract database functions, potentially compromising data integrity and confidentiality.

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

What is CVE-2022-34265?

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

Official description

An issue was discovered in Django 3.2 before 3.2.14 and 4.0 before 4.0.6. The Trunc() and Extract() database functions are subject to SQL injection if untrusted data is used as a kind/lookup_name value. Applications that constrain the lookup name and kind choice to a known safe list are unaffected.

Weakness: CWE-89

Which versions are affected by CVE-2022-34265?

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

PackageAffectedFixed in
django BitnamiFrom 3.2.03.2.14, 4.0.6
django PyPIFrom 3.23.2.14, 4.0.6
django PyPIFrom 3.2a13.2.14
django PyPIFrom 4.0a14.0.6
Django PyPIFrom 3.2a13.2.14
Django PyPIFrom 4.0a14.0.6
Linux distribution packages (3)
python-django Red Hat:rhui:4::el8All versions0:3.2.14-3.el8ui
python38-django Red Hat:rhui:4::el8All versions0:3.2.14-3.el8ui
python-Django openSUSE:TumbleweedAll versions4.0.6-1.1

Products include Djangoproject Django.

How do I fix CVE-2022-34265?

Upgrade django to a fixed version for your release line: 3.2.14 or 4.0.6.

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-2022-34265 being exploited?

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

Public exploit code: 5 proofs of concept on GitHub.

All Djangoproject Django vulnerabilities

Sources

Also known as BIT-django-2022-34265, DEBIAN-CVE-2022-34265, GHSA-p64x-8rxx-wf6q, PYSEC-2022-213, RHSA-2022:5738, UBUNTU-CVE-2022-34265 and 2 more.

Is CVE-2022-34265 in your software?

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

Check your SBOMs for free