high

CVE

CVE-2026-124827, CVE-2026-132092, CVE-2026-115868, CVE-2026-125673, CVE-2026-119642, CVE-2026-127929, CVE-2026-132809

CWE

CWE-73, CWE-89, CWE-79, CWE-200, CWE-122

Affected Surface

  • Django 6.1 before 6.1.4, 6.0 before 6.0.11 and 5.2 before 5.2.20 (PyPI `django`); unsupported series such as 4.2, 5.0 and 5.1 were not evaluated
  • CVE-2026-124827 (Django4Shell): GeoDjango apps on PostGIS with a `RasterField` reachable through the admin, a `ModelForm` or a writable serializer
  • CVE-2026-132092: queries that use `__range` with more than two values, or `__in` with a bilateral transform, together with an alias or key transform containing `%`
  • CVE-2026-125673: sites using `UpdateCacheMiddleware` or `cache_page()`; cached responses are not purged by the upgrade

TL;DR

Django shipped 6.1.4, 6.0.11 and 5.2.20 on 2 December 2026 with fixes for seven CVEs. Two of them matter most.

CVE-2026-124827 (Django4Shell) is a file write in GeoDjango. If a model has a RasterField and that field is reachable through the Django admin, a ModelForm or a writable serializer, the user submitting the form can hand Django a JSON raster definition that names a file-backed GDAL driver and a path. GDAL writes the file there while the form is still being validated. Drop a .pth or sitecustomize.py somewhere Python reads at startup and the next worker restart runs your code. The reporter, Mohammed Fathy, gave it the name; Snyk’s write-up uses it too. It needs an account that can reach the form, which in most deployments means staff. Django4Shell only affects GeoDjango on PostGIS.

CVE-2026-132092 is a SQL injection in the range and in lookups. It needs an unusual query shape: an alias or JSON key transform containing a percent sign, plus either a __range with more than two values or an __in behind a bilateral transform. When those line up, Django’s placeholders and parameters get out of step. The CNA scores it CVSS 3.1 9.8 with no privileges required. It applies to every Django app, not only GeoDjango ones, but only code that builds those query shapes is reachable.

Nobody has reported exploitation of any of the seven, and EPSS had no scores for them on 3 December.

What to do now:

  • Upgrade to Django 6.1.4, 6.0.11 or 5.2.20 and redeploy. The fixes are on PyPI as of 2 December, 12:54 UTC.
  • If you run GeoDjango, find every RasterField and check whether it shows up in an admin, form or serializer. Look for unexpected .pth and sitecustomize.py files on those hosts.
  • Clear your cache after upgrading if you use cache_page() or UpdateCacheMiddleware. The CVE-2026-125673 fix does not invalidate entries that were already poisoned.

Affected packages and projects

EcosystemPackageAffected versionsFixed version
PyPIdjango6.1 to 6.1.36.1.4
PyPIdjango6.0 to 6.0.106.0.11
PyPIdjango5.2 to 5.2.195.2.20
PyPIdjango4.2, 5.0, 5.1 and older (unsupported)Not evaluated by Django; no fix. Treat as affected and move to a supported series
CVEIssueDjango severityCNA CVSS 3.1
CVE-2026-124827Django4Shell: server-side file write through RasterField assignmentHigh8.8
CVE-2026-132092SQL injection in range and in lookupsHigh9.8
CVE-2026-115868XSS in truncatechars_html and Truncator.chars(html=True)Moderate6.1
CVE-2026-125673Cache poisoning through . and .. segments in build_absolute_uri()Low3.7
CVE-2026-119642Admin changelist data leak through the pk alias on a OneToOneField primary keyLown/a
CVE-2026-127929Admin changelist data leak through reverse relations (regressed in 5.0.3)Lown/a
CVE-2026-132809Heap buffer overflow in OGRGeometry.wkb for geometries over 4 GBLown/a

The GitHub Advisory Database imported all seven on 2 December as unreviewed advisories (GHSA-fh3p-824r-m74q for Django4Shell, GHSA-c7wh-8726-4mmj for the SQL injection) without package ranges attached yet. Until GitHub reviews them, Dependabot and pip-audit setups that rely on that database may not flag the upgrade. Pin by version instead of waiting for the alert.

Technical analysis

Django4Shell: a form field that hands paths to GDAL

RasterField accepts a raster as a GDALRaster, a dict or a JSON string. A dict is a GDAL data definition, and two of its keys matter here: driver picks the GDAL driver, and name is passed straight to it. With the default in-memory MEM driver, name is just a label. With a file-backed driver, name is where GDAL creates the file. Snyk’s analysis uses EHdr, which is in standard GDAL builds, as the example.

Before the fix, the field’s descriptor built a GDALRaster from whatever was assigned:

# django/contrib/gis/db/models/fields.py, before
setattr(cls, self.attname, SpatialProxy(gdal.GDALRaster, self))

RasterField also had no form field of its own, so Django fell back to a CharField. Register a model with a RasterField in the admin and the admin shows a text box. Whatever JSON the user types becomes ds_input the moment form cleaning assigns it to the instance. Per Snyk, the file is created right then: Django never has to call save() or touch the database.

Snyk spells out the route to code execution. Set name to a path outside the media directory with ../, aim it at a directory on sys.path or at site-packages, and write a sitecustomize.py or a .pth file. Python runs both when an interpreter starts, so the next Gunicorn worker recycle, runserver reload, manage.py command or cron job runs the attacker’s code as the web server’s user. The researcher also notes the same write can drop web shells into static directories or overwrite source and config files.

The fix is in commit a3934ab on main, with backports b70d098 (6.1), 6b5d29e (6.0) and 02d0944 (5.2). It does two things. First, RasterField is no longer editable by default, so it drops out of ModelForms, the admin and model serializers unless you opt back in:

+    def __init__(self, *args, **kwargs):
+        kwargs.setdefault("editable", False)
+        super().__init__(*args, **kwargs)

Second, assignment now goes through a hook that refuses dict and JSON definitions for any driver except MEM:

-        setattr(cls, self.attname, SpatialProxy(gdal.GDALRaster, self))
+        setattr(
+            cls,
+            self.attname,
+            # Field assignment should never write files outside of memory.
+            SpatialProxy(gdal.GDALRaster, self, self.init_raster),
+        )
+
+    def init_raster(self, ds_input):
+        """Hook to reject dict values with out-of-memory drivers."""
+        value = gdal.GDALRaster._preprocess_input(ds_input)
+        if (
+            isinstance(value, dict)
+            and (driver := value.get("driver", "MEM")) is not None
+            and Driver(driver).name != "MEM"
+        ):
+            raise GDALException(
+                "Only in-memory (MEM) data definitions can be assigned to "
+                f"RasterField (got: {driver!r}). Wrap the definition in "
+                "GDALRaster() to use another driver."
+            )
+        return gdal.GDALRaster(value)
  • The check runs on the preprocessed input, so it covers JSON strings as well as dicts. Django’s advisory confirms both now raise GDALException.
  • A missing driver is treated as MEM, so ordinary in-memory definitions still work.
  • The comparison uses Driver(driver).name, the name of the driver GDAL actually resolves, rather than the string the user typed.
  • Code that really needs a file-backed raster has to wrap the definition in GDALRaster() itself. That is the signal Django now reads as “this input is trusted”.

Django’s advisory is explicit that this closes the file write only. If untrusted input still reaches a RasterField, server-side request forgery through GDAL’s virtual file systems is still possible, and Django points to its raster security notes for validation.

This is the third GeoDjango raster fix since August. Snyk lists CVE-2026-15307 (4 August, file write and SSRF through raster values in spatial lookups) and CVE-2026-87890 (6 October, SSRF through byte values in lookups). Both of those guarded the lookup path. Neither guarded the model field, so 5.2.17 and 6.0.8, the releases that fixed the August bug, are still exposed to Django4Shell.

