Critical Java and nginx flaws Java4Shell + nginx2rootScan my domain
DjangoGeoDjangoGDALRCEFile writeVulnerability

CVE-2026-124827 (Django4Shell): arbitrary file write through RasterField in GeoDjango

Django4Shell (CVE-2026-124827): a RasterField fed with untrusted input lets GDAL write a file wherever the attacker chooses, up to code execution. Versions, score, fix, how to check.

by 19 min read
CVE-2026-124827 (Django4Shell): arbitrary file write through RasterField in GeoDjango

Context

On 2 December 2026 the Django team released 6.1.4, 6.0.11 and 5.2.20. They fix seven flaws, including CVE-2026-124827: assigning a raster definition to a GeoDjango RasterField, with a file name chosen by the user, can make GDAL write a file wherever the attacker wants. Depending on the raster driver used, the write is enough to get code execution.

The researcher who reported it, Mohammed Fathy (The Hacker News calls him Mohamed K. Fathy), named it Django4Shell. Django did not choose that name: its advisory only says "Server-side file-write via RasterField assignment".

This article draws on the CVE record published by Django, its 2 December advisory, the four commits of the fix, and the articles from The Hacker News and Upwind. We read the fix and the documentation that comes with it, then built a lab (Django 6.1.3, 6.1.4 and 5.2.19 with GeoDjango, behind gunicorn, admin enabled, DEBUG off) to replay the first step: the file write.

What the lab showed, and what it did not, is detailed in the "What the lab verified" section. We did not go as far as code execution, and we did not test PostGIS.

Update of 3 December: public exploits have been circulating since the day before (see the box and the "Exploitation and public exploits" section). The first version of this article said there were none, which is no longer true.

The flaw is part of a series. In August, CVE-2026-15307 fixed file writes through spatial filters (versions 5.2.17 and 6.0.8). In October, CVE-2026-87890 fixed an overlooked case that allowed outbound requests (5.2.18, 6.0.9 and 6.1.2). This one closes the field assignment path, which the August advisory had deliberately left open.

Technical sheet

ItemValue
IdentifierCVE-2026-124827, nicknamed Django4Shell (Mohammed Fathy)
Componentdjango.contrib.gis.db.models.RasterField, assignment of a raster data definition (ds_input), and the GDAL driver
ClassCWE-73, external control of a file name or path
Score8.8 CVSS 3.1 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H) and 8.7 CVSS 4.0; "high" per Django; 9.0 per The Hacker News
Affected versionsDjango 5.2 before 5.2.20, 6.0 before 6.0.11, 6.1 before 6.1.4. Series 5.1, 5.0 and 4.2 not evaluated, so possibly affected
Fixed versions5.2.20, 6.0.11, 6.1.4
ConditionsGeoDjango on PostGIS, a RasterField, an untrusted value assigned to it, a GDAL driver able to write
DiscoveryMohammed Fathy; report received 22 October 2026, flaw confirmed 9 November
ExploitationNone observed; public exploits since 2 December; CISA SSVC: Exploitation none, Automatable no, Technical Impact total

The score deserves a remark, because the sources disagree. The record published by Django gives 8.8 and 8.7. The Hacker News writes 9.0 and calls it critical, whereas Django rates it "high" and the vector contains PR:L (low privileges). The two numbers do not measure the same thing, and that is probably where they part. Django's 8.8 assumes an account (PR:L): the admin case, staff-only. But when the field is exposed by a public view or an open API, the attacker needs no account, the vector drops to PR:N, and the score rises toward the 9.0 The Hacker News gives without a vector. We keep the vendor's 8.8 as the reference figure, bearing in mind that the population actually exposed decides the rest. The exploit repositories that appeared since repeat "9.0, critical" without settling this point.

We would treat it as critical anyway, on any application that exposes a RasterField to users we do not control. An admin account is not always a trusted account, and an arbitrary file write turns into code execution without much effort.

Affected systems

Who is affected

GeoDjango is Django's mapping module. It provides geometry fields (points, polygons), which are not concerned, and a RasterField, which stores georeferenced images in PostGIS. Only the latter is involved, and it exists only on PostGIS.

We think the real scope is narrow: GeoDjango is mostly used to store geometries, and those are not affected. The Hacker News cites a "moderate" prevalence in mapping, agricultural or environmental platforms, with no figure, and we have none either.

