CVE-2024-39330: Django Path Traversal vulnerability

django Updated 02 Oct 2025

Summary

10/07/2024
Yes i
High
7.5

CVE-2024-39330: Django Path Traversal vulnerability. Affects django across 2 version ranges.

>= 4.2, < 4.2.14 >= 5.0, < 5.0.7

Fixed in 4.2.14 or 5.0.7, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2024-39330 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 that simplifies the development of web applications. It provides various features and utilities for handling web requests, managing databases, and rendering templates. The vulnerability in question affects Django versions 5.0 before 5.0.7 and 4.2 before 4.2.14. It specifically impacts derived classes of the django.core.files.storage.Storage base class that override the generate_filename() method without replicating the file-path validations from the parent class. This oversight potentially allows for directory traversal attacks when certain inputs are provided during a save() call. It's important to note that built-in Storage subclasses are not affected by this vulnerability.

Vulnerability Detail

The Django Path Traversal vulnerability arises due to the lack of proper file-path validations in derived classes of the django.core.files.storage.Storage base class. When developers override the generate_filename() method without including the necessary validations, it opens up the possibility of directory traversal attacks. An attacker could exploit this vulnerability by providing malicious inputs during a save() call, potentially allowing them to access files outside of the intended directory. This could lead to unauthorized access, data leakage, or even remote code execution depending on the context in which the vulnerable code is used.

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.

  • >= 4.2, < 4.2.14 4.2.14
    pip install --upgrade "django==4.2.14"
  • >= 5.0, < 5.0.7 5.0.7
    pip install --upgrade "django==5.0.7"

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

Workaround

If immediate updating is not feasible, developers can implement a workaround by manually adding the file-path validations to the overridden generate_filename() method in their derived classes. The following code snippet demonstrates an example of how this can be done:

from django.core.files.storage import Storage


class CustomStorage(Storage):
    def generate_filename(self, filename):
        # Add file-path validations here
        # to prevent directory traversal
        # ... (existing code)
        # ... (additional validations)
        # ... (return the sanitized filename)
        pass

By incorporating the necessary validations, developers can safeguard against directory traversal attacks until they can update to the fixed Django versions.

Conclusion

The Django Path Traversal vulnerability (CVE-2024-39330) affects Django versions 5.0 before 5.0.7 and 4.2 before 4.2.14. It arises due to the lack of proper file-path validations in derived classes of the django.core.files.storage.Storage base class. Attackers can exploit this vulnerability to perform directory traversal attacks and potentially gain unauthorized access or execute arbitrary code. Developers should update to the fixed Django versions and ensure that their codebase includes the necessary file-path validations to mitigate this vulnerability.

See every vulnerability recorded for django →

Share this vulnerability

FAQ

Django is a Python web framework that simplifies web application development. It provides various tools and utilities for handling web requests, managing databases, and rendering templates.

The vulnerability affects Django versions 5.0 before 5.0.7 and 4.2 before 4.2.14.

No, built-in Storage subclasses are not affected by this vulnerability. Only derived classes that override the generate_filename() method without including the necessary file-path validations are vulnerable.

The vulnerability could allow attackers to perform directory traversal attacks, potentially leading to unauthorized access, data leakage, or even remote code execution depending on the context in which the vulnerable code is used.

Developers should update to the latest Django versions (5.0.7 or 4.2.14) that include the fix. They should also review their codebase and ensure that any derived classes of the django.core.files.storage.Storage base class properly replicate the file-path validations from the parent class within their overridden generate_filename() method.

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.

  • >= 4.2, < 4.2.14 4.2.14
    pip install --upgrade "django==4.2.14"
  • >= 5.0, < 5.0.7 5.0.7
    pip install --upgrade "django==5.0.7"

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