Directory Traversal Vulnerability in Django Package
Summary
CVE-2021-33203: Django before 2.2.24, 3.x before 3.1.12, and 3.2.x before 3.2.4 has a potential directory traversal via django.contrib.admindocs. Affects python-django across 2 version ranges.
< 2:2.2.24-1
< 2da029d8540ab0b2e9edcba25c4d46c52853197f
Fixed in 2:2.2.24-1. How to fix ↓
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 high-level Python web framework that encourages rapid development and clean, pragmatic design. It provides a robust set of features for building web applications, including an admin interface, ORM, and templating engine. However, certain versions of Django are vulnerable to a directory traversal issue that could expose sensitive files to unauthorized users.
Vulnerability Detail
Django versions prior to 2.2.24, 3.x before 3.1.12, and 3.2.x before 3.2.4 are susceptible to a directory traversal vulnerability via django.contrib.admindocs. This flaw allows staff members to use the TemplateDetailView view to check for the existence of arbitrary files. If the default admindocs templates have been customized to display file contents, this could lead to unauthorized exposure of sensitive information. The vulnerability arises from improper handling of file paths, enabling attackers to traverse outside the intended directories.
How To Fix
Minimum fixed version
2:2.2.24-1
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, you can restrict access to the admindocs feature by modifying your Django settings. Disable the admindocs app in your INSTALLED_APPS list:
INSTALLED_APPS = [ ... # 'django.contrib.admindocs', # Comment this line out ...
]
Conclusion
The directory traversal vulnerability in Django poses a significant risk to applications using affected versions. It is crucial to update to the latest secure version to mitigate this risk. Additionally, implementing workarounds can provide temporary relief until a proper fix is applied.
See every vulnerability recorded for python-django →
FAQ
A directory traversal vulnerability allows an attacker to access files and directories that are stored outside the intended directory. This can lead to unauthorized access to sensitive information.
Django versions before 2.2.24, 3.x before 3.1.12, and 3.2.x before 3.2.4 are affected by this vulnerability.
You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.
If exploited, this vulnerability could allow unauthorized users to view sensitive files, leading to data breaches and potential compromise of the application.
The CVSS score for this vulnerability is 4.9, indicating a moderate level of severity.
References
Related vulnerabilities
Recent vulnerabilities recorded for python-django.