CVE-2021-45452: Directory Traversal Vulnerability in Django

django Updated 02 Oct 2025

Summary

05/01/2022
Yes i
Moderate
5.3

CVE-2021-45452: Storage.save in Django 2.2 before 2.2.26, 3.2 before 3.2.11, and 4.0 before 4.0.1 allows directory traversal if crafted filenames are directly passed to it. Affects django across 3 version ranges.

>= 2.2, < 2.2.26 >= 3.2, < 3.2.11 >= 4.0, < 4.0.1

Fixed in 2.2.26, 3.2.11 or 4.0.1, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-45452 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

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

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Django is a popular Python web framework known for its simplicity and scalability. It provides a comprehensive set of tools and libraries for building web applications. However, versions 2.2 before 2.2.26, 3.2 before 3.2.11, and 4.0 before 4.0.1 of Django are susceptible to a directory traversal vulnerability in the Storage.save function. This vulnerability allows an attacker to perform unauthorized file access by exploiting crafted filenames passed directly to the function.

Vulnerability Detail

The directory traversal vulnerability in Django's Storage.save function arises from insufficient input validation. When filenames are not properly sanitized, an attacker can manipulate them to traverse directories and access sensitive files on the server. This can lead to unauthorized disclosure of sensitive information, modification of critical files, or even remote code execution. It is crucial to address this vulnerability promptly to prevent potential exploitation.

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.2, < 2.2.26 2.2.26
    pip install --upgrade "django==2.2.26"
  • >= 3.2, < 3.2.11 3.2.11
    pip install --upgrade "django==3.2.11"
  • >= 4.0, < 4.0.1 4.0.1
    pip install --upgrade "django==4.0.1"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading Django is not immediately feasible, a temporary workaround can be implemented by implementing additional input validation and sanitization measures. Before passing filenames to the Storage.save function, ensure that they only contain valid characters and do not include any directory traversal sequences (e.g., '../'). Additionally, consider implementing access controls and permissions to restrict file access and prevent unauthorized directory traversal.

Conclusion

The directory traversal vulnerability in Django versions 2.2 before 2.2.26, 3.2 before 3.2.11, and 4.0 before 4.0.1 poses a significant risk to the security and integrity of web applications. It is crucial to upgrade Django to the recommended versions or implement temporary measures to mitigate the vulnerability. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for django →

Share this vulnerability

FAQ

The vulnerability allows attackers to access sensitive files on the server, potentially leading to unauthorized disclosure of information, file modification, or remote code execution.

Versions 2.2 before 2.2.26, 3.2 before 3.2.11, and 4.0 before 4.0.1 of Django are affected by this vulnerability.

There are no known instances of this vulnerability being exploited in the wild at the time of this report. However, it is crucial to address it promptly to prevent potential exploitation.

Yes, upgrading Django to version 2.2.26, 3.2.11, or 4.0.1 includes the necessary patches to mitigate this vulnerability.

Yes, you can implement additional input validation and sanitization measures to prevent directory traversal. Ensure filenames only contain valid characters and do not include any directory traversal sequences. Implement access controls and permissions to restrict file access.

Related vulnerabilities

Recent vulnerabilities recorded for django.

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.2, < 2.2.26 2.2.26
    pip install --upgrade "django==2.2.26"
  • >= 3.2, < 3.2.11 3.2.11
    pip install --upgrade "django==3.2.11"
  • >= 4.0, < 4.0.1 4.0.1
    pip install --upgrade "django==4.0.1"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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