Django4Shell, explained: who is exposed, four scenarios, and what to do now

Django4Shell (CVE-2026-124827) lets a staff user plant code on a Django server through a map field. Who is exposed, four scenarios, and what to do now.

Illustration with the story's key figures: Django4Shell, explained: who is exposed, four scenarios, and what to do now

Django4Shell (CVE-2026-124827) is a flaw in GeoDjango, the mapping part of Django, that lets someone with a staff login make the server write a file of their choosing; when that file is one Python loads at start, their code runs the next time the application restarts. Django fixed it on 2 December 2026 in versions 6.1.4, 6.0.11 and 5.2.20, together with six other flaws (Django ↗). It reaches only sites that store map images in a RasterField and let that field be edited through the admin, a form or a writable API, so the exposed group is small; for that group the fix is urgent.

The researcher who reported it, Mohammed Fathy of Robusta Technology Group, named it Django4Shell and rates it critical (django4shell.com ↗); Django rates it high under its own policy. It is the fourth fix this year for the way GeoDjango turns text into raster images, and the third since August in which a fix closed one route and another stayed open.

ExploitOps WeeklyStories like this one, by email every Friday.Subscribe

Updates. 2 December 2026: first edition, on the day of the fix. We will add the GitHub advisory, Linux distribution fixes and any report of exploitation here as they appear.

The 30‑second version

  • →What breaks: a staff user can make GDAL, the mapping library under GeoDjango, write a file anywhere the web process can write. A Python start-up file turns that into code that runs on the server.
  • →Who is exposed: sites that use GeoDjango on PostGIS with a RasterField that is open to the admin, a ModelForm or a writable serializer. Geometry fields, such as points and polygons, are unaffected.
  • →What the attacker needs: a staff account, or write access to an API that uses the field. The file is written during validation, before anything reaches the database, the researcher found.
  • →Fixed in: Django 6.1.4, 6.0.11 and 5.2.20, published on PyPI on 2 December. Django 4.2, 5.1 and 5.0 no longer receive security fixes.
  • →Exploitation: none reported as of 2 December. The researcher’s site shows the shape of the request, and the fix is public, so a working attack is a short step away.
  • →Today: upgrade. If you cannot, take the raster field out of every form and API, and check for planted start-up files (the checklist is below).

How much of the internet runs Django

Django is one of the most used web frameworks in the world. It was downloaded 52.4 million times from PyPI in the last month (pypistats ↗), about 2 million public GitHub repositories depend on it (GitHub ↗), and 35% of Python developers use it, beside FastAPI at 38% and Flask at 34%, in the 2024 Python Developers Survey, the latest published (PSF and JetBrains ↗). Wappalyzer tracks 100,000 websites built with it (Wappalyzer ↗), and 11% of developers who answered Stack Overflow’s 2026 web-framework question use it (Stack Overflow ↗).

Django4Shell sits in a small corner of that. GeoDjango with PostGIS, the only database RasterField runs on, is used by 23% of the roughly 3,500 developers in the Django Software Foundation’s 2026 survey (DSF and JetBrains ↗). RasterField itself is much rarer: in public Python code in GitHub’s search index, 53 database migration files in 34 projects create one, against 8,168 files that create a PointField, about one in 150 (MATT count, 2 December 2026).

The projects we found are the kind the researcher calls most exposed: government services, research institutes, environmental and air-quality monitoring, agriculture, trail and park management, and a United Nations development project. We leave them unnamed; their owners are the people to check, and a public repository says little about how a live deployment is set up.

Five stacked layers narrowing from Django’s reach to the exposed group: 52.4 million Django downloads from PyPI in the last month; about 2 million public GitHub repositories that depend on Django; 23% of Django developers use GeoDjango with PostGIS; in public code, about one RasterField migration for every 150 PointField migrations (53 files in 34 projects against 8,168); and an unknown share with the field open to a form or API and an attacker holding a staff login.