CVE-2026-132092: placeholders and parameters out of step

Django builds lookup SQL as a string with %s placeholders and a separate list of parameters, then hands both to the database driver. That only stays safe while every placeholder in the string lines up with exactly one parameter in the list.

Two code paths could break that. The range lookup formatted only the first two right-hand-side placeholders and ignored the rest:

 class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
     lookup_name = "range"

     def get_rhs_op(self, connection, rhs):
-        return "BETWEEN %s AND %s" % (rhs[0], rhs[1])
+        start, end = rhs
+        return "BETWEEN %s AND %s" % (start, end)

Pass __range=["a", "b", "c"] and the old code produced two placeholders but kept three parameters. The unpacking in the new code raises ValueError instead.

The in lookup’s batch path had the same problem in a different spot. A bilateral transform (one that Django applies to both sides of a comparison, such as a custom Lower) can compile a None value to a bare IS NULL with no parameter. The regression test describes the consequence: “Unbalanced placeholders and parameters could lead to SQL injection vulnerabilities.” The fix makes the pairing strict:

         sql, params = zip(
             *(
                 self.resolve_expression_parameter(compiler, connection, sql, param)
-                for sql, param in zip(*pre_processed)
+                for sql, param in zip(*pre_processed, strict=True)
             )
         )

A spare parameter on its own just makes the query fail. It becomes injectable when something else in the SQL string contains a %s the developer didn’t intend as a placeholder, and that is what a percent sign in a column alias or JSON key transform gives you. The regression tests in 1eb6104 use an annotation called x%sy together with a three-value __range, and a values("data__missing") JSON key lookup next to a bilateral __in. In the second test the key path is held in a variable named user_query_field, which is the realistic setup: an API that lets clients choose which JSON keys or aliases to select or filter on. Backports are e0e7876 (6.1), da230e1 (6.0) and 5a8963c (5.2).

Django deprecated percent signs in column aliases and key transforms in 6.0 and plans to remove them entirely in Django 2028. Until then the release narrows the two lookups. __range now takes exactly two values, and code that passed more, which never made sense, will now fail loudly.

The other five

  • CVE-2026-115868 (XSS): truncatechars_html and Truncator.chars(html=True) could produce unsafe output when the text length exactly matched the truncation length and the result was rendered inside an HTML attribute.
  • CVE-2026-125673 (cache poisoning): HttpRequest.build_absolute_uri() normalised . and .. path segments, so cache_page() and UpdateCacheMiddleware could key a response under the wrong URL. Under some URL configurations an unauthenticated user could get a response cached for a URL it doesn’t belong to. The fix preserves dot segments; existing cache entries stay until you clear them.
  • CVE-2026-119642 and CVE-2026-127929 (admin data leaks): staff with view permission could enumerate field values on related models by adding lookups to the changelist querystring, either through the pk alias on a model whose primary key is a OneToOneField (multi-table inheritance does this by default) or through reverse relations. Both are new variants of CVE-2010-4534. The second one regressed in Django 5.0.3.
  • CVE-2026-132809 (heap overflow): OGRGeometry.wkb, hex, geos and pickling allocated too small a buffer for geometries over 4 GB on 64-bit platforms.

IOCs

These are vulnerabilities, not malware, so there are no network indicators. Signs that someone tried Django4Shell, taken from Django’s advisory and Snyk’s guidance:

WhereWhat to look for
HTTP request bodies to the admin or any form or API that accepts raster dataJSON raster definitions with a driver other than MEM (for example EHdr), ../ in name, or /vsi GDAL virtual-filesystem prefixes
Python path directories and site-packagessitecustomize.py or .pth files that no installed distribution owns
Static, media and source directoriesFiles created or modified at times that don’t match a deploy
Application logs after upgradingGDALException: Only in-memory (MEM) data definitions can be assigned to RasterField

