CVE-2013-4315: Directory Traversal Vulnerability in Django

django Updated 02 Oct 2025

Summary

17/05/2022
Yes i
High
8.6

CVE-2013-4315: Django Directory Traversal via ssi template tag. Affects django across 2 version ranges.

>= 1.4, < 1.4.7 >= 1.5, < 1.5.3

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

Also tracked for

The same CVE-2013-4315 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 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

Django is a popular Python web framework known for its simplicity and versatility. It provides developers with a high-level API to build web applications rapidly. The vulnerability in question affects Django versions 1.4.x through 1.4.6, 1.5.x through 1.5.3, and 1.6.x through 1.6 beta 3. This vulnerability allows remote attackers to read arbitrary files by exploiting a directory traversal flaw in the ALLOWED_INCLUDE_ROOTS setting followed by a '..' (dot dot) in a ssi template tag.

Vulnerability Detail

The directory traversal vulnerability in Django arises from improper input validation. By manipulating the file path in the ALLOWED_INCLUDE_ROOTS setting and utilizing the '..' sequence in a ssi template tag, an attacker can bypass security measures and access arbitrary files on the server. This can lead to unauthorized disclosure of sensitive information, such as configuration files or user data. It is important to note that this vulnerability requires the ALLOWED_INCLUDE_ROOTS setting to be misconfigured.

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.

  • >= 1.4, < 1.4.7 1.4.7
    pip install --upgrade "django==1.4.7"
  • >= 1.5, < 1.5.3 1.5.3
    pip install --upgrade "django==1.5.3"

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. It involves validating and sanitizing user input to prevent directory traversal attacks. Here is an example of how to sanitize file paths in a Django view:

import os
from django.http import HttpResponse

def serve_file(request):
    file_path = request.GET.get('file_path', '')
    # Sanitize file_path to prevent directory traversal
    file_path = os.path.abspath(file_path)
    # Perform additional checks if necessary
    # ...
    # Serve the file
    with open(file_path, 'rb') as file:
        response = HttpResponse(file.read(), content_type='application/octet-stream')
        response['Content-Disposition'] = f'attachment; filename={os.path.basename(file_path)}'
        return response

This code snippet demonstrates how to sanitize the 'file_path' parameter received from a GET request. By using the os.path.abspath() function, the file path is resolved to an absolute path, preventing any directory traversal attempts.

Conclusion

The directory traversal vulnerability in Django versions 1.4.x through 1.4.6, 1.5.x through 1.5.3, and 1.6.x through 1.6 beta 3 poses a significant risk to the security of web applications. It allows remote attackers to read arbitrary files on the server, potentially leading to unauthorized disclosure of sensitive information. It is crucial to upgrade Django to the patched versions and properly configure the ALLOWED_INCLUDE_ROOTS setting to mitigate this 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 remote attackers to read arbitrary files on the server. This can lead to unauthorized disclosure of sensitive information and potential compromise of the application and its data.

Django versions 1.4.x through 1.4.6, 1.5.x through 1.5.3, and 1.6.x through 1.6 beta 3 are affected.

You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock, and Vulert will analyze it for open-source vulnerabilities in real-time.

Yes, a temporary workaround involves validating and sanitizing user input to prevent directory traversal attacks. Refer to the 'workaround' section for a code example.

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.

  • >= 1.4, < 1.4.7 1.4.7
    pip install --upgrade "django==1.4.7"
  • >= 1.5, < 1.5.3 1.5.3
    pip install --upgrade "django==1.5.3"

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