On 2 December 2026, the Django project released security versions 6.1.4, 6.0.11 and 5.2.20. Among other fixes, they address CVE-2026-124827, named “Django4Shell” by the researcher who found it. The flaw affects GeoDjango’s RasterField: a raster definition submitted through a form can make the GDAL library write a file to a location chosen by the attacker. Depending on the GDAL driver, this can lead to remote code execution. Our Audit & Offensive Security team reproduced the full chain in an isolated environment.
RasterFieldfalls back to aCharFieldform field, so it was editable by default in the Django admin, inModelForms and in writable model serializers.- A raster definition (dict or JSON) with a user-controlled
nameand a non-default GDAL driver can write a file to an arbitrary location on the server. - Depending on the driver, this write leads to code execution, for example by dropping a
.pthorsitecustomize.pyfile that runs the next time Python starts. - Only GeoDjango applications on PostGIS that expose a
RasterFieldare affected. Geometry fields are not. - Fix:
RasterFieldis no longer editable by default, and Django rejects definitions that request a non-default driver. Upgrade to 6.1.4, 6.0.11 or 5.2.20.
RasterField (PostGIS)MITRE ATT&CK mapping
This is an indicative Defensy mapping based on the behaviours described. The entry point is an exposed application (T1190): a form, the admin or an API that accepts a RasterField. Persistence and execution rely on a Python startup hook (T1546.018), a .pth or sitecustomize.py file, whose content is Python code (T1059.006). According to the researcher quoted by Snyk, the same write can also drop a web shell (T1505.003) into a static files directory.
Background: GeoDjango, RasterField and GDAL
GeoDjango is Django’s module for geographic data. It provides geometry fields (points, polygons…) and a RasterField for raster data such as georeferenced images or digital elevation models. This field is only implemented for PostGIS and relies on the GDAL library to read and write rasters.
GDAL works with drivers. The default driver, MEM, works in memory. Other drivers, such as EHdr mentioned by Snyk, write the raster to a file on disk, at the path given by the definition’s name parameter.
This is the third fix on the same attack surface. According to Snyk, CVE-2026-15307 (August 2026) already addressed file writes and outbound requests through raster values in spatial lookups, and CVE-2026-87890 (October 2026) a request forgery case. An application patched in August therefore needs another update.
Root cause analysis
- A field editable by default
Because
RasterFieldfalls back to theCharFieldform field, it appears automatically in the admin, inModelForms and in writable model serializers. According to the Django advisory, the flaw was therefore reachable “by default”. - No restriction on the driver or the path
Before the fix, Django passed the definition’s
nameparameter to GDAL without restricting the driver. With a driver that writes to disk, GDAL creates the file at the given path, including with../sequences. - A file write that becomes code execution
A file placed in a
sys.pathdirectory, such as a.pthinsite-packagesor asitecustomize.py, runs when the interpreter starts. A worker restart, a server reload, amanage.pycommand or a scheduled job is then enough to run the code.
The attack chain
This is the chain as we reproduced it. The attacker needs network access to an entry point that accepts an editable RasterField.
Checking the write primitive
T1190
The exploit submits a raster definition that requests a GDAL driver writing to disk. If the request is accepted, file writes are possible. On a patched version, Django raises a GDALException.
Dropping the .pth file
T1546.018 T1059.006
The exploit writes a .pth file into the site-packages directory. Python runs this type of file every time the interpreter starts.
Triggering a restart
The code only runs the next time Python starts. In our reproduction, the exploit makes the Django server reload. In production, a worker restart, a deployment or a scheduled job has the same effect.
Execution and output retrieval
At startup, Python processes the .pth and runs the attacker’s command. In our test environment, the id command returned uid=0(root), because the application ran as root inside its container. No direct access to the server is needed.
Demonstration: the proof of concept on video
The video below shows the full chain against a deliberately vulnerable test application, in an isolated environment.
Who is exposed
- Applications using the Django admin: a staff user who can add or change a model containing a
RasterFieldcan trigger the flaw. Superuser rights are not needed. - REST APIs: a writable model serializer includes the field. If the endpoint accepts weakly authenticated or anonymous users, the exposure grows accordingly.
- Public forms: any
ModelFormthat includes aRasterFieldand is reachable by external users. - Containers running as root: the code runs with the rights of the Python process. In a container started as root, the attacker directly gets root inside the container.
Out of scope: applications that do not use GeoDjango, those that do not use RasterField, and geometry fields (PointField, PolygonField…).
What the fix changes
| Branch | Affected versions | Fixed version |
|---|---|---|
| Django 6.1 | before 6.1.4 | 6.1.4 |
| Django 6.0 | before 6.0.11 | 6.0.11 |
| Django 5.2 (LTS) | before 5.2.20 | 5.2.20 |
| 4.2, 5.0, 5.1 | not evaluated by Django | move to a supported branch |
RasterField now has editable=False by default: it no longer appears in a ModelForm unless explicitly included. Django also raises a GDALException when a dict or JSON string requesting a non-default driver is assigned. To use another driver, wrap the definition in GDALRaster to mark the value as trusted. Django notes that this protection only prevents file writes: server-side request forgery (SSRF) is still possible if untrusted input is assigned to RasterField.
The same release fixes six other vulnerabilities, including CVE-2026-132092, a high-severity SQL injection in range and in lookups. The update is worth applying even without GeoDjango.
Recommendations
- ImmediateUpgrade Django
Move to 6.1.4, 6.0.11 or 5.2.20, then rebuild and redeploy your images. Check the version with
python -m django --version. Applications on 5.1 or older must move to a supported branch. - ImmediateIf the upgrade must wait, remove the field from forms
Add
editable=Falseto everyRasterFieldor explicitly exclude it from forms, the admin and serializers. Restrict admin access to the affected models. - Short termLook for signs of exploitation
In the logs of raster endpoints, look for requests containing
../,/vsiorEHdr. On servers, look for unexpected.pthorsitecustomize.pyfiles and for application files changed without a matching deployment. - Short termInventory RasterField usage
Search the code for
RasterField(grep -rn "RasterField" --include=*.py .) and list every form, admin view and serializer that exposes it, with its permissions. - Medium termValidate raster input and limit SSRF
SSRF remains possible after the fix. Validate raster definitions in the application, use
GDALRasteronly for trusted values and filter outbound traffic from application servers. - Medium termApply least privilege
Do not run Django as root in containers, make
site-packagesand the application code read-only for the web process, and limit writes to the directories that strictly need them.
Indicators to watch
- Unexpected
.pthorsitecustomize.pyfiles insite-packagesor asys.pathdirectory, especially if they contain imports or system calls. Critical - Requests to a raster endpoint containing a driver other than
MEM,EHdr,../or/vsi. Critical - GDAL sidecar files (
.hdr,.prj) appearing in application or system directories. Suspicious - Application or static files changed without a matching deployment. Suspicious
Django4Shell is not a GDAL bug but a missing control between Django and GDAL: an ordinary form field was wired to a library able to write to disk. The fix is simple, but an application patched in August against CVE-2026-15307 remains exposed until it is updated again.
Our Audit & Offensive Security team reproduced this chain and now includes it in penetration tests of Django applications. Our SOC, Detection & Response offer helps you monitor the indicators above on your exposed servers.
- Django security releases issued: 6.1.4, 6.0.11, and 5.2.20Django Project — 2 December 2026
- Django4shell (CVE-2026-124827): Why GeoDjango apps patched in August still need an updateSnyk — 2 December 2026
- Django4Shell (CVE-2026-124827): Affected Versions, How to Check and FixCycode — 2 December 2026
- Django4ShellResearcher’s website
- Event Triggered Execution: Python Startup Hooks (T1546.018)MITRE ATT&CK®
- New Django4Shell Vulnerability Enables Django RCE via GeoDjango Form ValidationThe Hacker News — December 2026
