CVE-2022-34265 Django `Trunc()` and `Extract()` database functions vulnerable to SQL Injection
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.
| Package | Affected | Fixed in |
|---|---|---|
django Bitnami | From 3.2.0 | 3.2.14, 4.0.6 |
django PyPI | From 3.2 | 3.2.14, 4.0.6 |
django PyPI | From 3.2a1 | 3.2.14 |
django PyPI | From 4.0a1 | 4.0.6 |
Django PyPI | From 3.2a1 | 3.2.14 |
Django PyPI | From 4.0a1 | 4.0.6 |
Linux distribution packages (3)
python-django Red Hat:rhui:4::el8 | All versions | 0:3.2.14-3.el8ui |
python38-django Red Hat:rhui:4::el8 | All versions | 0:3.2.14-3.el8ui |
python-Django openSUSE:Tumbleweed | All versions | 4.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.
Other vulnerabilities in Djangoproject Django
- CVE-2026-4277 Privilege abuse in GenericInlineModelAdmin
- CVE-2024-53908 Django SQL injection in HasKey(lhs, rhs) on Oracle
- CVE-2024-42005 Django SQL injection vulnerability
- CVE-2023-31047 Django bypasses validation when using one form field to upload multiple files
- CVE-2021-35042 SQL Injection in Django
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.