# Django4Shell (CVE-2026-124827): GeoDjango RasterField RCE, What to Do

> Django 6.1.4, 6.0.11 and 5.2.20 fix CVE-2026-124827, a GeoDjango RasterField file-write flaw nicknamed Django4Shell. Check if you are exposed and patch.

Source: https://www.epifive.com/blog/django4shell-vulnerability-enable-django-rce-via-geodjango · Published 2026-12-05 · EpiFive

## Key takeaways

- CVE-2026-124827 (Django4Shell) is fixed in Django 6.1.4, 6.0.11 and 5.2.20, released December 2, 2026.
- Only projects with a RasterField model on PostGIS are exposed, but RasterField reached the admin and ModelForms by default before the fix.
- Django rates the flaw "high"; the CVSS 9.0 score and the staff-login requirement come from the researcher's write-up, not from Django.
- After upgrading, RasterField is no longer editable by default and rejects non-default drivers from dict or JSON input.
- The same release fixes a high-severity SQL injection in range and in lookups, so patch even if you do not use GeoDjango.

Django's December 2, 2026 security release fixes CVE-2026-124827, nicknamed Django4Shell: assigning an attacker-controlled raster definition to a GeoDjango `RasterField` could make GDAL write a file to a location the attacker chooses, which, depending on the driver, could lead to remote code execution. The fix ships in Django 6.1.4, 6.0.11 and 5.2.20. If you have a `RasterField` model (PostGIS only), upgrade first and then review who can submit data to that field.

## Who this is for and what you will have at the end

This guide is for developers and ops engineers who run Django applications, especially anyone using `django.contrib.gis` with PostGIS. By the end you will know whether your project can reach the vulnerable code, which version to install, how to confirm the fix, and which settings and habits reduce the blast radius if another raster-handling bug appears. It gives no exploit details; it covers detection and defense only.

## What happened

The sequence below comes from Django's own security release posts and release notes, plus The Hacker News report of the researcher's write-up.

| Date | Event | Source |
|---|---|---|
| August 4, 2026 | Django 6.0.8 and 5.2.17 fix CVE-2026-15307, a GeoDjango spatial-lookup flaw Django describes as server-side file write and request forgery, rated high | Django weblog |
| October 6, 2026 | Django 6.1.2, 6.0.9 and 5.2.18 fix CVE-2026-87890, request forgery through raster `bytes` in spatial lookups (moderate). Raster `bytes` must now be wrapped in `GDALRaster` before spatial lookups | Django weblog |
| December 2, 2026 | Django 6.1.4, 6.0.11 and 5.2.20 fix CVE-2026-124827 in `RasterField` assignment (high) | Django weblog, release notes |

Django's release notes describe the December flaw this way: assigning a raster data definition to `RasterField` with a user-controlled `name` parameter and a non-default `driver` could cause GDAL to write a file to an attacker-controlled location. Because `RasterField` falls back to the `CharField` form field, the flaw "was reachable by default on models with `RasterField` registered in the admin or using `ModelForm`s or writable model serializers." Geometry fields were not affected, and `RasterField` is only implemented on PostGIS.

The Hacker News reported that the "Django4shell" name was given by a security researcher, who describes the bug as an incomplete fix in the chain of earlier raster issues: the earlier protections did not cover the `RasterField` assignment path. That framing is the researcher's. Django's advisory does not call the issue an incomplete fix, so treat that as the reporter's analysis.

### What Django says and what the researcher says

| Claim | Who made it | Status |
|---|---|---|
| Severity "high" under the Django security policy | Django | Official |
| Fixed in 6.1.4, 6.0.11, 5.2.20 | Django | Official |
| CVSS 9.0 (critical) | Researcher, via The Hacker News | Reported; Django's page shows only "high" |
| Exploitation needs staff-level authentication | Researcher, via The Hacker News | Reported; Django's note says the field was reachable through the admin, ModelForms and writable serializers |
| Attackers could overwrite app code, drop web shells or write `sitecustomize.py` | Researcher, via The Hacker News | Reported impact scenarios, not stated by Django |
| Active exploitation in the wild | Nobody | Neither source we read reports any; not confirmed |

The staff-login point matters for prioritizing, but do not rely on it. A public form, an API endpoint built on a writable serializer, or a compromised staff account changes the picture. Django's own wording is that the field was reachable wherever `RasterField` was exposed through those three paths.

## Am I affected?

Work through these checks in order. You are exposed only if all of the first three are true.

1. Your project uses `django.contrib.gis` and a model with `RasterField`.
2. You run PostGIS as the database backend (Django says `RasterField` is only implemented there).
3. Your Django version is below the fixed release for your branch (see the table in the next section).
4. Then ask the exposure question: can untrusted or semi-trusted users send data that ends up assigned to that field?

### Check your Django version

```bash
python -m django --version
pip show django
```

### Find RasterField in your code

```bash
grep -rn "RasterField" --include="*.py" .
grep -rn "django.contrib.gis" --include="*.py" .
```

If the first command prints nothing, your own models do not define a raster field. Also check third-party apps in your virtual environment, since they can define models too:

```bash
grep -rn "RasterField" "$(python -c 'import site; print(site.getsitepackages()[0])')" --include="*.py" -l
```

### Find the exposure paths

Look for each of these for any model that has a raster field:

| Exposure path | What to look for |
|---|---|
| Admin | The model registered with `admin.site.register` or a `ModelAdmin` |
| ModelForm | A `ModelForm` with `fields = "__all__"` or the raster field listed |
| API | A writable Django REST framework serializer or any code that assigns request JSON to the field |
| Imports | Management commands or upload handlers that assign dicts or JSON strings to the field |

Before the fix, a `RasterField` model registered in the admin was enough to make the field reachable, because the form field fell back to a text input. After the fix, `RasterField` defaults `editable` to `False`, which excludes it from a `ModelForm` unless you explicitly include it.

## What to do now

Do these in order of urgency.

1. **Upgrade Django to the fixed release for your branch.** Use 6.1.4, 6.0.11 or 5.2.20. Django's advisory lists nothing else as a remedy.
2. **Restart every worker.** A new package on disk does nothing until Gunicorn, uWSGI, Celery and any scheduled job processes reload.
3. **Check whether you are on a supported series.** If you run an older release such as 4.2, Django does not issue patches for it and says older versions may also be vulnerable. Plan an upgrade to a supported series.
4. **Clear caches** if you use Django's cache middleware. The same release fixes CVE-2026-125673, and Django notes that existing caches are not invalidated.
5. **Review who has staff access** to a site that uses RasterField, and remove accounts you do not recognize.
6. **Look for signs of tampering** (see below), because a bug like this is a file write.

### Step 1: Upgrade

Pin the fixed version for your branch in your requirements file, then install:

```bash
# Django 6.1 series
pip install "Django==6.1.4"

# Django 6.0 series
pip install "Django==6.0.11"

# Django 5.2 series (LTS)
pip install "Django==5.2.20"
```

Rebuild your container image or virtual environment the way you normally deploy, so production gets the same version you tested. Run your test suite, then deploy.

### Step 2: Confirm the fix

```bash
python -m django --version
```

The output should be the fixed version for your branch. Then check the documented behavior in a Django shell on a staging copy:

```python
from django.contrib.gis.db import models
f = models.RasterField()
print(f.editable)
```

Per the Django 5.2 documentation, the expected value is `False`, because "Changed in Django 5.2.20: Defaulting `editable` to `False` was added."

### Step 3: Check for tampering

Django's advisory covers the fix, not forensics, so use general file-integrity checks. The researcher's write-up, as reported, names Python startup files and application source as targets. Check that nothing unexpected sits in your application directories:

```bash
# Python files changed in the last 14 days under your app directory
find /srv/app -name "*.py" -mtime -14 -ls

# Startup hooks that Python imports automatically
find /srv/app /usr/lib/python3*/site-packages -name "sitecustomize.py" -o -name "*.pth" 2>/dev/null
```

Adjust the paths to your deployment. A `.pth` file or `sitecustomize.py` that you did not create deserves investigation. If your app runs from a Git checkout or an immutable image, compare the deployed files to the repository or image digest instead.