One older group needs attention too. About 8 million Django downloads in November were for versions that no longer get security fixes, 4.2, 5.1, 5.0 and 3.2, roughly one in six across the seven version lines counted (pepy ↗), and 4% of developers in the DSF survey say they run an unsupported version. Django 4.2’s support ended on 7 April 2026 (Django ↗). The advisory lists only supported versions and says nothing about older ones.

What broke, in plain words

GeoDjango stores map images, such as elevation models, satellite scenes and rainfall grids, in a model field called RasterField. When a value is assigned to that field, Django hands it to GDAL, which can build a raster from a description written as JSON: a size, a few numbers, a file name and a driver. Most drivers keep the raster in memory; some write it to disk. Django’s advisory puts it plainly: a user-controlled name and a non-default driver “could cause GDAL to write a file to an attacker-controlled location” (Django ↗).

Three defaults line up. RasterField has no form of its own, so the admin and ModelForms show it as an ordinary text box. GDAL’s EHdr driver, which writes plain binary files, is “built-in by default” (GDAL ↗). And Python, every time it starts, tries to import a module named sitecustomize, “which can perform arbitrary site-specific customizations” (Python ↗). The researcher’s write-up shows the result: a raster whose pixel values spell out Python, written to sitecustomize.py while the form is still being validated (django4shell.com ↗).

Five steps from a form field to code on the server: a staff user sends a form whose raster field holds a raster written as JSON with the EHdr driver and a file name; RasterField falls back to an ordinary text field; validation reads the value and builds a GDAL raster; GDAL writes the file before anything is saved; Python runs it at the next start, as the web application’s user.

The fix changes two defaults (commit ↗). RasterField is now left out of forms unless a developer includes it, and assigning a dict or JSON string that names a driver other than the in-memory one raises an error; code that needs another driver wraps the value in GDALRaster to say it is trusted. Django adds a caution: request forgery “is still possible if untrusted input is assigned” to the field, so validation stays the developer’s job (Django ↗, raster security considerations ↗).

The same door, four fixes this year

In February Django fixed SQL injection through raster lookups on PostGIS, CVE-2026-1207 (Django ↗); CrowdSec saw attacks against it from 26 February, mostly “focused reconnaissance to identify vulnerable Django and PostGIS configurations” (CrowdSec ↗). In August it stopped spatial lookups passing text and dicts to GDAL, CVE-2026-15307, which could write files or make network requests, and was reachable by staff users with view permissions in the admin (Django ↗). In October it closed a route through byte values that was “overlooked in the fix for CVE-2026-15307” (Django ↗).

The August note matters most. It said “assignments to model fields are unaffected and still accept these input types”, on the principle that untrusted input should be validated before use (Django ↗). Django4Shell is that assignment path, reached through the default admin form, where the input arrives unvalidated. The researcher reported it on 22 October; Django confirmed it on 9 November (CVE record ↗).

A timeline of GeoDjango raster fixes in 2026: 3 February, CVE-2026-1207, SQL injection through raster lookups, high, with attacks seen from 26 February; 4 August, CVE-2026-15307, file write and request forgery through spatial lookups, high, with Django’s note that assignments to model fields are unaffected; 6 October, CVE-2026-87890, request forgery through byte values, moderate, overlooked in the August fix; 22 October, Django4Shell reported; 2 December, CVE-2026-124827, file write through RasterField assignment, high, fixed in 6.1.4, 6.0.11 and 5.2.20.

Who is exposed, and who is safe

Four conditions have to meet, and three of them are defaults in a standard GeoDjango deployment, by the researcher’s account to The Hacker News (The Hacker News ↗). The fourth, and the real gate, is an attacker who can submit the form: “the primary requirement is staff-level authentication,” Fathy said.

