Directory Traversal Vulnerability in Python-Django: CVE-2021-3281

python-django Updated 02 Oct 2025

Summary

01/02/2021
N/A
Yes i
Medium
5.3

UBUNTU-CVE-2021-3281: 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 a... Affects python-django versions < 1.6.11-0ubuntu1.3+esm2. Fixed in 1.6.11-0ubuntu1.3+esm2. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Python-Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It is widely used for building web applications and provides a robust set of features, including an ORM, routing, and templating. However, certain versions of Django are vulnerable to a directory traversal issue, which can allow attackers to manipulate file paths and access unauthorized directories.

Vulnerability Detail

The vulnerability identified as CVE-2021-3281 affects Django versions 2.2 before 2.2.18, 3.0 before 3.0.12, and 3.1 before 3.1.6. It arises from the django.utils.archive.extract method, which is used by commands like 'startapp --template' and 'startproject --template'. This flaw allows for directory traversal through archives containing absolute paths or relative paths with dot segments, potentially leading to unauthorized access to sensitive files on the server.

How To Fix

Minimum fixed version

1.6.11-0ubuntu1.3+esm2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python-django

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid using the 'startapp --template' and 'startproject --template' commands with untrusted archives until the package has been updated to a secure version.

Conclusion

CVE-2021-3281 is a significant vulnerability in Django that can lead to directory traversal attacks. It is crucial for users to update their Django installations to the patched versions to mitigate this risk. For those unable to update immediately, following the provided workaround is advisable.

See every vulnerability recorded for python-django →

Share this vulnerability

FAQ

CVE-2021-3281 is a vulnerability in Django that allows directory traversal through certain commands, potentially exposing sensitive files.

Django versions 2.2 before 2.2.18, 3.0 before 3.0.12, and 3.1 before 3.1.6 are affected by this vulnerability.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The CVSS score of CVE-2021-3281 is 5.3, indicating a medium severity level.

If you cannot update immediately, avoid using the vulnerable commands with untrusted archives as a temporary workaround.

Related vulnerabilities

Recent vulnerabilities recorded for python-django.

How To Fix

Minimum fixed version

1.6.11-0ubuntu1.3+esm2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python-django

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback