Django 6.1.2 hardened QuerySet lookups for GDALRaster values (CVE-2026-87890), blocking dangerous raster paths in filter() clauses. That guard never executes on the RasterField assignment path—allowing a staff user to write sitecustomize.py via GDAL’s EHdr driver during form.is_valid() , before model.save() is ever called.
Research and responsible disclosure:
Robusta Technology Group — Mohammed Fathy · Report Date: 2026-12-02
What is Django4Shell?
Django4Shell is a critical Remote Code Execution (P1) vulnerability in Django 6.1.2’s GeoDjango RasterField that bypasses the CVE-2026-87890 lookup hardening. With no PostGIS connection and no database table required, an authenticated staff user can submit a crafted JSON raster to any ModelForm or Django Admin view, triggering GDALCreate() to write arbitrary Python code to disk inside form.is_valid() .
Common Django software
Root Cause · Bypass of CVE-2026-87890
The Guard That Doesn’t Apply
Django 6.1.2 introduced check_raster_lookup_value() to block dangerous raster paths in QuerySet lookups. However, the ModelForm assignment and validation path is completely independent—and never invokes the guard.
Execution Trace: Assignment / Validation
Deep Technical Analysis · 5 Phases
From HTTP POST to Remote Code Execution
Step through the complete 13-step exploit chain—showing how an unvalidated JSON raster string travels from a Django Admin form into GDAL’s C GDALCreate() and executes on the Python startup.
1 Attacker with Staff/Admin privileges sends an HTTP POST to Django admin add/change view or any ModelForm-backed view with a RasterField.
Attacker with Staff/Admin privileges sends an HTTP POST to Django admin add/change view or any ModelForm-backed view with a RasterField.
2 Payload specifies "driver": "EHdr" (GDAL headerless binary raster), "name" pointing to sitecustomize.py, and bands[0].data containing ASCII byte values of Python source.
Payload specifies "driver": "EHdr" (GDAL headerless binary raster), "name" pointing to sitecustomize.py, and bands[0].data containing ASCII byte values of Python source.
Key Takeaway: No file upload widget needed — a plain text/JSON string in the form field is accepted.
Impact & Blast Radius
Full OS-User Code Execution
Higher severity than lookup-only SSRF (CVE-2026-87890) because this path writes arbitrary attacker bytes to disk and executes code, not only fetching a URL.
1. Arbitrary File Write
Writes as the Django process OS user to any writable path on the host filesystem—entirely inside form.is_valid() .
2. Remote Code Execution via Startup Hooks
Dropping sitecustomize.py into CWD or any sys.path directory executes on the Python process start ( runserver , gunicorn , uwsgi , manage.py cron ).
3. Additional Persistence Primitives
Overwrite application source code, plant a .pth file in site-packages , or pivot across the host with full web-worker privileges.
Attack Preconditions (All 4 Required)
When Is an App Vulnerable?
No PostGIS connection and no database table are required—the file write occurs before any database interaction.
GeoDjango RasterField
django.contrib.gis installed and a model defined with a RasterField.
Form or Admin Exposure
Field exposed via ModelForm or default Django Admin (true for any project using auto-generated forms).
GDAL with EHdr Driver
Standard GDAL build — the ESRI .hdr Labelled (EHdr) headerless binary driver is compiled in by default.
Worker CWD, project directory, or site-packages writable by the Django process OS user.
Recommended Remediation
How to fix Django4Shell
The fix must extend to both the form layer and the proxy read path—not only QuerySet lookups.
Robusta Technology Group — a 200+ expert group serving 250+ clients across MENA and Europe — offers a dedicated Django4Shell security assessment covering detection of vulnerable RasterField surfaces, full exploitation chain verification, remediation guidance for Django admin and ModelForm layers, regression test suites, and a written advisory report suitable for board-level disclosure.
Secure your Django application
Robusta Technology Group is a 200+ expert technology group serving 250+ clients across MENA and Europe. Their Cybersecurity practice covers secure SDLC, penetration testing, virtual CISO, and compliance readiness — the same team behind Django4Shell.
Django4Shell Assessment — Full exploitation chain verification for your stack
Source Code Audit — GeoDjango, DRF, admin — traced to the entry point
Incident Response — Breach triage with written report within 48 hours
Responsible Disclosure — CVE authoring, advisories, and patch coordination
Reach out directly — we respond to all serious security inquiries within one business day.
security@robustastudio.com
All engagements are covered by a signed NDA before any work begins.