Four conditions that must all hold: a GeoDjango RasterField model, which runs only on PostGIS; the field exposed through the default admin, a ModelForm or a writable serializer; GDAL with the EHdr driver, which ships in standard builds; and a path the web process can write that Python reads at start. Then someone with a staff account or write access to the API sends the form. The researcher’s prevalence estimates are moderate, very high, near-universal and very high.
Your setupExposed to Django4Shell?Why
GeoDjango with a RasterField model registered in the adminYes, to anyone with staff access to that modelThe admin builds a text box for the field by default
RasterField in a ModelForm or a writable serializerYes, to whoever can submit itDjango names both routes in its advisory
RasterField filled only by your own scripts or management commandsLowerThere is no form route; upgrade all the same
GeoDjango with geometry fields only (points, lines, polygons)NoDjango: “Geometry fields were not affected”
Django without GeoDjangoNoThe other six fixes in the release still apply
Django 4.2, 5.1, 5.0 or older, or a distribution package that lagsUnknown, and no fix is comingMove to a supported version from PyPI

Linux distributions are a trap here. Debian marked its stable Django packages as ignored for the August fix, giving “Invasive fix; too difficult to backport; affects only GeoSpatial component” (Debian ↗), and Debian has no entry for Django4Shell yet. A GeoDjango application built on a distribution’s own Django package may wait a long time for this fix.

What an attacker gets, and what stops them

  • →Code on the server, as the web application’s user. Everything that user can read, the attacker can read: environment variables, settings files, mounted secrets.
  • →The keys to the rest. Database passwords, cloud storage keys and API tokens usually sit in that environment. Django’s SECRET_KEY signs password-reset links and other values, so a stolen key lets the attacker forge them.
  • →The data. Whatever the application can query, the attacker can take: user accounts, customer records, the maps and the data behind them.
  • →A foothold that outlives the account. “This allows overwriting application source code, dropping web shells into static directories, or corrupting configuration files,” Fathy told The Hacker News (The Hacker News ↗); his write-up adds a planted .pth file in site-packages, which Python reads at every start (django4shell.com ↗).

What stops it: a second factor on every staff account, which closes the most likely way in; a web process that cannot write to its own code or site-packages; containers rebuilt from a clean image on each deploy, which wipe anything written inside them; outbound traffic limited to what the application needs; and GDAL drivers the application never uses switched off with GDAL_SKIP, as GDAL’s own security guide advises (GDAL ↗).

Four scenarios

1. The flood map editor. A regional water authority publishes flood-risk maps. Twelve editors upload elevation and rainfall rasters through Django’s admin. One editor reuses a password that appeared in an old breach. An attacker signs in, opens the raster page and pastes a raster written as JSON that names the project’s sitecustomize.py; the form may even show an error, but the file is already written. Nothing happens until the 02:00 deploy restarts the workers. Then the planted code runs in every one of them, reads the database password, the cloud storage keys and SECRET_KEY, and sends them out. What stops it: a second factor on admin logins, code directories the web process cannot write, and outbound traffic blocked at start. What shows it: a change in the admin history on the raster model, a new sitecustomize.py, and a connection out of the server at 02:00.

2. The customer who became the platform. A farm-analytics company gives each customer’s manager a Django staff account that sees only that customer’s fields and satellite images. The permissions keep customers apart in the database, but the file is written on the shared server. One manager, or whoever phished them, plants code that runs for every customer the next time the service restarts, and the separation between customers ends there. What stops it: customers kept out of the Django admin, or the raster field removed from their forms, and one application per customer where the data justifies it.

3. The partner’s API token. A city’s open-data portal lets partner agencies push land-cover rasters through a REST endpoint built on a writable serializer, one of the routes Django names. One partner’s token sits in a public build log. The attacker sends the same JSON raster to the API, and validation writes the file. What stops it: tokens scoped to what each partner needs and rotated when exposed, and raster uploads that accept files through a validated import path, with the field itself kept out of the serializer.

4. The contractor’s last day. A GIS contractor held staff access for a mapping project. On their last day they plant a .pth file in site-packages. Their account is removed the following week; the file stays and runs at every start. On a server whose virtual environment is never rebuilt, it can run for months. What stops it: deploys from a clean image, a regular check of site-packages against what the lock file installs, and staff access removed on the day a contract ends.

Why a fix this narrow still matters

