CVE-2021-3281 Django Directory Traversal via archive.extract

Medium 5.3 Published Updated

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.

PackageAffectedFixed in
django BitnamiFrom 2.2.02.2.18, 3.0.12, 3.1.6
django PyPIFrom 2.22.2.18, 3.0.12, 3.1.6
django PyPIFrom 2.22.2.18
django PyPIFrom 3.03.0.12
django PyPIFrom 3.13.1.6
Django PyPIFrom 2.22.2.18
2 more packages
Django PyPIFrom 3.03.0.12
Django PyPIFrom 3.13.1.6
Linux distribution packages (29)
ardana-db SUSE:OpenStack Cloud 9All versions9.0+git.1611600773.5f1de5f-3.22.1
ardana-horizon SUSE:OpenStack Cloud 9All versions9.0+git.1610491814.38661c2-3.16.1
ardana-logging SUSE:OpenStack Cloud 9All versions9.0+git.1610490922.d5f9813-3.16.1
ardana-monasca SUSE:OpenStack Cloud 9All versions9.0+git.1610547641.d79ecfd-3.22.1
ardana-opsconsole-ui SUSE:OpenStack Cloud 9All versions9.0+git.1611867924.eb82818-4.16.1
ardana-osconfig SUSE:OpenStack Cloud 9All versions9.0+git.1610634027.5934cf8-3.25.1
kibana SUSE:OpenStack Cloud 9All versions4.6.3-4.6.1
openstack-dashboard SUSE:OpenStack Cloud 9All versions14.1.1~dev10-3.21.3
openstack-manila SUSE:OpenStack Cloud 9All versions7.4.2~dev60-4.33.2
openstack-neutron SUSE:OpenStack Cloud 9All versions13.0.8~dev147-3.34.2
openstack-neutron-gbp SUSE:OpenStack Cloud 9All versions12.0.1~dev16-3.22.2
openstack-nova SUSE:OpenStack Cloud 9All versions18.3.1~dev78-3.34.2
python-Django1 SUSE:OpenStack Cloud 9All versions1.11.29-3.18.2
release-notes-suse-openstack-cloud SUSE:OpenStack Cloud 9All versions9.20201214-3.27.2
venv-openstack-horizon SUSE:OpenStack Cloud 9All versions14.1.1~dev10-4.25.2
venv-openstack-manila SUSE:OpenStack Cloud 9All versions7.4.2~dev60-3.27.2
venv-openstack-neutron SUSE:OpenStack Cloud 9All versions13.0.8~dev147-6.25.2
venv-openstack-nova SUSE:OpenStack Cloud 9All versions18.3.1~dev78-3.25.2
crowbar-core SUSE:OpenStack Cloud Crowbar 9All versions6.0+git.1611320924.849e748ff-3.34.1
crowbar-openstack SUSE:OpenStack Cloud Crowbar 9All versions6.0+git.1610402342.21499240d-3.31.1
kibana SUSE:OpenStack Cloud Crowbar 9All versions4.6.3-4.6.1
openstack-dashboard SUSE:OpenStack Cloud Crowbar 9All versions14.1.1~dev10-3.21.3
openstack-manila SUSE:OpenStack Cloud Crowbar 9All versions7.4.2~dev60-4.33.2
openstack-neutron SUSE:OpenStack Cloud Crowbar 9All versions13.0.8~dev147-3.34.2
openstack-neutron-gbp SUSE:OpenStack Cloud Crowbar 9All versions12.0.1~dev16-3.22.2
openstack-nova SUSE:OpenStack Cloud Crowbar 9All versions18.3.1~dev78-3.34.2
python-Django1 SUSE:OpenStack Cloud Crowbar 9All versions1.11.29-3.18.2
release-notes-suse-openstack-cloud SUSE:OpenStack Cloud Crowbar 9All versions9.20201214-3.27.2
sleshammer SUSE:OpenStack Cloud Crowbar 9All versions0.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.

All Djangoproject Django vulnerabilities

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.

Is CVE-2021-3281 in your software?

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

Check your SBOMs for free