Skip to content

The third time Django patched the same hole

A file-write flaw in GeoDjango's RasterField let an authenticated user write files to the server, and the fix changes how the field works.

Three fabric patches stitched onto dark indigo denim, two in natural canvas and the third in deep vermillion red, the red patch in sharp focus at the right
Three patches stitched over the same spot. The vermillion one is the latest.
On this pageJump to section

On December 2, Django shipped security releases 6.1.4, 6.0.11, and 5.2.20, fixing seven vulnerabilities. The headline flaw, CVE-2026-124827, lets an authenticated user turn a form submission into a file written to the server, and from there, depending on the raster driver, into code execution. Its finder calls it Django4Shell. It is also the third time in four months that Django has patched the same GeoDjango code.

The flaw sits in RasterField, the GeoDjango field that stores raster data such as satellite imagery and elevation maps in PostGIS. Assigning a raster definition with a user-controlled name and a non-default driver could make GDAL, the library that reads geographic data, write a file to an attacker-chosen location. Django rates the flaw "high" under its own policy. SecurityWeek reports a CVSS score of 8.8.

What makes it dangerous is how ordinary the route in is. RasterField falls back to an ordinary CharField form field, so the flaw was reachable by default wherever a model with a RasterField is registered in the Django admin or exposed through ModelForms or writable model serializers. No exotic setup, no unusual configuration: a form that accepts a raster value was enough. Orca Security, which published an analysis of the flaw, says staff-level authentication is required, and that an attacker could drop Python files into the working directory, write into site-packages, overwrite source code, deploy web shells, or corrupt configuration files.

Three patches for one sink

The December fix is the end of a story that started in August. On August 4, Django shipped 6.0.8 and 5.2.17 to fix CVE-2026-15307: spatial lookups could pass dictionary and string values into GDALRaster, the constructor that turns a value into a raster, and a crafted value could make GDAL write a file or fetch a remote URL. The August advisory blocked those values in lookups and added a sentence that reads very differently now: "assignments to model fields are unaffected and still accept these input types."

The reasoning was stated plainly. Applications are supposed to validate their own input before assigning it to a model field, so the lookup path got a gate and the assignment path did not. On October 6, Django patched CVE-2026-87890, which SecurityWeek describes as an incomplete fix for the August flaw: byte values in lookups could smuggle in a VRT document that fetches an external URL. December's flaw uses the assignment path the August advisory named as unaffected.

The attack is a form submission. A raster data definition, sent as a dictionary or a JSON string, names a file and a driver. GDAL takes the definition at face value and writes the file before anything reaches the database. The August fix guarded the query. The October fix guarded a value type the first fix had overlooked. The December fix guards the assignment.

Timeline of three Django security releases patching the same GeoDjango raster code: August 4, 2026 closed the query path; October 6 closed a byte-value bypass; December 2 closed the field-assignment path.
Three releases, one sink: August guarded the query, October caught a bypass, and December closed the assignment. Source.

What the fix changes

The December patch changes RasterField in two ways. The field now defaults to editable=False, so ModelForms leave it out unless a developer includes it explicitly. And assigning a dictionary or JSON string that names a non-default driver now raises a GDALException. Trusted values have to be wrapped in GDALRaster, which marks them as the developer's choice rather than user input.

That second change also breaks code that relied on the old behavior. Applications that passed raster definitions as plain dictionaries will need to wrap them. It is the kind of break a security release usually avoids, and its presence says something about how Django now views the field: the convenience of accepting raw definitions was the vulnerability.

The fix does not close everything. Django's advisory warns that server-side request forgery is still possible if untrusted input is assigned to RasterField, and points developers to its raster security guidance. The patch stops the file write. The input still needs validation. Anyone who treats the upgrade as the end of the work has read the advisory halfway.

The rest of the release

The same releases carry a second flaw rated high, and it reaches far more sites than the raster bug. CVE-2026-132092 is a potential SQL injection in the range and in lookups, triggered when queries use aliases or key transforms containing percent signs. The range lookup now requires exactly two right-hand-side values. Django notes that percent signs in aliases and key transforms were deprecated in 6.0 and are scheduled for removal in Django 2028.

The other five fixes are smaller: a moderate cross-site scripting flaw in the truncatechars_html template filter, a low-severity cache-poisoning bug involving dot segments in request paths, two low-severity information leaks in the admin changelist, and a heap buffer overflow in OGRGeometry.wkb for geometries larger than 4 GB. Django advises clearing potentially affected caches after upgrading, since the cache fix does not invalidate existing cached responses.

Who should do what

Upgrade to 6.1.4, 6.0.11, or 5.2.20, according to your branch. If your app uses GeoDjango with a RasterField on PostGIS, treat it as urgent: the flaw is reachable through the admin and ordinary forms, and proof-of-concept details are public, according to SecurityWeek. If your app does not use GeoDjango at all, upgrade anyway for the SQL injection and the template-filter fix.

Then check what your app hands to RasterField. The December patch assumes developers validate untrusted input before assignment, which is the same premise the August advisory stated and the December flaw disproved. Django has not said whether the flaw was exploited in the wild, and it does not appear in CISA's known-exploited catalog as of November 30, according to Cycode's tracking. With a public proof of concept, the window between patch and exploit is short.

Upgrade, then search your codebase for RasterField assignments that take user input. The patch closes the file write. The validation is still yours.

Related reporting

More from grep.tips

All articles