The researcher’s site shows the shape of the request, and Django’s fix is public. In November Google found attackers running an AI system that compares web software before and after each security fix and writes the attack itself (exploit_agent); the hours between a release and an upgrade are the window such tools work in. The raster code has been a target all year: the February flaw in the same area drew steady scanning for Django and PostGIS set-ups within three weeks (CrowdSec ↗). And the sites with RasterField hold data governments and companies care about: water, land, crops, air and infrastructure.

It also shows how fixes go wrong. Each 2026 fix guarded one route into the same dangerous call, turning text into a GDAL raster, and the next report found another route. The same pattern ran through PHP2Shell, where early patched code gave the flaw away, and Broccoli2Shell, where the fix sat unreleased for months. One of the seven reports in this release is credited to OpenAI, part of a year in which AI-assisted research has found serious flaws in mature software faster than before (NGINX, Java and Apache).

The other six fixes

The seven fixes in Django 6.1.4, 6.0.11 and 5.2.20 with Django’s severity: high, CVE-2026-124827, Django4Shell, server-side file write via RasterField, reported by Mohammed Fathy; high, CVE-2026-132092, SQL injection in range and in lookups, Cristian Panaro; moderate, CVE-2026-115868, cross-site scripting in truncatechars_html, JoeCyberTech; low, CVE-2026-125673, cache poisoning via dot segments in paths, 4drez; low, CVE-2026-119642, admin data leak via the pk alias, JoeCyberTech; low, CVE-2026-127929, admin data leak via reverse relations, OpenAI; low, CVE-2026-132809, heap overflow in OGRGeometry.wkb, Zhixi Jace Sun.
  • →SQL injection in range and in lookups (high, CVE-2026-132092). Reachable through aliases or key transforms containing percent signs; the range lookup now takes exactly two values.
  • →Cross-site scripting in `truncatechars_html` (moderate). When the text length matches the truncation length and the output lands in an HTML attribute.
  • →Cache poisoning through dot segments in paths (low). Django says existing cached responses are not invalidated: clear caches that may be affected after upgrading.
  • →Two admin data leaks (low). Staff users with view permission could enumerate data through the pk alias on a custom one-to-one primary key, or through reverse relations; the second was reported by OpenAI.
  • →A heap overflow in `OGRGeometry.wkb` (low). For geometries larger than 4GB on 64-bit platforms.

Who should do what

WhoTodayThis week
Developers who own a Django appUpgrade to 6.1.4, 6.0.11 or 5.2.20; search the code for RasterFieldAdd a test that a raster written as JSON with a file driver is refused on every form and API
Platform and DevOps teamsRebuild images and redeploy; where an upgrade waits, ship with the raster field removed from formsMake code and site-packages read-only to the web process; limit outbound traffic
Security teamsLook for sitecustomize.py, usercustomize.py and new .pth files; read the admin history of raster models since AugustRequire a second factor on every staff account; list every Django app and its version
CTOs and CISOsAsk which applications use GeoDjango and who holds staff loginsAsk suppliers who build on Django for their upgrade date in writing
Agencies and freelancers who built GeoDjango sitesPatch the sites you host and tell clients what you didFind client apps on a distribution’s Django package and move them to PyPI
Buyers of software built on DjangoAsk the vendor whether it uses RasterField and when it upgradedAdd the answer to the vendor’s file

What to do now

In the next hour.

  • →Check the version: python -m django --version. Fixed releases are 6.1.4, 6.0.11 and 5.2.20 and later.
  • →Find the field: grep -rn "RasterField" --include="*.py" . in your code, leaving out the virtual environment, then check the admin, forms and serializers that use those models.
  • →Upgrade within your version line, for example pip install "Django~=5.2.20", and redeploy.
  • →If you cannot upgrade today, take the field out of every form: exclude it in the admin and ModelForms, or set editable=False on the model, which becomes the default in the fixed releases.

