CVE Professor
/
All CVEs
CVE-2026-124827

CVE-2026-124827 — Djangoproject Django (6.1.4) — CWE-73

HIGH CVSS 8.8 CVE.org

An issue was discovered in Django 6.1 before 6.1.4, 6.0 before 6.0.11, and 5.2 before 5.2.20. `django.contrib.gis.db.models.RasterField` allows the creation of files at attacker-controlled locations via the `name` parameter of a data definition. Depending on the raster driver, this could enable remote code execution. Earlier, unsupported Django series (such as 5.1.x, 5.0.x, and 4.2.x) were not evaluated and may also be affected. Django would like to thank Mohammed Fathy for reporting this issue.

An issue was discovered in Django 6.1 before 6.1.4, 6.0 before 6.0.11, and 5.2 before 5.2.20. `django.contrib.gis.db.models.RasterField` allows the creation of files at attacker-controlled locations via the `name` parameter of a data definition. Depending on the raster driver, this could enable remote code execution. Earlier, unsupported Django series (such as 5.1.x, 5.0.x, and 4.2.x) were not evaluated and may also be affected. Django would like to thank Mohammed Fathy for reporting this issue.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Attack Vector Network AV:N
Attack Complexity Low AC:L
Privileges Req. Low PR:L
User Interaction None UI:N
Scope Unchanged S:U
Confidentiality High C:H
Integrity High I:H
Availability High A:H
AI Security Analysis & Remediation

🎯 What is this vulnerability?

CVE‑2026‑124827 is a CWE‑73 (OS Command Injection via Path Manipulation) flaw in the Django framework’s GIS module (django.contrib.gis.db.models.RasterField).
The RasterField accepts a name argument that specifies the file path of the raster data. In Django 6.1 (≤ 6.1.3), 6.0 (≤ 6.0.10), and 5.2 (≤ 5.2.19), the value of name is not sanitized or constrained to the application’s media directory. An attacker can therefore supply an arbitrary absolute or relative path that points outside the intended upload directory.

When the raster driver (e.g., GDAL) processes the file, it may invoke external commands (e.g., gdal_translate, gdalwarp) that interpret the file path. If the supplied path contains shell metacharacters or a specially crafted filename, the driver can execute arbitrary shell commands, leading to remote code execution (RCE).

The vulnerability is unauthenticated (AV:N) but requires low‑privilege (PR:L) access to the Django application (e.g., a normal authenticated user or a public API that accepts raster uploads). No user interaction (UI:N) is needed, and the impact is confidentiality, integrity, and availability (C = H, I = H, A = H).


⚡ Attack Chain

NOTE: The following chain is a realistic, step‑by‑step illustration. The exact URL or form field names may vary depending on the project’s URL routing and admin configuration. The example uses Django’s default admin interface for clarity.

1. Discovery & Reconnaissance

