Django fixes Django4Shell file write and an SQL injection in seven-flaw release


On this page
Django has released versions 6.1.4, 6.0.11 and 5.2.20 to fix seven security flaws. The security team’s announcement on 2 December rates two of them high. One lets a staff user write files anywhere the web app can, which researcher Mohammed Fathy has named Django4Shell. The other is an SQL injection in two common query lookups. Upgrade now if you run any supported Django version.
Django4Shell: a file write through GeoDjango
CVE-2026-124827 sits in RasterField, the GeoDjango field for raster
data, which Django only implements on PostGIS. You can assign it a raster
definition as a dict or JSON string. Before the fix, that definition
could name a file and a GDAL driver, and GDAL would create the file
wherever the name pointed.
RasterField has no form field of its own, so Django falls back to a
plain text box. That made the flaw reachable by default on any model with
a RasterField in the admin, a ModelForm or a writable serializer.
Fathy’s write-up shows how far that goes.
Using GDAL’s EHdr driver, which standard GDAL builds include, a staff user
can write a sitecustomize.py file into a folder Python loads at startup.
The write happens while Django validates the form, before anything is
saved. The next time a worker or management command starts, Python runs
the file as the web app’s user. He lists four conditions: a model with a
RasterField, the field exposed in a form or the admin, the EHdr driver,
and a path the app can write to.
Fathy describes it as a way around the guard Django added in October for CVE-2026-87890. That fix, itself a follow-up to CVE-2026-15307 in August, blocked dangerous raster values in query lookups. It never ran when a value was assigned through a form. Fathy’s page includes a sample payload, so assume the technique is public.
The CVE record scores Django4Shell at CVSS 3.1 8.8, because the attacker needs a staff login. Staff accounts are a common phishing target, so don’t treat that as much comfort.
The SQL injection
CVE-2026-132092 affects the range and in lookups. Its CVE record
scores it at CVSS 3.1 9.8, though Django rates it high, like
Django4Shell.
The conditions are narrow. It needs a query using aliases or key
transforms that contain percent signs. The range route also needs more
than two values on the right-hand side, and the in route needs a
bilateral transform. Django deprecated percent signs in aliases and key
transforms in 6.0.
The other five fixes
The truncatechars_html filter could produce cross-site scripting when
truncated text ended up in an HTML attribute (CVE-2026-115868). Django’s
cache middleware mishandled . and .. in request paths, so an attacker
could get a cached page served at the wrong URL (CVE-2026-125673). Two
admin bugs let staff with view rights work out data through crafted
search strings (CVE-2026-119642 and CVE-2026-127929). A GeoDjango heap
overflow affected geometries over 4GB (CVE-2026-132809).
Django hasn’t reported any of the seven being used in attacks.
What changes when you upgrade
The fixes change some behaviour you may rely on.
RasterFieldnow defaults toeditable=False, so it drops out ofModelForms and the admin unless you add it back.- Assigning a dict or JSON string that names a non-default driver now
raises
GDALException. Wrap trusted definitions inGDALRasterto use other drivers. - The
rangelookup now needs exactly two values. - Existing cache entries aren’t cleared. Clear any caches that might hold poisoned responses after upgrading.
Django notes that the raster fix only stops file writes. If you assign
untrusted input to a RasterField, server-side request forgery is still
possible, so validate it first.
What to do
- Upgrade to Django 6.1.4, 6.0.11 or 5.2.20, and test any code that creates rasters.
- If you can’t upgrade yet and use GeoDjango, set
editable=Falseon eachRasterFieldand take it out of the admin and yourModelForms. - Lock down staff accounts with multi-factor authentication, and check your admin logs for unexpected edits to raster fields.
- Look for dropped files. Check for unexpected
sitecustomize.pyor.pthfiles in your project folder and site-packages.