Today.

  • →Look for planted start-up files: python -c "import importlib.util as u; print(u.find_spec('sitecustomize'), u.find_spec('usercustomize'))" prints None for each module that does not exist. Anything else names a file: read it, and compare it with what your operating system or image ships (Ubuntu, for one, ships its own sitecustomize.py).
  • →List .pth files in site-packages changed since August: find the folder with python -c "import site; print(site.getsitepackages())", then find <folder> -name "*.pth" -newermt 2026-08-04.
  • →Read the admin history: the django_admin_log table records who added or changed each record. Check the models with a raster field.
  • →If anything looks wrong, rotate SECRET_KEY, database passwords and cloud keys, and rebuild the server from a clean image.
  • →Clear caches after upgrading, as Django advises for the cache-poisoning fix.

This week.

  • →Run the web process as a user that cannot write to the code, the virtual environment or site-packages.
  • →Turn off GDAL drivers you never use with GDAL_SKIP, as GDAL’s security guide advises.
  • →Require a second factor on every staff account, and remove access on the day a contract ends.
  • →List every Django application, its version and its support date; move anything on 4.2 or older.

What to follow

  • →Django’s security releases ↗ and security archive ↗, and the django-announce mailing list, for further fixes.
  • →The CVE record ↗ and NVD entry ↗: Django’s own score is CVSS 3.1 8.8 and CVSS 4.0 8.7; a 9.0 figure in some press coverage has no primary source.
  • →The GitHub Advisory Database, which had no entry for CVE-2026-124827 on 2 December; Dependabot alerts follow it.
  • →CISA’s Known Exploited Vulnerabilities catalog ↗, which listed no Django flaw on 2 December.
  • →Your Linux distribution’s security tracker, if you install Django from its packages.
  • →The researcher’s write-up ↗, and this page’s update log.

Rules worth checking

Written as plain-English rules, each of which holds or breaks on any given day:

  • →No text from a user becomes a GDAL raster that can write a file, on any route: admin, forms, APIs or lookups.
  • →The web process cannot write to the directories Python reads at start.
  • →Every staff account signs in with a second factor, and access ends with the contract.

MATT’s ExploitOps Review tests rules like these against a company’s own software with its team. Our Record logs AI-era incidents as they are disclosed.

Sources

Questions

What is Django4Shell?

Django4Shell, CVE-2026-124827, is a flaw in GeoDjango’s RasterField that lets a user who can submit a form or API request containing the field make GDAL write a file on the server. Written to a Python start-up file such as sitecustomize.py, it runs code at the next restart. Django fixed it on 2 December 2026.

Is my Django site affected by Django4Shell?

Only if it uses GeoDjango on PostGIS with a RasterField that is open to the admin, a ModelForm or a writable serializer, and an attacker can submit that form, usually with a staff login. Sites with geometry fields only, or without GeoDjango, are unaffected by this flaw, though the other six fixes in the release still apply.

Which Django versions fix Django4Shell?

Django 6.1.4, 6.0.11 and 5.2.20, released on 2 December 2026. Django 4.2, 5.1 and 5.0 no longer receive security fixes, so applications on them should move to a supported version.

Is Django4Shell being exploited?

No exploitation had been reported as of 2 December 2026, and CISA’s Known Exploited Vulnerabilities catalog listed no Django flaw. An earlier raster flaw from February, CVE-2026-1207, was attacked from 26 February according to CrowdSec.

What is the CVSS score of CVE‑2026‑124827?

Django, which issued the CVE, gives it 8.8 under CVSS 3.1 and 8.7 under CVSS 4.0, and rates it high under its own policy. The researcher rates it critical. A 9.0 score in some press coverage has no primary source.

What should I do if I cannot upgrade Django today?

Take the RasterField out of every form and serializer, require a second factor for staff, check for planted sitecustomize.py, usercustomize.py and .pth files, and make the code and site-packages read-only to the web process until you can upgrade.

ExploitOps WeeklyBy email

The week in security,in one email.

Every Friday: the five to seven stories that mattered for people who build software. What happened, why it matters and the source, then rules to check before Monday. Stop any time.

Know where you stand.

Book a discovery call→

Let’s understand your priority

What brings you to MATT?

What would you like help with?
01 / 02