One detail changes the reading, though: the advisory says the flaw is reachable "by default". Nothing has to be misconfigured. An application that declares a RasterField and registers its model in the admin is in that position without having decided it.

Versions

The three supported series are affected, and Django did not evaluate older series (5.1, 5.0, 4.2), while stating they may be affected too. Those series are unsupported: they will not get a fix, and the only way out is to migrate.

Versions that already carry the August fix (from 5.2.17 and 6.0.8 onwards) are therefore still affected. A team that updated for CVE-2026-15307 and considered the matter closed is not covered.

Who can reach the field

The sources do not say the same thing, and this is the part to read carefully. The CVE record retains low privileges. The researcher tells The Hacker News that the main requirement is staff-level access (the Django admin's "staff"). Django's advisory adds ModelForms and writable serializers, which goes beyond the admin: an API that accepts a raster as JSON from any logged-in user is in scope.

So we will retain this: the flaw is reachable by anyone who can write to the model, and that population varies by application. A platform where hundreds of contributors can upload rasters is not the same as an internal tool with two administrators.

Exploitation and public exploits

The CVE record was updated on 3 December at 4

UTC, and its CISA SSVC still reads "Exploitation: none" and "Automatable: no". That assessment predates the repositories described below and does not account for them: we would not rely on it to decide anything.

A GitHub search returned six repositories on the morning of 3 December. The first was created on 2 December at 15

UTC, barely nine hours after the advisory, and the others followed through the evening and the night. We read their descriptions and landing files, without running their code or citing them here. They advertise an exploit, a Docker lab, a check mode and a Nuclei or Nmap detector which, from their descriptions, logs in with a staff account. Their mechanism matches what the advisory describes: a write at form validation, followed by execution when a process re-imports the dropped file.

What these repositories change for the operator is simple: the attacker's work is done, and only the access condition remains to be met. We did not replay them, and we cannot say which ones work. None tells us about a real exploitation.

How it works

This section stays at the level of the advisory and the code of the fix. It is enough to understand where to look, not to reproduce anything.

A raster definition is a dictionary (or its JSON form) that describes a raster: its driver, its dimensions, its bands and a name. With the default driver, which works in memory, name points to nothing on disk. With a driver that produces a file, name becomes the path where GDAL writes it.

When such a value is assigned to a RasterField, Django converts it into a GDALRaster object, and that constructor opens the raster for writing. The value coming from the form is therefore interpreted as an instruction to create a file, whose location the attacker controls and, according to the researcher, whose content too. The write happens at assignment, before anything is saved to the database.

The form field of a RasterField is a plain text field. Text typed into the admin is therefore received as a string, read as JSON, and treated as a definition.

The researcher describes possible follow-ups with a file dropped into the application's working directory and imported automatically at the next start. We do not detail that path. The point to remember is that an arbitrary write converts into code execution at the next start of a Python process, or by dropping a file into a served directory.

Why August was not enough

The August fix covered spatial filters only, and the documentation said so: field assignments were deliberately left untouched, on the grounds that input validation is the application's job. Upwind sums this up by writing that "half of August's fix stayed open". That is its reading, not Django's, but it is accurate.

The design flaw lies elsewhere: a model field that accepts, through a simple assignment, instructions to create files. In the earlier state, the application's security depended on the validation of each form, and the default form checked nothing of the kind.

The fix

The fix is one commit backported to the three series (four commits in total). It acts at two levels.

The first makes RasterField non-editable by default: it no longer shows up in a ModelForm or the admin unless the developer asks for it. That closes the default exposure.

The second validates the assignment. A dictionary or JSON string that names a driver other than the in-memory one now raises a GDALException. To use another driver with a trusted value, the definition must be wrapped in GDALRaster, which means "I accept that this value writes a file".

We find this second level more important than the first. The first is undone by declaring editable=True, for instance to allow raster uploads. The second holds even then, as long as the driver is not the in-memory one.

Two limits are written in the advisory. The first: the exception only limits writes to disk, and outbound requests remain possible if an untrusted value is assigned (a raster that points to a remote source, for example). The second: the change is not backward compatible for anyone who deliberately used a file driver through this path. Those applications will have to wrap their values, or they will fail.

The lab confirms the closure on the path we tested (see below). We cannot say it is closed in every case: we only tried one driver, through the admin form.

What the lab verified

A staff account sends, through the admin add form, a raster definition whose driver produces a file and whose name points to a harmless file in the container's temporary directory. The model is declared with a plain RasterField, the database is SQLite and the table does not exist: saving fails (a 500 error), but the write has already happened, at form validation.

TargetResult
Django 6.1.3, GeoDjangothe field is in the form, the file is written
Django 5.2.19, GeoDjangothe field is in the form, the file is written
Django 6.1.4, GeoDjangothe field is no longer in the form, no file
Django 6.1.4, explicit editable=TrueGDALException: "Only in-memory (MEM) data definitions can be assigned to RasterField (got: 'GTiff')"

Two remarks that only hands-on testing gives. The first: the write happens at validation (is_valid()), before any call to save(). An application that checks what it saves afterwards, or whose save fails, has already left the file on disk. The second: on 6.1.4 it is the first level of the fix that protects an application that changed nothing, and the second that answers when a developer has reopened the field.

What these tests do not say: we did not use PostGIS, did not try any driver other than the common image-file one, did not try to place a file anywhere other than the temporary directory, and executed nothing. The write is established; the rest of the chain described by the researcher is not, and we did not attempt it.

Checking an application

Three questions: which Django version, is a RasterField declared, and who can write to the model.

# 1. Django version in the application's environment
python -c "import django; print(django.get_version())"
 
# 2. Is a RasterField declared?
grep -rn "RasterField" --include=*.py .
 
# 3. Is the field exposed for writing? (admin, forms, serializers)
grep -rn "RasterField\|ModelAdmin\|ModelForm\|ModelSerializer" --include=*.py . | grep -i raster

A version below 5.2.20, 6.0.11 or 6.1.4 and a RasterField that is not excluded from forms is the case to handle first. A RasterField declared on a model that no user ever fills in (fed by a trusted internal import) is far less of a problem.

From the outside

There is no reliable remote test. The flaw lives in the application's code: an exposed Django publishes neither its version nor its list of models, and the only probe that would confirm the flaw would be to make the target write a file, which we will never do.

We wrote a Nuclei template, CVE-2026-124827-flawfence, that is limited to locating. It sends two GET requests with no body: the admin login page (/admin/), from which it reads the static files prefix, then gis/js/OLMapWidget.js under that prefix, which Django only collects if django.contrib.gis is installed. It posts nothing and writes nothing on the target.

It is deliberately rated info: the fix only changes Python code, no static file differs between 6.1.3 and 6.1.4, and without authentication nothing tells a patched version from a vulnerable one. It flags the GeoDjango targets of our lab, patched ones included, and stays silent on Django without GeoDjango, on Apache, and on an application that answers 200 to every address. A result is a candidate, to close with the commands above: GeoDjango installed is a condition, not a flaw, and most GeoDjango applications have no RasterField.

We also wrote a second template, CVE-2026-124827-flawfence-authenticated, that confirms the flaw instead of locating it. It has no false positive, but it comes at a price: it needs an account able to write to the model, and it actually writes a benign probe file on the target. Its logic rests on the two things the fix changes: on a patched version the field disappears from the form by default, and if it is re-enabled, the write is refused by an exception before it reaches GDAL. The template therefore requires both: the field present in the add form and a success redirect after the raster definition is submitted. Only a vulnerable version satisfies both, and the file appears only on it. This is a tool for an authorised penetration test, not for mass scanning: it changes the target, so run it only with permission and clean up the files it drops. We validated it on our lab (write confirmed on a 6.1.3 with a PostGIS backend, silence on a default 6.1.4 and on a 6.1.4 with editable=True re-enabled).

An admin moved elsewhere, protected upstream or whose static files are served by a CDN will not be seen.

Remediation

  1. Update to 5.2.20, 6.0.11 or 6.1.4, then rebuild container images: an image built before 2 December embeds the old version. The update also fixes a SQL injection rated "high" (CVE-2026-132092), which makes it a priority for any Django application.
  2. Without waiting, remove the RasterField from the admin, from ModelForms and from writable serializers (exclude, or editable=False), until the update is done.
  3. Validate inputs before they reach the field if the application really must accept rasters: reject anything that is not an expected raster file, rather than accepting a definition.
  4. Reduce what a staff account can do: remove write permissions on raster models from those who do not need them.
  5. Run the application with a read-only code directory and no write access to the Python environment. That is the measure that turns a file write into a plain failure, whatever the next flaw is.
  6. To limit the available GDAL drivers, Django's documentation points to GDAL's "security" page.

We would do points 1 and 5 everywhere. Point 2 is a stopgap: a RasterField hidden from the admin remains reachable through an API.

Looking for compromise

No indicator of compromise has been published, and no exploitation in the wild is reported to date, even though public exploits exist. The following leads come from the nature of the flaw, not from an observed case.

  • the Django admin log (django_admin_log table) for changes to models with a RasterField made by staff accounts, especially outside working hours;
  • recent or unexpected files in the application directory, its media and static directories, and the Python environment (sitecustomize.py, usercustomize.py or .pth files that nobody deployed);
  • unusual child processes spawned by the application server (a shell, a download tool);
  • in the web server logs, POST requests to the change form of the relevant model from an unusual address.

An arbitrary file write does not need to leave a trace in the database: the researcher says nothing is saved. The absence of a suspicious row in the admin therefore does not mean the absence of an incident.

On an exposed application with an editable RasterField before 2 December, we would check the contents of the application directory rather than rely on the log.

Timeline

The dates come from the CVE records, the 2 December advisory and the fix. The main commit of the fix carries the date of 28 October, before the confirmation of the flaw given by the record (9 November): we have no explanation, and a commit date is its author's, not that of its merge.

Timeline

Django4Shell timeline

Earlier fixes

  1. 4 August 2026

    CVE-2026-15307

    spatial filters can no longer create a raster from dictionaries or strings (5.2.17, 6.0.8). Field assignments stay open.

  2. 6 October 2026

    CVE-2026-87890

    the binary-value case missed by the August fix, outbound requests (5.2.18, 6.0.9, 6.1.2).

This flaw

  1. 22 October 2026

    Report

    Mohammed Fathy sends the flaw to Django.

  2. 28 October 2026

    Fix commit

    author date of the main commit.

  3. 9 November 2026

    Confirmation

    the flaw is confirmed and the identifier reserved.

Publication

  1. 2 December 2026, 7

    Fixes published

    5.2.20, 6.0.11 and 6.1.4, with six other flaws.

  2. 2 December 2026, 14

    CISA SSVC

    exploitation "none", automatable "no", technical impact "total".

  3. 2 December 2026, 15

    First public exploit

    a GitHub repository is created. Others follow through the evening.

  4. 3 December 2026, 4

    CVE record updated

    the SSVC stays at "none".

  5. 3 December 2026, morning

    Six exploit repositories

    five new ones since the day before, some with a Docker lab.

CVE-2026-15307, CVE-2026-87890 and CVE-2026-124827 records, Django advisory of 2 December 2026. Times in UTC when the record gives them.

Frequently asked questions about Django4Shell

What is Django4Shell?

The nickname its discoverer gave to CVE-2026-124827, an arbitrary file write in GeoDjango's RasterField that can lead to code execution. Django does not use it in its advisory.

Are all Django applications affected?

No. It takes GeoDjango on PostGIS and a model that carries a RasterField. Django applications without GeoDjango, or with only geometry fields, are not affected by this flaw.

Do you need to be authenticated?

It depends on the application. Through the admin, yes: a staff account is required (the record's PR:L). But Django's advisory also puts ModelForms and writable serializers in scope: a public view or an open API that accepts the raster makes the flaw reachable with no account at all. This second population is most likely what explains the "critical" score sometimes quoted, higher than the admin's 8.8.

What is the real score?

8.8 in CVSS 3.1 and 8.7 in CVSS 4.0 according to the record published by Django, rated "high". The Hacker News writes 9.0 without specifying the vector.

Are my 5.2.17 or 6.0.8 versions protected?

No. Those versions carry the August fix, which only concerned spatial filters. Only 5.2.20, 6.0.11 and 6.1.4 close the field assignment.

Is the flaw being exploited?

We have seen no exploitation in the wild as of 3 December, and CISA's SSVC reads "Exploitation: none", but that assessment predates the public exploits. At least six repositories offer one since 2 December, and since the fix is public, anyone who reads the commit knows where to look. We treat the flaw as exploitable by anyone who holds the right account.

Is the fix enough?

For the file write, that is what the advisory says. It specifies that outbound requests remain possible if an untrusted value is assigned: validating inputs remains the application's job.

What should I do right now?

Update, remove RasterField from the admin and forms in the meantime, then check recent files in the application directory.

Sources

Let’s discuss your external exposure

Request a personalized Flawfence demo and discover your real exposure level.