Directory Traversal Vulnerability in python-django

python-django Updated 02 Oct 2025

Summary

04/08/2009
N/A
Yes i
Unrated
Not published

CVE-2009-2659: The Admin media handler in core/servers/basehttp.py in Django 1.0 and 0.96 does not properly map URL requests to expected "static media files," which allows remote attackers to conduct directory traversal attacks and rea... Affects python-django versions < 1.1-1. Fixed in 1.1-1. 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

python-django is a popular web framework for building web applications using the Python programming language. It provides a high-level API for handling web requests and generating dynamic web content. The vulnerability in python-django allows remote attackers to conduct directory traversal attacks and read arbitrary files by exploiting a flaw in the Admin media handler.

Vulnerability Detail

The Admin media handler in python-django does not properly map URL requests to expected "static media files." This allows an attacker to manipulate the URL and traverse directories to access files outside the intended scope. By crafting a malicious URL, an attacker can read sensitive files on the server, potentially exposing confidential information or gaining unauthorized access.

How To Fix

Minimum fixed version

1.1-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

If upgrading python-django is not immediately feasible, a temporary workaround is to implement access controls and input validation to prevent directory traversal attacks. This can be done by validating user input and restricting access to sensitive files and directories. Here is an example of how to implement input validation in Python:

import os

def validate_path(path):
    # Check if the path is within the allowed directory
    allowed_directory = '/path/to/static/media'
    full_path = os.path.join(allowed_directory, path)
    if os.path.realpath(full_path).startswith(allowed_directory):
        return True
    else:
        return False

This code snippet checks if the requested path is within the allowed directory and returns a boolean value indicating the validity of the path. It can be used to validate user input before serving static media files.

Conclusion

The directory traversal vulnerability in python-django allows remote attackers to read arbitrary files on the server. It is recommended to upgrade to version 1.1-1 or later to mitigate this vulnerability. If immediate upgrade is not possible, implementing access controls and input validation can provide temporary protection. For further assistance with vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for python-django →

Share this vulnerability

FAQ

The vulnerability allows an attacker to read arbitrary files on the server, potentially exposing sensitive information or gaining unauthorized access.

Yes, there are known exploits for this vulnerability. Attackers can craft malicious URLs to traverse directories and access files outside the intended scope.

No, only versions 0.96 and 1.0 of python-django are affected. The vulnerability was fixed in version 1.1-1.

Yes, this vulnerability can be exploited remotely. Attackers can send crafted requests to the affected server to exploit the directory traversal flaw.

Yes, a patch is available for this vulnerability. Users should upgrade to version 1.1-1 or later of python-django to fix the issue.

Related vulnerabilities

Recent vulnerabilities recorded for python-django.

How To Fix

Minimum fixed version

1.1-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 →

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