StepTechniqueWhat the attacker learns
1.1Banner grabbing (curl -I http://target/)Detects Server: Django/6.1.3 or similar.
1.2Directory enumeration (dirsearch, gobuster)Finds /admin/ and /media/.
1.3Admin interface probing (curl -X GET http://target/admin/)Confirms the presence of the Django admin and that the user can log in.
1.4Model introspection (curl -X GET http://target/admin/app/model/ after login)Reveals a model that contains a RasterField.
If the application exposes a public API endpoint that accepts raster uploads (e.g., /api/upload_raster/), the same discovery steps apply.

2. Exploitation

2.1 Crafting the malicious payload

The attacker crafts a POST request that creates a new instance of the model containing the vulnerable RasterField.
The name field is set to an absolute path that points to a location where the attacker can write a file that will later be executed by GDAL.

# Example: write a shell script to /tmp/evil.sh
# The GDAL driver will later invoke /tmp/evil.sh as part of its processing.

2.2 Example curl payload (illustrative)

curl -k \
  -X POST http://target/admin/app/model/add/ \
  -F "name=/tmp/evil.sh" \
  -F "raster_file=@/path/to/valid.tif" \
  -F "csrfmiddlewaretoken=YOUR_CSRF_TOKEN" \
  -F "username=admin" \
  -F "password=adminpass" \
  -b cookie.txt -c cookie.txt

Explanation of fields:

FieldPurpose
nameAttacker‑controlled file path (/tmp/evil.sh).
raster_fileA legitimate raster file that triggers GDAL processing.
csrfmiddlewaretokenRequired for POST to admin.
username / passwordCredentials for an authenticated user (low‑privilege).
-b/-c cookie.txtSession cookie handling.
Important: The exact form field names (name, raster_file) depend on the model definition. The attacker can discover them by inspecting the admin form or the API schema.

2.3 Triggering the RCE

Once the record is created, Django’s GIS backend will invoke the raster driver to process the uploaded file.
If the driver is GDAL, it may internally call:

gdal_translate /tmp/evil.sh /tmp/converted.tif

Because /tmp/evil.sh is a shell script, GDAL will execute it, giving the attacker arbitrary command execution on the host.

The exact command depends on the driver and the raster operation. The key point is that the driver interprets the file path and may run it as a command.

3. Post‑exploitation

1. Establish persistence – upload a webshell or create a cron job via the executed script.
2. Privilege escalation – if the GDAL process runs as a privileged user (e.g., www-data), the attacker can leverage local privilege escalation exploits.
3. Data exfiltration – read sensitive files, dump database credentials, or exfiltrate via HTTP/HTTPS.
4. Denial‑of‑service – delete critical files or corrupt the database.


🌍 Real World Impact

ImpactCVSS ComponentEffect
ConfidentialityC:HArbitrary files can be read or created, exposing sensitive data.
IntegrityI:HMalicious code can modify application files, database records, or system configuration.
AvailabilityA:HRCE can crash services, delete data, or lock out legitimate users.

Practical consequences:

  • Web applications that allow raster uploads (e.g., GIS portals, mapping services) become a vector for RCE.
  • Enterprise deployments that rely on Django’s GIS stack (e.g., spatial analytics, geofencing) risk full system compromise.
  • Cloud‑hosted services may suffer from data exfiltration or service disruption if the attacker gains a foothold.

  • 🛡️ Remediation & Mitigation

    A. Patch

    Affected Django seriesVulnerable releasesFixed release
    6.16.1.0 – 6.1.36.1.4
    6.06.0.0 – 6.0.106.0.11
    5.25.2.0 – 5.2.195.2.20

    Action: Upgrade to the latest patch release of the corresponding series.
    If upgrading the entire Django stack is not immediately possible, consider the following work‑arounds.

    B. Work‑arounds

    1. Disable or remove RasterField usage
    - Comment out or delete any models that use RasterField.
    - If the field is optional, set null=True, blank=True and enforce a custom validator that restricts name to the media root.

    2. Validate the name field

    from django.core.exceptions import ValidationError
       import os
    
       def validate_raster_name(value):
           # Ensure the path is relative and stays within MEDIA_ROOT
           if os.path.isabs(value) or '..' in value.split(os.sep):
               raise ValidationError("Invalid raster file path.")

    3. Restrict GDAL execution
    - Run GDAL processes under a dedicated, low‑privilege user.
    - Use sudo with a minimal sudoers entry that only allows the specific GDAL commands needed.

    4. File system permissions
    - Mount the media directory with noexec to prevent execution of uploaded files.
    - Set chmod 640 on uploaded raster files.

    5. WAF / ModSecurity rule (illustrative)

    SecRule REQUEST_URI "@beginsWith /admin/" \
           "phase:2,chain,block,msg:'RasterField Path Traversal',id:100001"
    
       SecRule ARGS:name "@rx ^(\.\./|/)" \
           "t:none,log,deny,status:403"

    This rule blocks any request to the admin that contains ../ or an absolute path in the name parameter.

    C. Detection

    Log sourceIndicatorExample
    Django access logPOST to /admin/.../add/ with name= containing / or ..POST /admin/app/model/add/ 200
    System audit logsExecution of gdal_translate or gdalwarp with a non‑standard source pathaudit.log: execve("/usr/bin/gdal_translate", ["gdal_translate", "/tmp/evil.sh", ...])
    File system monitoringCreation of files in /tmp/ or other unexpected directories by a web processinotify: /tmp/evil.sh created by www-data
    WAF logsRule 100001 triggeredWAF: 100001 - RasterField Path Traversal

    IoCs:

  • File paths such as /tmp/evil.sh, /var/www/html/evil.sh, or any file with a .sh extension created by the web user.
  • Process names gdal_translate, gdalwarp invoked with arguments that are not typical raster files.
  • Log entries containing execve or system() calls from the Django process.

  • ⚠️ Urgency

  • CVSS Score: 8.8 (High)
  • Exploit Complexity: Low (requires only a low‑privilege account or public API).
  • CISA KEV: No (not yet in the KEV list).
  • Potential for RCE: Yes, depending on the raster driver.
  • Recommendation:

  • Immediate patching of all affected Django installations.

  • If patching cannot be performed within 48 hours, apply the work‑arounds above and monitor for the detection patterns listed.

  • Treat this vulnerability as a critical priority for any production environment that uses Django’s GIS stack.




[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="djangoproject Django"
PoC & Exploit Intelligence (GitHub)
joshuavanderpoll/CVE-2026-124827 ★ 10 Python 2026-12-03
CVE-2026-124827 (Django4Shell): Arbitrary file write to RCE via GeoDjango RasterField. PoC exploit, Nmap NSE, Nuclei template, Docker lab.
linoMlv/CVE-2026-124827-PoC-and-Lab ★ 1 Python 2026-12-02
Django4Shell CVE-2026-124827 teaching lab and PoC exploit
CVE-2026-124827
Luscious8/Django4shell PoC 2026-12-03
Django4Shell (CVE-2026-124827) is a critical vulnerability in GeoDjango’s RasterField that allows authenticated attackers to exploit form validation to write ar
Technical reference / advisory repository for CVE-2026-124827
Technical reference / advisory repository for CVE-2026-124827
CVSS Score
8.8 / 10 · CVSS HIGH
Weakness Types (CWE)
CWE-73
Affected Products (1)
djangoproject:Django (6.1.4)
Related CVEs
8.7
CVE-2026-144965
Docutils before 0.23.1 contains a local file disclosure vulnerability in the HTML and ODT writers that embed i
8.6
CVE-2026-135760
External control of a file path in Revenera FlexNet Publisher lmadmin versions 11.19.10 and prior allows a re
6.1
CVE-2026-130017
When a table is dropped with purge, and when old metadata files are deleted after a commit (write.metadata.del
6.0
CVE-2026-144666
AsyncSSH before 2.24.2 contains an arbitrary file write vulnerability in the SCP client that allows malicious
4.8
CVE-2026-115940
Potential local privilege escalation vulnerabilities have been identified in the Fortemedia APO Control Servic
0.0
CVE-2026-142413
Incorrect Permission Assignment for Critical Resource vulnerability in Drupal Database Export UI allows Exploi
8.8
CVE-2026-47798
The eauth token directory was created world-listable (mode 0755). Each token file is named with the bearer tok