CVE-2021-3281 Django Directory Traversal via archive.extract
Attackers can exploit directory traversal in Django's archive extraction to read or modify files outside the intended directory during project initialization.
- 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-3281?
CVE-2021-3281 is a medium-severity path traversal vulnerability in Djangoproject Django, published on 2 Feb 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
In Django 2.2 before 2.2.18, 3.0 before 3.0.12, and 3.1 before 3.1.6, the django.utils.archive.extract method (used by "startapp --template" and "startproject --template") allows directory traversal via an archive with absolute paths or relative paths with dot segments.
Weakness: CWE-22
Which versions are affected by CVE-2021-3281?
8 open source packages ship an affected version, including django and Django. It affects 3 products.
| Package | Affected | Fixed in |
|---|---|---|
django Bitnami | From 2.2.0 | 2.2.18, 3.0.12, 3.1.6 |
django PyPI | From 2.2 | 2.2.18, 3.0.12, 3.1.6 |
django PyPI | From 2.2 | 2.2.18 |
django PyPI | From 3.0 | 3.0.12 |
django PyPI | From 3.1 | 3.1.6 |
Django PyPI | From 2.2 | 2.2.18 |
2 more packages
Django PyPI | From 3.0 | 3.0.12 |
Django PyPI | From 3.1 | 3.1.6 |
Linux distribution packages (29)
ardana-db SUSE:OpenStack Cloud 9 | All versions | 9.0+git.1611600773.5f1de5f-3.22.1 |
ardana-horizon SUSE:OpenStack Cloud 9 | All versions | 9.0+git.1610491814.38661c2-3.16.1 |
ardana-logging SUSE:OpenStack Cloud 9 | All versions | 9.0+git.1610490922.d5f9813-3.16.1 |
ardana-monasca SUSE:OpenStack Cloud 9 | All versions | 9.0+git.1610547641.d79ecfd-3.22.1 |
ardana-opsconsole-ui SUSE:OpenStack Cloud 9 | All versions | 9.0+git.1611867924.eb82818-4.16.1 |
ardana-osconfig SUSE:OpenStack Cloud 9 | All versions | 9.0+git.1610634027.5934cf8-3.25.1 |
kibana SUSE:OpenStack Cloud 9 | All versions | 4.6.3-4.6.1 |
openstack-dashboard SUSE:OpenStack Cloud 9 | All versions | 14.1.1~dev10-3.21.3 |
openstack-manila SUSE:OpenStack Cloud 9 | All versions | 7.4.2~dev60-4.33.2 |
openstack-neutron SUSE:OpenStack Cloud 9 | All versions | 13.0.8~dev147-3.34.2 |
openstack-neutron-gbp SUSE:OpenStack Cloud 9 | All versions | 12.0.1~dev16-3.22.2 |
openstack-nova SUSE:OpenStack Cloud 9 | All versions | 18.3.1~dev78-3.34.2 |
python-Django1 SUSE:OpenStack Cloud 9 | All versions | 1.11.29-3.18.2 |
release-notes-suse-openstack-cloud SUSE:OpenStack Cloud 9 | All versions | 9.20201214-3.27.2 |
venv-openstack-horizon SUSE:OpenStack Cloud 9 | All versions | 14.1.1~dev10-4.25.2 |
venv-openstack-manila SUSE:OpenStack Cloud 9 | All versions | 7.4.2~dev60-3.27.2 |
venv-openstack-neutron SUSE:OpenStack Cloud 9 | All versions | 13.0.8~dev147-6.25.2 |
venv-openstack-nova SUSE:OpenStack Cloud 9 | All versions | 18.3.1~dev78-3.25.2 |
crowbar-core SUSE:OpenStack Cloud Crowbar 9 | All versions | 6.0+git.1611320924.849e748ff-3.34.1 |
crowbar-openstack SUSE:OpenStack Cloud Crowbar 9 | All versions | 6.0+git.1610402342.21499240d-3.31.1 |
kibana SUSE:OpenStack Cloud Crowbar 9 | All versions | 4.6.3-4.6.1 |
openstack-dashboard SUSE:OpenStack Cloud Crowbar 9 | All versions | 14.1.1~dev10-3.21.3 |
openstack-manila SUSE:OpenStack Cloud Crowbar 9 | All versions | 7.4.2~dev60-4.33.2 |
openstack-neutron SUSE:OpenStack Cloud Crowbar 9 | All versions | 13.0.8~dev147-3.34.2 |
openstack-neutron-gbp SUSE:OpenStack Cloud Crowbar 9 | All versions | 12.0.1~dev16-3.22.2 |
openstack-nova SUSE:OpenStack Cloud Crowbar 9 | All versions | 18.3.1~dev78-3.34.2 |
python-Django1 SUSE:OpenStack Cloud Crowbar 9 | All versions | 1.11.29-3.18.2 |
release-notes-suse-openstack-cloud SUSE:OpenStack Cloud Crowbar 9 | All versions | 9.20201214-3.27.2 |
sleshammer SUSE:OpenStack Cloud Crowbar 9 | All versions | 0.9.0-7.6.1 |
Products include Djangoproject Django, Fedoraproject Fedora, Netapp Snapcenter.
How do I fix CVE-2021-3281?
Upgrade django to a fixed version for your release line: 2.2.18, 3.0.12 or 3.1.6.
Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.
Is CVE-2021-3281 being exploited?
There is no known exploitation of CVE-2021-3281 in the wild and no public exploit code.
Public exploit code: 1 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-2022-34265 Django `Trunc()` and `Extract()` database functions vulnerable to SQL Injection
Sources
Also known as BIT-django-2021-3281, DEBIAN-CVE-2021-3281, DLA-2540-1, GHSA-fvgf-6h6h-3322, PYSEC-2021-9, SUSE-RU-2021:0497-1 and 3 more.