Django's December 2, 2026 security release fixes CVE-2026-124827, nicknamed Django4Shell: assigning an attacker-controlled raster definition to a GeoDjango RasterField could make GDAL write a file to a location the attacker chooses, which, depending on the driver, could lead to remote code execution. The fix ships in Django 6.1.4, 6.0.11 and 5.2.20. If you have a RasterField model (PostGIS only), upgrade first and then review who can submit data to that field.
Who this is for and what you will have at the end
This guide is for developers and ops engineers who run Django applications, especially anyone using django.contrib.gis with PostGIS. By the end you will know whether your project can reach the vulnerable code, which version to install, how to confirm the fix, and which settings and habits reduce the blast radius if another raster-handling bug appears. It gives no exploit details; it covers detection and defense only.
What happened
The sequence below comes from Django's own security release posts and release notes, plus The Hacker News report of the researcher's write-up.
| Date | Event | Source |
|---|---|---|
| August 4, 2026 | Django 6.0.8 and 5.2.17 fix CVE-2026-15307, a GeoDjango spatial-lookup flaw Django describes as server-side file write and request forgery, rated high | Django weblog |
| October 6, 2026 | Django 6.1.2, 6.0.9 and 5.2.18 fix CVE-2026-87890, request forgery through raster bytes in spatial lookups (moderate). Raster bytes must now be wrapped in GDALRaster before spatial lookups | Django weblog |
| December 2, 2026 | Django 6.1.4, 6.0.11 and 5.2.20 fix CVE-2026-124827 in RasterField assignment (high) | Django weblog, release notes |
Django's release notes describe the December flaw this way: assigning a raster data definition to RasterField with a user-controlled name parameter and a non-default driver could cause GDAL to write a file to an attacker-controlled location. Because RasterField falls back to the CharField form field, the flaw "was reachable by default on models with RasterField registered in the admin or using ModelForms or writable model serializers." Geometry fields were not affected, and RasterField is only implemented on PostGIS.
The Hacker News reported that the "Django4shell" name was given by a security researcher, who describes the bug as an incomplete fix in the chain of earlier raster issues: the earlier protections did not cover the RasterField assignment path. That framing is the researcher's. Django's advisory does not call the issue an incomplete fix, so treat that as the reporter's analysis.
What Django says and what the researcher says
| Claim | Who made it | Status |
|---|---|---|
| Severity "high" under the Django security policy | Django | Official |
| Fixed in 6.1.4, 6.0.11, 5.2.20 | Django | Official |
| CVSS 9.0 (critical) | Researcher, via The Hacker News | Reported; Django's page shows only "high" |
| Exploitation needs staff-level authentication | Researcher, via The Hacker News | Reported; Django's note says the field was reachable through the admin, ModelForms and writable serializers |
Attackers could overwrite app code, drop web shells or write sitecustomize.py | Researcher, via The Hacker News | Reported impact scenarios, not stated by Django |
| Active exploitation in the wild | Nobody | Neither source we read reports any; not confirmed |
The staff-login point matters for prioritizing, but do not rely on it. A public form, an API endpoint built on a writable serializer, or a compromised staff account changes the picture. Django's own wording is that the field was reachable wherever RasterField was exposed through those three paths.
Am I affected?
Work through these checks in order. You are exposed only if all of the first three are true.
- Your project uses
django.contrib.gisand a model withRasterField. - You run PostGIS as the database backend (Django says
RasterFieldis only implemented there). - Your Django version is below the fixed release for your branch (see the table in the next section).
- Then ask the exposure question: can untrusted or semi-trusted users send data that ends up assigned to that field?
Check your Django version
python -m django --version
pip show djangoFind RasterField in your code
grep -rn "RasterField" --include="*.py" .
grep -rn "django.contrib.gis" --include="*.py" .If the first command prints nothing, your own models do not define a raster field. Also check third-party apps in your virtual environment, since they can define models too:
grep -rn "RasterField" "$(python -c 'import site; print(site.getsitepackages()[0])')" --include="*.py" -lFind the exposure paths
Look for each of these for any model that has a raster field:
| Exposure path | What to look for |
|---|---|
| Admin | The model registered with admin.site.register or a ModelAdmin |
| ModelForm | A ModelForm with fields = "__all__" or the raster field listed |
| API | A writable Django REST framework serializer or any code that assigns request JSON to the field |
| Imports | Management commands or upload handlers that assign dicts or JSON strings to the field |
Before the fix, a RasterField model registered in the admin was enough to make the field reachable, because the form field fell back to a text input. After the fix, RasterField defaults editable to False, which excludes it from a ModelForm unless you explicitly include it.
What to do now
Do these in order of urgency.
- Upgrade Django to the fixed release for your branch. Use 6.1.4, 6.0.11 or 5.2.20. Django's advisory lists nothing else as a remedy.
- Restart every worker. A new package on disk does nothing until Gunicorn, uWSGI, Celery and any scheduled job processes reload.
- Check whether you are on a supported series. If you run an older release such as 4.2, Django does not issue patches for it and says older versions may also be vulnerable. Plan an upgrade to a supported series.
- Clear caches if you use Django's cache middleware. The same release fixes CVE-2026-125673, and Django notes that existing caches are not invalidated.
- Review who has staff access to a site that uses RasterField, and remove accounts you do not recognize.
- Look for signs of tampering (see below), because a bug like this is a file write.
Step 1: Upgrade
Pin the fixed version for your branch in your requirements file, then install:
# Django 6.1 series
pip install "Django==6.1.4"
# Django 6.0 series
pip install "Django==6.0.11"
# Django 5.2 series (LTS)
pip install "Django==5.2.20"Rebuild your container image or virtual environment the way you normally deploy, so production gets the same version you tested. Run your test suite, then deploy.
Step 2: Confirm the fix
python -m django --versionThe output should be the fixed version for your branch. Then check the documented behavior in a Django shell on a staging copy:
from django.contrib.gis.db import models
f = models.RasterField()
print(f.editable)Per the Django 5.2 documentation, the expected value is False, because "Changed in Django 5.2.20: Defaulting editable to False was added."
Step 3: Check for tampering
Django's advisory covers the fix, not forensics, so use general file-integrity checks. The researcher's write-up, as reported, names Python startup files and application source as targets. Check that nothing unexpected sits in your application directories:
# Python files changed in the last 14 days under your app directory
find /srv/app -name "*.py" -mtime -14 -ls
# Startup hooks that Python imports automatically
find /srv/app /usr/lib/python3*/site-packages -name "sitecustomize.py" -o -name "*.pth" 2>/dev/nullAdjust the paths to your deployment. A .pth file or sitecustomize.py that you did not create deserves investigation. If your app runs from a Git checkout or an immutable image, compare the deployed files to the repository or image digest instead.
If you find something unexpected, treat the host as compromised: isolate it, preserve logs, rotate the secrets that process could read (database passwords, SECRET_KEY, cloud keys), and redeploy from a clean image. For database-level recovery planning see PostgreSQL backups with pgBackRest.
If you cannot upgrade today
Django lists no workaround besides upgrading. Django's documentation says: "Do not assign untrusted input to RasterField without custom validation." Until you can patch, remove the raster field from admin forms and from any serializer that accepts client data, for example by using exclude or readonly_fields. This is a stopgap based on Django's own guidance, not a fix; the upgrade is still required.
What the fix changes in your code
The release notes describe two behavior changes:
RasterFieldnow defaultseditabletoFalse, so it is left out of aModelFormunless you include it deliberately.RasterFieldraisesGDALExceptionwhen you assign adictor JSON string that names a non-default driver. To use another driver with trusted input, wrap the definition inGDALRasterto signal that you trust it.
If your project edits rasters through the admin on purpose, expect them to disappear from the form after the upgrade. Add the field back explicitly, and only after you have written validation:
# Only do this with custom validation in place
class ElevationForm(forms.ModelForm):
class Meta:
model = Elevation
fields = ["name", "rast"]Be clear about what is not fixed. Django states that the new exception "only limits server-side file writes. Server-side request forgery is still possible if untrusted input is assigned to RasterField." So even on a patched version, validate raster input before you accept it.
Other fixes in the same release
The December 2 release fixes more than one bug. Django's table lists:
| CVE | Component | Django severity |
|---|---|---|
| CVE-2026-124827 | RasterField assignment | High |
| CVE-2026-132092 | range and in lookups, SQL injection with percent signs in aliases or key transforms | High |
| CVE-2026-115868 | truncatechars_html | Moderate |
| CVE-2026-125673 | build_absolute_uri() and cache middleware | Low |
| CVE-2026-119642 | Admin changelist, pk alias on OneToOneField | Low |
| CVE-2026-127929 | Admin changelist, reverse relations | Low |
| CVE-2026-132809 | OGRGeometry.wkb with geometries over 4 GB | Low |
The SQL injection fix is a reason to upgrade even if you have no GeoDjango. Per the release notes, the range lookup now requires exactly two right-hand side values, and percent signs in column aliases and key transforms were deprecated in Django 6.0. Test any code that passes a list of a different length to __range.
How to prevent it
- Treat raster and geometry input as untrusted. Django's GDAL documentation says instantiating
GDALRasterfrom untrusted input "allows an attacker to write a file or make a network request." Validate input before it reaches a model field. - Wrap trusted values explicitly. Spatial lookups block
bytes,str,pathlib.Pathanddictvalues; wrap withGDALRasteronly when you trust the source. - Run the web process with least privilege. If the application user cannot write to the project directory or site-packages, a file-write bug has fewer places to land. Mount code read-only in containers where you can.
- Limit staff accounts and require MFA for the admin. Even where an issue needs a staff login, a stolen staff password is a common starting point.
- Subscribe to Django's announcements. Django's security policy says it notifies the django-announce list about a week before disclosure of date, time and severity, and posts each release on its weblog. Put that on a calendar for your upgrade window.
- Stay on a supported series. Django patches only the newest series and LTS releases. A major database or runtime upgrade is easier when planned; see PostgreSQL major version upgrade with pg_upgrade for a related example.
- Review GDAL driver availability. Django's documentation points to defense-in-depth steps for limiting the raster drivers available. We could not read that part of the page in this run, so open the GDAL security section of the Django docs and follow it.
Checklist
- Run
python -m django --versionon every environment (dev, staging, production, CI images). - Search for
RasterFieldin your code and in installed apps. - Upgrade to 6.1.4, 6.0.11 or 5.2.20.
- Restart all workers and scheduled jobs.
- Clear caches that might hold responses cached before the fix.
- Look for unexpected
sitecustomize.py,.pthand changed.pyfiles. - Validate raster input; do not rely on the new default alone.
- Plan the move off any unsupported Django series.
What we checked
- Opened Django's December 2, 2026 security release post (djangoproject.com) on 2026-12-05: fixed versions 6.1.4, 6.0.11 and 5.2.20, the table of seven CVEs, and "High" for CVE-2026-124827 and CVE-2026-132092.
- Opened the Django 5.2.20 release notes on 2026-12-05 and compared the CVE-2026-124827 wording with the release post; both state a file write via
RasterFieldassignment and theeditableandGDALExceptionchanges. - Opened the Django 5.2
RasterFieldmodel API page:editabledefaults toFalse("Changed in Django 5.2.20") andRasterFieldis only implemented on PostGIS. - Opened the Django GDAL page (security considerations) and the October 6, 2026 release post to confirm CVE-2026-87890 and the
GDALRasterwrapping rule. The last part of the GDAL page was cut off when fetched, so the defense-in-depth section on limiting raster drivers was not read. - Opened the Django security policy page: supported series, advance notice on django-announce, and the severity table (RCE and SQL injection are "High").
- Read The Hacker News report for the researcher's claims (CVSS 9.0, staff-level authentication, file-write scenarios) and labelled them as reported. The django4shell.com page returned only a title, so we could not verify anything from it.
- Not tested: we did not run Django, PostGIS or GDAL, so the shell and
findcommands are standard checks, not documented vendor output. The version check andeditablevalue come from the documentation. No CVE record in NVD was opened in this run.
Last tested: 2026-12-05
References
- Django security releases: 6.1.4, 6.0.11, 5.2.20 (December 2, 2026)
- Django 5.2.20 release notes
- Django GeoDjango model API: RasterField
- Django GDAL API: security considerations
- Django security policy
- Django security releases, October 6, 2026
- Django security releases, August 4, 2026
- The Hacker News: Django4Shell vulnerability enables Django RCE
Comments
Questions and tips are welcome. Comments are checked by the EpiFive team before they appear; please do not share passwords, phone numbers or other private details.