Django4Shell, how to protect yourself (CVE-2026-124827)
Django4Shell is the name for CVE-2026-124827, a file write in GeoDjango's RasterField that can lead to remote code execution. Django fixed it on December 2 in 6.1.4, 6.0.11 and 5.2.20. Read who is affected and what to do.

Key takeaways
- Django4Shell is the name for CVE-2026-124827, a server-side file write in GeoDjango's
RasterFieldthat can lead to remote code execution (RCE). - The fix was released on December 2, 2026 in Django 6.1.4, 6.0.11 and 5.2.20. Upgrade as soon as you can.
- You are only affected if your project uses
django.contrib.gisand has a model with aRasterField. Geometry fields such as points and polygons are not affected. - In a default setup the attacker needs a staff account that is allowed to add or change the affected model. Superuser rights are not needed. A public form or API that accepts raster definitions could take that barrier away.
- As of December 2 there are no public reports of exploitation in the wild.
Background and potential impact
On December 2, 2026 the Django team published security releases that fix seven vulnerabilities. The one getting the attention is CVE-2026-124827. It was reported by Mohammed Fathy of Robusta Technology Group, who named it Django4Shell.
The bug is in GeoDjango, the part of Django that handles geographic data. A RasterField stores grid-based data such as satellite images or elevation maps, and Django only supports it on PostGIS. When a raster definition with a user-controlled name and a non-default driver is assigned to such a field, GDAL (the geospatial library underneath) can write a file to a location the attacker chooses. Depending on the raster drivers that are available, that file write can become code execution.
What makes this reachable by default is that RasterField has no form field of its own and falls back to a plain CharField. A raster definition can therefore be submitted as ordinary text through the Django admin, a ModelForm or a writable model serializer. According to the researcher the file is written during form validation, before anything is saved to the database.
It is the third issue in the same code in four months. CVE-2026-15307 (August) and CVE-2026-87890 (October) closed the route through spatial lookups. Django4Shell uses the assignment path, which those fixes did not cover.
Django rates the issue as high under its own security policy. The researcher considers it critical. If you use raster fields, that difference does not change what you should do.
Are you affected?
Affected versions are Django 6.1 before 6.1.4, 6.0 before 6.0.11 and 5.2 before 5.2.20. According to the researcher, exploitation requires all of the following:
django.contrib.gisis inINSTALLED_APPSand at least one model has aRasterField.- That field is exposed through the admin, a
ModelFormor a writable serializer. Unless you excluded it explicitly, this is the default. - GDAL is built with the
EHdrdriver. Standard builds include it. - The Django process can write to a useful location, for example the project directory.
- The attacker has a staff account with add or change permission on the model. That can be an insider, a compromised account or stolen credentials.
If the first condition applies to you, assume the next three do as well.
Older series such as 5.1, 5.0 and 4.2 no longer receive security fixes and were not evaluated. They may be vulnerable too, and no patch will be released for them.
What an attacker can do
The attacker controls the path, the filename and the contents of the file that is written. The researcher describes writing a file that Python loads automatically at startup, such as sitecustomize.py or a .pth file. The code in it then runs with the rights of the web server user the next time a worker restarts, reloads or forks.
From there an attacker can read secrets and environment variables, change or steal data, and move further into the host or the network.
The patch
Upgrade to Django 6.1.4, 6.0.11 or 5.2.20. If you run an unsupported series, move to a supported one. The fix changes two things:
RasterFieldnow defaults toeditable=False. It no longer appears in aModelFormor the admin unless you include it explicitly.- Assigning a
dictor JSON string that specifies a non-default driver now raisesGDALException. Code that really needs another driver has to wrap the definition inGDALRaster, which marks the value as trusted.
This is a backward-incompatible change. Test any code that edits rasters through forms or uses other drivers.
Also note what the patch does not do. Django warns that it only limits file writes. Server-side request forgery (SSRF) is still possible when untrusted input is assigned to a RasterField, so keep validating that input before it reaches the field.
After upgrading, rebuild your container images, redeploy and check which version is actually running. An updated requirements file does not help while old images are still serving requests.
If you cannot patch right away
- Remove
RasterFieldfrom admin classes,ModelFormclasses and writable serializers withexclude, or seteditable=Falseon the field. - Do not accept raster definitions from untrusted users until the update is live.
- Limit who has staff access, enforce MFA on admin accounts and make the admin reachable from trusted networks only.
- Run the application as a low-privilege user. Where possible, make the project directory and
site-packagesread-only for the web process. - Disable GDAL raster drivers you do not use, for example with the
GDAL_SKIPconfiguration option.
These measures reduce the risk. They do not replace the update.
Detection and indicators of compromise
No formal indicators of compromise have been published. What you can check:
- Unexpected
.pyor.pthfiles in the project directory and insite-packages, especially recent ones. Pay attention tositecustomize.pyandusercustomize.py. - Admin logs showing staff edits to models that contain a raster field.
- New processes started by the web server user and unusual outbound connections.
If you find a file you cannot explain, treat the host as compromised. Preserve logs and rotate the secrets and environment variables the application could read. Restart workers only after cleanup, because a restart is the moment a planted file gets executed.
Patching fixes the vulnerability but does not remove an attacker's access.
Quick check
Run these from your project directory, in the environment or container where Django runs.
Which Django version is running?
python -m django --version
Does the project use RasterField?
grep -rn "RasterField" --include="*.py" .
Recently changed startup files, Bash (Linux)
find . -type f \( -name "sitecustomize.py" -o -name "usercustomize.py" -o -name "*.pth" \) -mtime -60
Recently changed startup files, Powershell (Windows)
Get-ChildItem -Recurse -File -Include sitecustomize.py,usercustomize.py,*.pth | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-60) }Repeat the search in site-packages if it is outside your project directory. This command shows where it is:
python -c "import site; print(site.getsitepackages())"
A .pth file that belongs to an installed package is normal. Look for files you cannot trace back to a package or to your own code. Finding nothing does not rule out an attack, because timestamps can be changed.
Other fixes in the same release
- CVE-2026-132092 (high): potential SQL injection in the
rangeandinlookups. - CVE-2026-115868 (moderate): potential XSS in the
truncatechars_htmltemplate filter. - CVE-2026-125673 (low): cache poisoning via dot segments in request paths. Existing cached responses are not invalidated, so clear your caches after upgrading.
- CVE-2026-119642 and CVE-2026-127929 (low): information leakage in the admin changelist.
- CVE-2026-132809 (low): heap buffer overflow in
OGRGeometry.wkbfor geometries larger than 4 GB.
So the upgrade is worth doing even if you do not use GeoDjango.
Source
Want to know what a staff account in your own application can reach? That is the kind of question a web application pentest answers. Book a demo.
More from the blog
View all blogs- R&D
SPAR Framework: how an agentic pentest works
SPAR stands for Scope, Probe, Attack and Report. Read how our AI agents at AssistSec carry out a pentest and why a pentester checks every finding first.
Dec 1, 2026 - News
AI Pentesting: Why organisations choose assistsec
Discover why more companies are choosing AI pentesting with AssistSec. We combine autonomous AI agents with the expertise of senior penetration testers to deliver comprehensive AI-powered penetration tests.
Nov 21, 2026 - Inside AssistSec
ISO 27001: what is it and what does it cost?
ISO 27001 is the standard for information security. Learn what it contains, how certification works, what it costs and how it relates to NIS2.
Nov 2, 2026
Interested in a pentest?
Discover how AssistSec's AI agents give your organisation faster and more thorough insight into vulnerabilities.
Contact us



