Django4Shell (CVE-2026-124827) is a server-side file-write bug in GeoDjango’s RasterField that can turn into remote code execution on a Django server. The Django team fixed it on December 2, 2026 in Django 6.1.4, 6.0.11 and 5.2.20, together with six other security issues.
If your project never touches django.contrib.gis, this one isn’t your problem, though the same release also fixes a high-severity SQL injection, so you should still upgrade. If you do run GeoDjango with a raster model in the admin or behind a form, treat this as a this-week patch, not a next-sprint one.
| CVE ID | CVE-2026-124827 (nicknamed Django4Shell) |
| Affected Django versions | 6.1 before 6.1.4, 6.0 before 6.0.11, 5.2 before 5.2.20 (older unsupported series were not evaluated) |
| Vulnerable component | django.contrib.gis.db.models.RasterField (GeoDjango, PostGIS) |
| Fixed versions | Django 6.1.4, 6.0.11, 5.2.20 LTS |
| Severity | Django rating: high. CNA score CVSS 4.0 8.7 (High) |
| Exploited in the wild | No confirmed exploitation reported as of Dec 2, 2026 |
| CISA KEV | Not listed as of Dec 2, 2026 |
| Workaround | None official. Upgrade, and keep untrusted input away from RasterField |
| Published | December 2, 2026 |
TL;DR
- Upgrade Django to 6.1.4, 6.0.11 or 5.2.20 LTS (or newer) on every environment.
- Rebuild container images and restart all workers so the new version is actually running.
- Clear your cache after upgrading (one of the other fixes doesn’t invalidate poisoned entries).
- If you use GeoDjango rasters, look for new
sitecustomize.pyand.pthfiles on app hosts.
What happened with Django4Shell
Django4Shell is the third round of fixes for the same GeoDjango raster area in about four months. Each earlier patch closed one path into GDAL, and the researcher found another one that the previous fix didn’t cover.
| Date | Event |
|---|---|
| Aug 4, 2026 | Django patches CVE-2026-15307, a GeoDjango raster issue in spatial lookups |
| Oct 6, 2026 | Django 6.1.2, 6.0.9 and 5.2.18 fix CVE-2026-87890 (request forgery via raster bytes in spatial lookups), noting it was missed in the CVE-2026-15307 fix |
| Dec 2, 2026 | Django 6.1.4, 6.0.11 and 5.2.20 fix CVE-2026-124827 plus six other CVEs |
| Dec 2, 2026 | Researcher Mohammed Fathy (Robusta Technology Group) publishes the Django4Shell write-up; NVD lists the CVE the same day |
Fathy’s write-up frames Django4Shell as a bypass of the October hardening: the new guard ran on QuerySet lookups, but not on the path where a raster value is assigned to a model field and validated by a form. That’s a pattern worth remembering. Patching one entry point to a dangerous library call rarely closes them all.
How the Django4Shell vulnerability works
GeoDjango’s RasterField accepts a raster “data definition”, which can be a Python dict or a JSON string describing a raster: width, height, bands, a driver and a name. Django hands that definition to GDAL to build the raster.
According to the Django advisory, if an attacker controls the name and picks a non-default driver, GDAL writes a file to wherever that name points. The researcher’s chain uses GDAL’s EHdr driver, which is compiled into standard GDAL builds, and stores attacker-chosen bytes as band data. Point the name at a sitecustomize.py somewhere on Python’s path, and the next time the interpreter starts (a Gunicorn reload, a uWSGI restart, a cron job running manage.py), that code runs as the application user.
Two details make this worse than it sounds at first:
- It’s on by default for many apps.
RasterFieldfalls back to a plainCharFieldform field, so any raster model registered in the admin, used in aModelForm, or exposed through a writable serializer accepted that JSON without extra code. - The write happens during validation. Per the researcher, the file lands on disk inside
form.is_valid(), beforesave()is called, so a failed or rejected form submission can still leave the file behind.
The realistic attacker is someone with a staff account that can add or change the raster model. That’s a real bar, but staff accounts get phished, shared and forgotten all the time. If you’ve built a public form or API that accepts raster definitions from anyone, the bar drops to nothing. Some coverage cites a CVSS score of 9.0; the score Django published as the CNA is CVSS 4.0 8.7 with low privileges required, which matches the staff-account requirement.
Other CVEs in the December Django security release
| CVE | Issue | Django rating |
|---|---|---|
| CVE-2026-132092 | SQL injection in range and in lookups with aliases or key transforms containing % | High |
| CVE-2026-115868 | XSS in truncatechars_html / Truncator.chars(html=True) | Moderate |
| CVE-2026-125673 | Cache poisoning via dot segments in request paths | Low |
| CVE-2026-119642 | Admin changelist data leak via the pk alias on OneToOneField primary keys | Low |
| CVE-2026-127929 | Admin changelist data leak via reverse relations | Low |
| CVE-2026-132809 | Heap buffer overflow in OGRGeometry.wkb for geometries over 4GB | Low |
The SQL injection is the one non-GIS shops should care about. It needs specific query patterns to trigger, but “high” from the Django team is reason enough to roll this release everywhere.
Am I affected by CVE-2026-124827?
Work through the list below. If you tick the first three boxes, assume you’re exposed until you’ve upgraded.
Tick everything that applies to you
Any box ticked? Patch now. Ticks reset when you reload the page.
Check the installed Django version (run inside the same virtualenv or container as the app)
python -m django --version
pip show django | grep -i '^version'
Find GeoDjango and RasterField usage in your code
grep -rn "django.contrib.gis" --include=*.py .
grep -rn "RasterField" --include=*.py .
Check whether your GDAL build includes the EHdr driver
gdalinfo --formats | grep -i ehdr
Running a supported branch below the fixed release means you’re affected if you use raster fields. If you’re still on 4.2 or 5.1, NVD notes that unsupported series weren’t evaluated, so don’t assume they’re safe. Plan the move to 5.2 LTS.
| Branch | First fixed release |
|---|---|
| Django 6.1 | 6.1.4 |
| Django 6.0 | 6.0.11 |
| Django 5.2 LTS | 5.2.20 |
| main (development) | Patched on Dec 2, 2026 |
Disclaimer: These steps are general guidance based on the vendor’s published advisory and are provided as-is. Every environment is different: test in a staging environment, take a full backup or snapshot first, and follow the vendor’s official documentation. SysOpsTechnix accepts no responsibility for outages, data loss or other damage resulting from applying these steps. See our Terms of Use.
How to upgrade Django and fix Django4Shell

