Skip to content
Django4Shell

Django4Shell

Django4Shell • December 2, 2026

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

Robusta Technology Group

All engagements are covered by a signed NDA before any work begins.

The full story

This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.

Django4Shell: CVE-2026-124827 RasterField flaw enables file write and possible RCE Django released versions 6.1.4, 6.0.11 and 5.2.20 on 2 December 2026 to fix CVE-2026-124827, dubbed Django4Shell, a high-severity (CVSS 8.8 per the verified record; The Hacker News reports CVSS 9.0) server-side file-write flaw in GeoDjango's RasterField assignment path. Django's advisory says that assigning a raster definition with an user-controlled name and a non-default GDAL driver could write a file to an attacker-controlled location, which depending on the driver could enable remote code execution. The flaw is described as an incomplete fix for CVE-2026-87890, which itself was an incomplete fix for CVE-2026-15307. Robusta Technology Group's Mohammed Fathy is credited with the research and says an authenticated staff user could submit a crafted JSON raster through a ModelForm or Django admin view to write sitecustomize.py or.pth files, though these exploitation details come from the researcher's write-up and have not been independently verified. Django states RasterField falls back to the CharField form field, so it was reachable by default in admin and ModelForms, and only PostGIS-backed RasterField is affected, not geometry fields. The fix sets RasterField editable to False by default and raises GDALException for dict or JSON definitions specifying non-default drivers. Django notes server-side request forgery remains possible if untrusted input reaches RasterField. Cybersecuritynews reports no confirmed and no independent demonstration of unauthenticated attack as of 2 December. The same releases also fix other issues, including a separate high-severity SQL injection flaw in range and lookups. 7 sources 74

Extracted Entities