Skip to content
Haxset

Django4Shell: Affected Django Versions, Fix and Workaround

Am I affected by Django4Shell? Yes, if users can submit a GeoDjango RasterField on Django 6.1 before 6.1.4, 6.0 before 6.0.11 or 5.2 before 5.2.20.

Haxset Research

8 min read

Contents10 sections
  1. What is Django4Shell and how does it work?
  2. Which Django versions are affected?
  3. How do I check whether my app is affected?
  4. How do I fix Django4Shell?
  5. What can I do if I cannot patch today?
  6. Is Django4Shell being exploited?
  7. What is still unknown?
  8. How Haxset can help
  9. Related research
  10. References

What is Django4Shell and how does it work?⁠

Django4Shell is a file write through GeoDjango's RasterField, the model field that stores raster images on PostGIS. Django describes it this way: assigning a raster data definition "with a user-controlled name parameter and a non-default driver could cause GDAL to write a file to an attacker-controlled location. Depending on the raster driver, this could enable remote code execution."1 The field falls back to a plain text form field, so Django says the flaw "was reachable by default on models with RasterField registered in the admin or using ModelForms or writable model serializers".1

Django, the CVE record and NVD do not use the name Django4Shell. It comes from the site django4shell.com, which presents itself as the advisory of Mohammed Fathy of Robusta Technology Group. Django credits Fathy with the report.12

Django rates the flaw "high" under its own security policy. The Django Software Foundation, which assigned the CVE, scores it 8.8 under CVSS 3.1 and 8.7 under CVSS 4.0. Both vectors set privileges required to low (PR:L), such as an ordinary logged-in account.3 A "9.0 Critical" figure that circulates comes from the README of the third-party proof of concept described below, not from Django or the CVE record.

The reporter adds details that Django does not confirm. In the reporter's account, a staff user submits a crafted raster to an admin page or ModelForm, and GDAL writes the file during form validation, before any database work. The reporter's chain uses GDAL's EHdr driver to write a sitecustomize.py file, which Python runs the next time a worker or command starts.2

The reporter calls the flaw a bypass of CVE-2026-87890. Django's advisories do not describe it that way. CVE-2026-87890 was a moderate request-forgery flaw in spatial lookups, released in October, that Django says "was overlooked in the fix for CVE-2026-15307".1

Which Django versions are affected?⁠

Django 6.1 before 6.1.4, 6.0 before 6.0.11 and 5.2 before 5.2.20 are affected, as is the main branch. Django released the three fixed versions on 2 December 2026.13

SeriesAffectedFixed in
6.16.1 to 6.1.36.1.4
6.06.0 to 6.0.106.0.11
5.2 LTS5.2 to 5.2.195.2.20
5.1, 5.0, 4.2Not evaluatedNo fix

The CVE record says that "Earlier, unsupported Django series (such as 5.1.x, 5.0.x, and 4.2.x) were not evaluated and may also be affected."3 Those series no longer get security fixes, so an app on them that uses RasterField has to move to a supported series. The reporter's site lists only Django 6.1.2, the version it tested. Use Django's range.

The app must also use RasterField, which "is only implemented on PostGIS", and geometry fields are not affected.1 The reporter says no PostGIS connection is needed at the moment of the write.2 If the reporter is right, both statements hold: a real app needs PostGIS to have the field at all, but the write happens before the database is touched.

How do I check whether my app is affected?⁠

Run these commands in the project's own environment, from its root:

text
python -m django --version
grep -rn --include='*.py' --exclude-dir=venv --exclude-dir=.venv -e 'django.contrib.gis' -e 'RasterField' .
grep -rln --include='*.py' RasterField "$(python -c 'import django, os; print(os.path.dirname(os.path.dirname(django.__file__)))')" | grep -v '/django/contrib/gis/'

The first prints the Django version. The second finds GeoDjango and RasterField in your code, skipping a venv or .venv folder. The third lists installed packages that mention RasterField, other than Django's own GeoDjango code.