Django is a Python dependency, so the fix is a version bump and a redeploy. The steps below assume pip with a requirements file, with notes for Poetry and containers. It’s the same process for any Django security release; the only Django4Shell-specific parts are the behavior changes in step 4 and the file check at the end.
1. Take a backup and record what’s running
Snapshot the VM or tag the current container image, and save your current lock file. If the upgrade breaks something, rolling back should take minutes, not an evening.
pip freeze > requirements-before-django-upgrade.txt
2. Bump Django to the fixed release
Stay on your current branch; you don’t need a feature upgrade to get this fix. Pin the patched version in requirements.txt (for example Django==6.1.4 or Django>=5.2.20,<5.3), then install:
pip
pip install --upgrade "Django==6.1.4" # or 6.0.11 / 5.2.20
python -m django --version
Poetry
poetry add "django@^6.1.4"
poetry lock && poetry install
If you use Django from your Linux distribution’s python3-django package instead of pip, check your distro’s security tracker for a backport before assuming you’re covered. Distro packages often lag upstream by days.
3. Rebuild images and restart every process
A new requirements.txt does nothing until the running interpreter loads the new Django. In Docker, make sure the pip layer actually rebuilds; a cached layer is the classic way to “deploy” a patch that isn’t there. Then restart Gunicorn or uWSGI, Celery workers, and anything that imports your project.
docker build --pull --no-cache -t myapp:django-6.1.4 .
docker compose up -d --force-recreate
docker compose exec web python -m django --version
4. Check for breaking changes in raster handling
The fix changes behavior, so run your test suite before you push to production. Per the Django advisory:
RasterFieldnow defaults toeditable=False, so it disappears from auto-generated admin forms andModelForms unless you list it explicitly.- Assigning a dict or JSON string that specifies a non-default driver now raises
GDALException. If your own trusted code needs another driver, wrap the definition inGDALRasterfirst. - If you’re jumping from a release older than October’s, raster bytes used in spatial lookups must also be wrapped in
GDALRaster(the CVE-2026-87890 change).
python manage.py check --deploy
python manage.py test
5. Verify, then clear your cache
Confirm the version inside the running app, not just on your laptop. Then clear your cache: the CVE-2026-125673 fix doesn’t invalidate responses that were already poisoned. If you store sessions in the cache, clearing it logs users out, so pick a quiet window.
python manage.py shell -c "from django.core.cache import cache; cache.clear()"
If you want a broader post-patch pass on the server itself, our pre-launch security checklist for Linux web servers covers file permissions and service hardening that also limit what a bug like this can reach.
Temporary mitigations if you can’t patch yet
Django doesn’t list a workaround; upgrading is the fix. If you need a day or two to get a release out, these reduce the risk in the meantime:
- Stop accepting raster input from users you don’t fully trust. Pull the raster model out of the admin or exclude the field from forms and serializers until you’ve upgraded.
- Review staff accounts with add or change permission on raster models, and remove the ones nobody can explain.
- Run the app with a read-only code directory and a
site-packagesthe app user can’t write to. A read-only root filesystem in containers blocks the startup-file trick even if a write is attempted. - Keep in mind the patch blocks file writes, not every raster risk. Django says server-side request forgery is still possible if untrusted input reaches
RasterField, so validate that input before it gets there.
Signs of compromise
Upgrading closes the hole. It doesn’t remove anything that was already written. If you were exposed, spend twenty minutes on these checks on each app host or container:
List the directories on Python’s import path
python -c "import sys; print('\n'.join(p for p in sys.path if p))"
Look for sitecustomize.py / usercustomize.py in the project and site-packages
SP=$(python -c "import site; print(' '.join(site.getsitepackages()))")
find /path/to/project $SP \( -name 'sitecustomize.py' -o -name 'usercustomize.py' \) -ls
List .pth files changed in the last 30 days
find $SP -name '*.pth' -mtime -30 -ls
Review recent admin activity
python manage.py shell -c "from django.contrib.admin.models import LogEntry; [print(e.action_time, e.user, e.content_type, e.object_repr) for e in LogEntry.objects.order_by('-action_time')[:50]]"
Also look for unexpected files in static and media directories, new processes owned by the app user, and outbound connections from web workers that you can’t account for. Fathy’s write-up describes web shells in static paths and .pth persistence as likely follow-ups, so those are the first places to look.
Found an unexpected sitecustomize.py, a new .pth file or a file you can’t explain? Treat it as an incident: isolate the host, keep a copy of the file for analysis, rotate SECRET_KEY, database passwords and any API keys the app could read, and rebuild from a known-good image rather than cleaning in place.
Django4Shell FAQ
What is Django4Shell?
It’s the researcher’s name for CVE-2026-124827, a file-write flaw in GeoDjango’s RasterField. A crafted raster definition can make GDAL write a file to an attacker-chosen path, which can lead to code execution when Python next starts.
Which Django version fixes CVE-2026-124827?
Django 6.1.4, 6.0.11 and 5.2.20 LTS, released December 2, 2026. Any later release on those branches also includes the fix.
Am I affected if I don’t use GeoDjango?
Not by Django4Shell itself. It only affects projects with django.contrib.gis and a RasterField. You should still upgrade because of the high-severity SQL injection fixed in the same release.
Can Django4Shell be exploited without logging in?
In a default setup, the attacker needs a staff account with add or change permission on a raster model. If your app exposes a public form or API that accepts raster definitions, that requirement goes away.
Is Django4Shell being exploited in the wild?
As of December 2, 2026 there are no confirmed reports of exploitation, and the CVE isn’t in CISA’s Known Exploited Vulnerabilities catalog. The researcher has published a detailed write-up, so expect that to change faster than usual.
Will upgrading break my GeoDjango code?
Possibly. RasterField is no longer editable by default, and non-default drivers in dict or JSON definitions now raise an error. Run your tests and check any forms that relied on the raster field showing up automatically.
Sources
- Django: Security releases issued: 6.1.4, 6.0.11 and 5.2.20 (Dec 2, 2026)
- NVD: CVE-2026-124827
- Django: Security releases issued: 6.1.2, 6.0.9 and 5.2.18 (Oct 6, 2026)
- Django docs: GDAL raster security considerations
- Django4Shell research write-up (Robusta Technology Group)
- CISA Known Exploited Vulnerabilities catalog
- The Hacker News coverage
- Cyber Security News coverage
Patching other software this week too? See our breakdown of the OpenSSL 4.1.1 vulnerabilities and the critical RabbitMQ OAuth2 flaw.