For CVE-2026-132092, look for __range filters with more than two values, and for aliases or JSON key paths containing %, in requests to any endpoint that lets clients choose fields or keys.

Detection and remediation

Find the Django version everywhere it runs, including images:

pip show django 2>/dev/null | grep -E '^(Name|Version|Location)'
python -c 'import django; print(django.get_version())'

grep -rniE '^django([=<>~! ]|$)|"django"' \
  --include='requirements*.txt' --include='pyproject.toml' --include='poetry.lock' \
  --include='uv.lock' --include='Pipfile.lock' --include='pdm.lock' .

docker run --rm --entrypoint python <image> -c 'import django; print(django.get_version())'

Anything below 6.1.4, 6.0.11 or 5.2.20 in its series needs the upgrade. 5.1 and older are out of support, so move them to 5.2.20 or later.

Check whether Django4Shell is reachable in your code:

# Models with a RasterField
grep -rn --include='*.py' 'RasterField' .

# Whether those models are in the admin, a ModelForm or a serializer
grep -rnE --include='*.py' 'admin\.register|admin\.site\.register|ModelForm|ModelSerializer|GeoFeatureModelSerializer' .

After the upgrade, a RasterField is non-editable unless the field sets editable=True. Search for that too, because any field that does will be back in forms. It is still guarded by the MEM-only assignment check.

Look for planted startup files on hosts that ran a vulnerable GeoDjango app with a reachable RasterField:

for py in $(which -a python3 python 2>/dev/null | sort -u); do
  "$py" -c 'import site,sys; print("\n".join(p for p in sys.path if p))'
done | sort -u | while read -r d; do
  ls -la "$d"/sitecustomize.py "$d"/usercustomize.py "$d"/*.pth 2>/dev/null
done

# Recently changed files under the project and static roots (adjust paths)
find /srv/app /srv/app/static /srv/app/media -newer /srv/app/manage.py -type f 2>/dev/null | head -50

A .pth file is normal when a package installs one (setuptools, coverage and editable installs all do). Compare each file against pip show -f for the distribution that should own it. Anything unowned, or a sitecustomize.py you didn’t write, means the host is compromised.

Then:

  1. Upgrade Django, rebuild images and redeploy. A changed requirements.txt doesn’t change running containers.
  2. Clear the cache backends used by cache_page() or UpdateCacheMiddleware, for example with python manage.py shell -c "from django.conf import settings; from django.core.cache import caches; [caches[a].clear() for a in settings.CACHES]".
  3. If you can’t upgrade right away, restrict the admin and any form exposing a RasterField to trusted users, and set editable=False on the field yourself.
  4. If you find a planted file, treat the host as compromised. Rebuild it from a known-good image and rotate what the Django process could read: SECRET_KEY, database credentials, cloud and API keys in the environment, and any service account tokens on the host.

Timeline

  • 4 August 2026: Django fixes CVE-2026-15307, a GeoDjango raster file write and SSRF through spatial lookups (per Snyk).
  • 6 October 2026: Django fixes CVE-2026-87890, SSRF through raster byte values in spatial lookups (per Snyk).
  • 28 October 2026: Author date on the CVE-2026-124827 fix commit, a3934ab. It stayed private until the release.
  • 2 December 2026, 12:54 to 12:55 UTC: Django 6.1.4, 6.0.11 and 5.2.20 are uploaded to PyPI.
  • 2 December 2026, 13:20 to 13:21 UTC: The Django Software Foundation publishes the seven CVE records.
  • 2 December 2026, 13:26 UTC: Django’s announcement is posted to oss-security.
  • 2 December 2026: Snyk publishes its Django4Shell analysis. GitHub imports the seven CVEs as unreviewed advisories.
  • 3 December 2026: No exploitation reported, no EPSS scores yet, and none of the CVEs is in CISA KEV.

From research to remediation

Check whether this pattern exists in your codebase

Turn this research into a remediation workflow. Scan dependencies and package manifests for similar supply-chain risk, then prioritize fixes with reachability context.

References