For each RasterField you find, check where users can write to it: an admin class, a ModelForm whose fields include it (or use __all__), or a writable API serializer. Then check who can reach each of those. The admin needs a staff account. Any form or serializer that exposes the field to untrusted users is in scope too, including a public one.

How do I fix Django4Shell?⁠

Upgrade to Django 6.1.4, 6.0.11 or 5.2.20, and restart every process that runs Django.1 If an untrusted or staff account could reach the field before the upgrade, first look for unexpected sitecustomize.py or .pth files in the project folder and site-packages. The reporter's chain runs such a file at the next start.2

The fix makes two changes that can break existing code, so test before you deploy:14

  • RasterField now defaults to editable=False. Django's fix commit says this prevents its "accidental inclusion in writable API serializers or ModelForms (e.g., in the admin)". A developer can still add it back explicitly.
  • Assigning a dict or JSON string that names any driver other than the in-memory default now raises GDALException. To use another driver with trusted input, wrap the value in GDALRaster.

Admin pages and forms that edited rasters lose the field, and dict input with other drivers now fails. One risk stays open. Django says: "Server-side request forgery is still possible if untrusted input is assigned to RasterField." It tells users to validate input before assigning it.1

When we checked Debian, Ubuntu, Red Hat, Fedora and Alpine at about 17:40 UTC on 2 December 2026, none had a fixed package. Debian sid and Alpine edge shipped 5.2.19. Until a package arrives, install the fixed release from PyPI in a virtual environment.

What can I do if I cannot patch today?⁠

Django offers no workaround beyond upgrading and validating input.1 Haxset's advice until you can upgrade: remove RasterField from every admin class, ModelForm and writable serializer that untrusted or staff users can submit, or set editable=False on the field yourself.

This stopgap does not cover code that assigns user input to the field directly, and it does not fix the six other flaws in the same releases. One of them is CVE-2026-132092, a potential SQL injection in the range and in lookups that Django also rates "high".1 It does not need GeoDjango, so upgrade even if you found no RasterField.

Is Django4Shell being exploited?⁠

The CVE was not in CISA's Known Exploited Vulnerabilities catalog at 17:38 UTC on 2 December 2026. CISA's assessment in the CVE record, added at 14:49 UTC, records exploitation as "none".3 We found no public report of attacks by 17:45 UTC.

A public proof of concept exists. A third party, not the reporter, published one on GitHub at 15:52 UTC on 2 December. Haxset has not run it. The reporter's own page also describes the attack step by step.2 Assume attackers can exploit it today.

What is still unknown?⁠

No cited source says how often a public form exposes a RasterField in practice. Your own forms and serializers decide your exposure.

Django does not say which GDAL drivers allow code execution. The EHdr driver comes from the reporter alone. At 17:40 UTC, GitHub's advisory for the CVE was still unreviewed and listed no package versions, so a dependency scanner that relies on it may not flag Django yet.

How Haxset can help⁠

Haxset's AI SAST and the AI PR Scanner check a project's dependencies against public vulnerability databases, and Agentic Pentesting tests web applications. Haxset does not keep the prompts its AI models process and does not train models on them. It stores only scan metadata and scan results. To scope a first engagement, contact us.

References

  1. Django, Django security releases issued: 6.1.4, 6.0.11, and 5.2.20, Django weblog, 2 December 2026, and Django security releases issued: 6.1.2, 6.0.9, and 5.2.18, 6 October 2026. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11

  2. Mohammed Fathy, Robusta Technology Group, Django4Shell, the reporter's advisory at django4shell.com, 2 December 2026. ↩ ↩2 ↩3 ↩4 ↩5

  3. CVE Program, CVE-2026-124827: Server-side file-write via RasterField assignment, CVE record from the Django Software Foundation, 2 December 2026. ↩ ↩2 ↩3 ↩4

  4. Jacob Walls, Django, Fixed CVE-2026-124827 -- Rejected non-default drivers when assigning data definitions to RasterField, commit on the main branch, authored 28 October and merged 2 December 2026. ↩

Share this post

LinkedInX

Haxset Research

Research from the offensive-security experts behind the Haxset Engine.