Skip to content

cat posts/en/django-6-1-4-sicherheitsrelease.md

Django 6.1.4: the security release, taken apart

Django 6.1.4 closes seven CVEs. What's behind each one, how to check whether you're affected, and what else the upgrade changes — every bug checked against its fix commit.

Flat illustration: A small robot raises a wrench in front of a terminal showing pip install -U django==6.1.4. A code line highlighted in red is patched with a bandage; below it, seven shields with check marks.

Django 6.1.4 shipped on December 2, 2026, alongside 6.0.11 and 5.2.20. It's a security release: seven CVEs, plus a handful of bugfixes you might notice on the way up. Every supported branch is affected: main, 6.1, 6.0, and 5.2. If you're on 6.0 or 5.2, everything here applies just the same; you'll land on 6.0.11 or 5.2.20 respectively.

The release notes list the issues, and the advisory adds the reporters and the patches. What neither one does: tell you whether you are on the hook. That's what this article is for — issue by issue, each with a short self-check you can run in python manage.py shell against your own installation. The checks are defensive: they show you which side of the fix you're on, they don't attack anything.

The short version: how urgent?

Two issues are rated high, one moderate, four low. The rating says little about your urgency. That depends on what you run:

  • Do you use GeoDjango with PostGIS and RasterField in forms, the admin, or a writable API? → CVE-2026-124827, high, upgrade now.
  • Do you build querysets with __range/__in from user input and use percent signs in alias or key-transform names? → CVE-2026-132092, high.
  • Do you render truncatechars_html into an HTML attribute? → CVE-2026-115868, moderate.
  • Do you cache whole pages via middleware or cache_page? → CVE-2026-125673, clear the cache after upgrading.
  • Do you run a Django admin with staff users you don't blindly trust? → CVE-2026-119642 and -127929.

None of these issues fires on a stock installation by itself; each needs a specific feature or setup. Still: a security release isn't something you put off.

CVE-2026-124827 – RasterField writes files (high)

GeoDjango's RasterField accepted a dict or a JSON string as a raster definition on assignment. Its name parameter tells GDAL where to write a new raster — and with a non-default driver, the file lands at an attacker-chosen location. Depending on the driver, that reaches as far as remote code execution. It was reachable by default, because RasterField falls back to the CharField form field: every ModelForm, every writable serializer, and the admin offered a way in.

The fix bolts two doors shut: RasterField is now editable=False and so drops out of ModelForms unless you include it explicitly. And an assignment with a driver other than the in-memory default MEM raises a GDALException. If you need another driver, you wrap the definition in GDALRaster() explicitly. That signals "this value is trusted." Important: this only stops the file write. SSRF is still possible if you assign untrusted input to a RasterField, so keep validating it yourself.

Am I affected? PostGIS only. Plain GeometryField/PointField are not; RasterField exists only on PostGIS. Grep your project:

grep -rn "RasterField" --include=*.py

If nothing turns up, you're clear. I did not reproduce this one locally: it needs a PostGIS/GDAL setup, and the analysis comes from the fix commit and its tests.

CVE-2026-132092 – SQL injection in range/in (high)

The __range and __in lookups were open to SQL injection when aliases or key transforms contained a percent sign. The __range path required (incorrectly) passing more than two values; the __in path required a bilateral transform. The core of it: a bilateral transform can compile None down to a parameter-less IS NULL, so the number of placeholders and the number of parameters drift apart — and that gap between "this many %s" and "this many values" is the way in.

The fix is pleasantly blunt: range now demands exactly two values, and the zip of SQL and parameters runs with strict=True, so unbalanced placeholders blow up immediately instead of slipping through to the database.

Am I affected? The self-check shows the behavior without any injection at all:

# any model, three values instead of two for __range:
MyModel.objects.filter(headline__range=["a", "b", "c"])

On 6.1.3 Django drags the third value all the way down to the DB layer, where it surfaces as a surplus binding (on SQLite: Incorrect number of bindings supplied). On 6.1.4 you get a clear ValueError: too many values to unpack (expected 2, got 3) up front. That the extra value ever got that far is the whole point. Percent signs in alias and key-transform names, incidentally, have been deprecated since Django 6.0 (flagged with RemovedInDjango2028Warning), one more reason to keep them out of your querysets.

CVE-2026-115868 – XSS in truncatechars_html (moderate)

The truncatechars_html filter (and Truncator.chars(html=True)) failed to escape the last chunk of text when its length landed exactly on the truncation length. While expanding HTML entities, that one edge case slipped past. Rendered into an HTML attribute, it becomes an XSS.

