CVE-2021-28658: Directory Traversal in Django
Summary
CVE-2021-28658: Directory Traversal in Django. Affects django across 3 version ranges.
>= 2.2a1, < 2.2.20
>= 3.0a1, < 3.0.14
>= 3.1a1, < 3.1.8
Fixed in 2.2.20, 3.0.14 or 3.1.8, depending on the release line you run. How to fix ↓
Also tracked for
- django · Bitnami
- python-django · Debian:11
The same CVE-2021-28658 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
Django is a popular Python web framework known for its simplicity and scalability. It provides a robust set of tools and features for building web applications. However, versions 2.2 before 2.2.20, 3.0 before 3.0.14, and 3.1 before 3.1.8 of Django are vulnerable to a directory traversal attack. This vulnerability allows an attacker to bypass file upload restrictions and access files outside of the intended directory.
Vulnerability Detail
The directory traversal vulnerability in Django arises from a flaw in the MultiPartParser. By uploading files with specially crafted names, an attacker can manipulate the file path and traverse directories to access sensitive files on the server. This can lead to unauthorized disclosure of sensitive information or even remote code execution if the accessed files contain executable code. It is important to note that built-in upload handlers are not affected by this vulnerability.
How To Fix
Latest published version: 6.1.2 as of 22 Oct 2026
pip install --upgrade "django==6.1.2"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
>= 2.2a1, < 2.2.202.2.20pip install --upgrade "django==2.2.20" -
>= 3.0a1, < 3.0.143.0.14pip install --upgrade "django==3.0.14" -
>= 3.1a1, < 3.1.83.1.8pip install --upgrade "django==3.1.8"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
There is no known workaround for this vulnerability. It is essential to apply the official patches by upgrading Django to the fixed versions.
Conclusion
The directory traversal vulnerability in Django can have serious consequences if left unpatched. It is highly recommended to upgrade to the fixed versions of Django to mitigate the risk of unauthorized file access and potential remote code execution. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for django →
FAQ
The vulnerability allows an attacker to access sensitive files on the server, potentially leading to unauthorized disclosure of information or remote code execution.
No, only versions 2.2 before 2.2.20, 3.0 before 3.0.14, and 3.1 before 3.1.8 are vulnerable. It is recommended to upgrade to the fixed versions.
Yes, an attacker can exploit this vulnerability remotely by uploading specially crafted files to the affected Django application.
There are no known instances of this vulnerability being exploited in the wild at the time of this report. However, it is crucial to apply the necessary patches to prevent any potential exploitation.
Yes, the CVSS score for this vulnerability is 5.3, indicating a moderate severity level.
Related vulnerabilities
Recent vulnerabilities recorded for django.