If you find something unexpected, treat the host as compromised: isolate it, preserve logs, rotate the secrets that process could read (database passwords, `SECRET_KEY`, cloud keys), and redeploy from a clean image. For database-level recovery planning see [PostgreSQL backups with pgBackRest](https://www.epifive.com/blog/postgresql-backup-pgbackrest-guide).

### If you cannot upgrade today

Django lists no workaround besides upgrading. Django's documentation says: "Do not assign untrusted input to `RasterField` without custom validation." Until you can patch, remove the raster field from admin forms and from any serializer that accepts client data, for example by using `exclude` or `readonly_fields`. This is a stopgap based on Django's own guidance, not a fix; the upgrade is still required.

## What the fix changes in your code

The release notes describe two behavior changes:

- `RasterField` now defaults `editable` to `False`, so it is left out of a `ModelForm` unless you include it deliberately.
- `RasterField` raises `GDALException` when you assign a `dict` or JSON string that names a non-default driver. To use another driver with trusted input, wrap the definition in `GDALRaster` to signal that you trust it.

If your project edits rasters through the admin on purpose, expect them to disappear from the form after the upgrade. Add the field back explicitly, and only after you have written validation:

```python
# Only do this with custom validation in place
class ElevationForm(forms.ModelForm):
    class Meta:
        model = Elevation
        fields = ["name", "rast"]
```

Be clear about what is not fixed. Django states that the new exception "only limits server-side file writes. Server-side request forgery is still possible if untrusted input is assigned to `RasterField`." So even on a patched version, validate raster input before you accept it.

## Other fixes in the same release

The December 2 release fixes more than one bug. Django's table lists:

| CVE | Component | Django severity |
|---|---|---|
| CVE-2026-124827 | `RasterField` assignment | High |
| CVE-2026-132092 | `range` and `in` lookups, SQL injection with percent signs in aliases or key transforms | High |
| CVE-2026-115868 | `truncatechars_html` | Moderate |
| CVE-2026-125673 | `build_absolute_uri()` and cache middleware | Low |
| CVE-2026-119642 | Admin changelist, `pk` alias on `OneToOneField` | Low |
| CVE-2026-127929 | Admin changelist, reverse relations | Low |
| CVE-2026-132809 | `OGRGeometry.wkb` with geometries over 4 GB | Low |

The SQL injection fix is a reason to upgrade even if you have no GeoDjango. Per the release notes, the `range` lookup now requires exactly two right-hand side values, and percent signs in column aliases and key transforms were deprecated in Django 6.0. Test any code that passes a list of a different length to `__range`.

## How to prevent it

- **Treat raster and geometry input as untrusted.** Django's GDAL documentation says instantiating `GDALRaster` from untrusted input "allows an attacker to write a file or make a network request." Validate input before it reaches a model field.
- **Wrap trusted values explicitly.** Spatial lookups block `bytes`, `str`, `pathlib.Path` and `dict` values; wrap with `GDALRaster` only when you trust the source.
- **Run the web process with least privilege.** If the application user cannot write to the project directory or site-packages, a file-write bug has fewer places to land. Mount code read-only in containers where you can.
- **Limit staff accounts and require MFA** for the admin. Even where an issue needs a staff login, a stolen staff password is a common starting point.
- **Subscribe to Django's announcements.** Django's security policy says it notifies the django-announce list about a week before disclosure of date, time and severity, and posts each release on its weblog. Put that on a calendar for your upgrade window.
- **Stay on a supported series.** Django patches only the newest series and LTS releases. A major database or runtime upgrade is easier when planned; see [PostgreSQL major version upgrade with pg_upgrade](https://www.epifive.com/blog/postgresql-major-version-upgrade-pg-upgrade) for a related example.
- **Review GDAL driver availability.** Django's documentation points to defense-in-depth steps for limiting the raster drivers available. We could not read that part of the page in this run, so open the GDAL security section of the Django docs and follow it.

## Checklist

1. Run `python -m django --version` on every environment (dev, staging, production, CI images).
2. Search for `RasterField` in your code and in installed apps.
3. Upgrade to 6.1.4, 6.0.11 or 5.2.20.
4. Restart all workers and scheduled jobs.
5. Clear caches that might hold responses cached before the fix.
6. Look for unexpected `sitecustomize.py`, `.pth` and changed `.py` files.
7. Validate raster input; do not rely on the new default alone.
8. Plan the move off any unsupported Django series.

## What we checked

- Opened Django's December 2, 2026 security release post (djangoproject.com) on 2026-12-05: fixed versions 6.1.4, 6.0.11 and 5.2.20, the table of seven CVEs, and "High" for CVE-2026-124827 and CVE-2026-132092.
- Opened the Django 5.2.20 release notes on 2026-12-05 and compared the CVE-2026-124827 wording with the release post; both state a file write via `RasterField` assignment and the `editable` and `GDALException` changes.
- Opened the Django 5.2 `RasterField` model API page: `editable` defaults to `False` ("Changed in Django 5.2.20") and `RasterField` is only implemented on PostGIS.
- Opened the Django GDAL page (security considerations) and the October 6, 2026 release post to confirm CVE-2026-87890 and the `GDALRaster` wrapping rule. The last part of the GDAL page was cut off when fetched, so the defense-in-depth section on limiting raster drivers was not read.
- Opened the Django security policy page: supported series, advance notice on django-announce, and the severity table (RCE and SQL injection are "High").
- Read The Hacker News report for the researcher's claims (CVSS 9.0, staff-level authentication, file-write scenarios) and labelled them as reported. The django4shell.com page returned only a title, so we could not verify anything from it.
- Not tested: we did not run Django, PostGIS or GDAL, so the shell and `find` commands are standard checks, not documented vendor output. The version check and `editable` value come from the documentation. No CVE record in NVD was opened in this run.

Last tested: 2026-12-05

## References

- [Django security releases: 6.1.4, 6.0.11, 5.2.20 (December 2, 2026)](https://www.djangoproject.com/weblog/2026/dec/02/security-releases/)
- [Django 5.2.20 release notes](https://docs.djangoproject.com/en/5.2/releases/5.2.20/)
- [Django GeoDjango model API: RasterField](https://docs.djangoproject.com/en/5.2/ref/contrib/gis/model-api/)
- [Django GDAL API: security considerations](https://docs.djangoproject.com/en/5.2/ref/contrib/gis/gdal/)
- [Django security policy](https://docs.djangoproject.com/en/5.2/internals/security/)
- [Django security releases, October 6, 2026](https://www.djangoproject.com/weblog/2026/oct/06/security-releases/)
- [Django security releases, August 4, 2026](https://www.djangoproject.com/weblog/2026/aug/04/security-releases/)
- [The Hacker News: Django4Shell vulnerability enables Django RCE](https://thehackernews.com/2026/12/new-django4shell-vulnerability-enables.html)

## Frequently asked questions

### Is Django4Shell the same as CVE-2026-124827?

Yes. Django4Shell is the name a researcher gave to CVE-2026-124827, as reported by The Hacker News. Django's own advisory uses only the CVE number and describes it as a server-side file write via RasterField assignment that, depending on the raster driver, could enable remote code execution.

### Which Django versions fix it?

Django 6.1.4, 6.0.11 and 5.2.20, released on December 2, 2026. The advisory lists the main, 6.1, 6.0 and 5.2 branches as affected. Django supports only the newest release series and LTS releases, so older versions may also be vulnerable and will not get a patch.

### Do I need to patch if I do not use GeoDjango?

This flaw needs a model that uses RasterField, which only works on PostGIS and lives in django.contrib.gis. Django says geometry fields were not affected. You should still upgrade, because the same release fixes a high-severity SQL injection (CVE-2026-132092) and other issues.

### Is there a workaround if I cannot upgrade today?

Django's advisory does not list a workaround other than upgrading. Its documentation says not to assign untrusted input to RasterField without custom validation, so the safe interim step is to keep RasterField out of admin forms, ModelForms and writable serializers until you can patch.

