CVE-2026-124827 — Djangoproject Django (6.1.4) — CWE-73
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.
🎯 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
| Step | Technique | What the attacker learns |
|---|---|---|
| 1.1 | Banner grabbing (curl -I http://target/) | Detects Server: Django/6.1.3 or similar. |
| 1.2 | Directory enumeration (dirsearch, gobuster) | Finds /admin/ and /media/. |
| 1.3 | Admin interface probing (curl -X GET http://target/admin/) | Confirms the presence of the Django admin and that the user can log in. |
| 1.4 | Model 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.txtExplanation of fields:
| Field | Purpose |
|---|---|
name | Attacker‑controlled file path (/tmp/evil.sh). |
raster_file | A legitimate raster file that triggers GDAL processing. |
csrfmiddlewaretoken | Required for POST to admin. |
username / password | Credentials for an authenticated user (low‑privilege). |
-b/-c cookie.txt | Session 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.tifBecause /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
| Impact | CVSS Component | Effect |
|---|---|---|
| Confidentiality | C:H | Arbitrary files can be read or created, exposing sensitive data. |
| Integrity | I:H | Malicious code can modify application files, database records, or system configuration. |
| Availability | A:H | RCE 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 series | Vulnerable releases | Fixed release |
|---|---|---|
| 6.1 | 6.1.0 – 6.1.3 | 6.1.4 |
| 6.0 | 6.0.0 – 6.0.10 | 6.0.11 |
| 5.2 | 5.2.0 – 5.2.19 | 5.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 source | Indicator | Example |
|---|---|---|
| Django access log | POST to /admin/.../add/ with name= containing / or .. | POST /admin/app/model/add/ 200 |
| System audit logs | Execution of gdal_translate or gdalwarp with a non‑standard source path | audit.log: execve("/usr/bin/gdal_translate", ["gdal_translate", "/tmp/evil.sh", ...]) |
| File system monitoring | Creation of files in /tmp/ or other unexpected directories by a web process | inotify: /tmp/evil.sh created by www-data |
| WAF logs | Rule 100001 triggered | WAF: 100001 - RasterField Path Traversal |
IoCs:
/tmp/evil.sh, /var/www/html/evil.sh, or any file with a .sh extension created by the web user. gdal_translate, gdalwarp invoked with arguments that are not typical raster files. execve or system() calls from the Django process.⚠️ Urgency
Recommendation:
[🤖 CVE Professor AI Security Engine]
FOFA Query