The fix is a one-liner: the final appended chunk now goes through escape() too.

Am I affected? Checkable directly:

from django.utils.text import Truncator
print(Truncator('"ab"').chars(4, html=True))
# 6.1.3:  "ab"            <- raw, not escaped
# 6.1.4:  &quot;ab&quot;  <- escaped

If you only use the filter in the visible text body and not in attributes, the risk is low, but the fix costs you nothing.

CVE-2026-125673 – cache poisoning via path dot segments (low)

UpdateCacheMiddleware and cache_page() suffered from a bug in build_absolute_uri(): the method normalized paths containing . and .. segments before the cache key was derived from them. Under certain deployment and URL configurations, an unauthenticated attacker could get cached responses served for the wrong URL.

The fix leaves the request path's dot segments untouched when build_absolute_uri() is called without an explicit location. Watch out when upgrading: already-cached responses are not invalidated, so clear any potentially affected caches after the update.

Am I affected? The self-check:

from django.http import HttpRequest
from django.test.utils import override_settings

r = HttpRequest()
r.META["SERVER_NAME"] = "example.com"; r.META["SERVER_PORT"] = "80"
r.path = "/preview/../payroll/"
with override_settings(ALLOWED_HOSTS=["example.com"]):
    print(r.build_absolute_uri())
# 6.1.3:  http://example.com/payroll/              <- path changed!
# 6.1.4:  http://example.com/preview/../payroll/   <- preserved

The override_settings is only there so example.com passes as a host. That 6.1.3 turns /preview/../payroll/ into /payroll/ is the path confusion the cache key collision rides on. If you don't cache whole pages, you're not affected.

CVE-2026-119642 & -127929 – admin changelist leaks data (low)

Two variants of the same theme, both a special case of the ancient CVE-2010-4534: a staff user with mere view permission could enumerate values of related models through manipulated querystrings in the admin changelist, by repeated lookup searches, bit by bit.

  • -119642 went through the pk alias onto a OneToOneField primary key. Models using multi-table inheritance were affected by default, since Django's implicit PK there is a OneToOneField.
  • -127929 went through reverse relations and is a regression since Django 5.0.3. Before that, lookup_allowed() rejected such names.

Both fixes sit in ModelAdmin.lookup_allowed(): -119642 resolves the pk alias to the real PK name, -127929 remembers whether the lookup ran through a reverse relation and then rejects it.

Am I affected? Do you run an admin with staff accounts you don't fully trust? Then yes. Both are purely server-side checks, so there's no workaround but the upgrade. The behavior difference is visible directly on lookup_allowed(): for a reverse-relation or pk-alias lookup, 6.1.3 returns True, 6.1.4 returns False.

CVE-2026-132809 – heap overflow for WKB > 4 GB (low)

OGRGeometry.wkb allocated an undersized buffer for geometries beyond 4 GB on 64-bit platforms: a c_size_t from GDAL was truncated to a c_int. Result: a segfault or undefined behavior. The hex and geos properties and pickling hung on the same bug. The fix corrects the return type of the get_wkbsize() prototype to c_size_t. Affects only those processing genuinely huge geometries with GeoDjango, a small group in practice. This one, too, comes from the commit rather than a local run: you don't whip up a 4 GB geometry on a whim.

What else the upgrade changes

Besides the CVEs, 6.1.4 fixes a few regressions, two of which matter when you upgrade:

  • ~F() on a nullable BooleanField (#37520): negating a NULL value returned False instead of None on SQLite. MySQL and Oracle 23+ had the same longstanding flaw and are now fixed too. If you rely on the three-valued logic of nullable booleans, check your queries.
  • union()/intersection()/difference() with Meta.ordering referencing related fields (#37505): could crash — not anymore.

Plus the small stuff: models.E050 now detects mixed on_delete variants on a GenericRelation, a FETCH_PEERS case now raises DoesNotExist correctly, deeply nested GeoJSON is reported cleanly as a ValidationError, Oracle executemany() no longer crashes when only some string parameters exceed 4,000 characters, and pylibmc 1.8.0 is supported.

Conclusion

Of seven CVEs, two or three really matter for most setups — which ones depends on whether you run PostGIS rasters, full-page caching, or an open admin. The self-checks above tell you in seconds which side of the fix you're on. After that it's the usual drill: pip install -U "django>=6.1.4,<6.2" (or the matching patch for your branch), run your tests, and with full-page caching, clear the cache. If you want to reproduce the fixes against your own codebase first, the quickest way is two uv venvs: one old version and one new, side by side.

0 comments

No comments yet. Be the first!