If your Django site uses cache_page or the cache middleware, upgrading is only half the job: you also need to clear the cache. The release notes for the Django security update of December 2, 2026 say so explicitly, and our reproduction shows why. On Django 6.1.3, one crafted request was enough to make every later visitor to /news/ see the content of a different page. The Django project pushed 6.1.4, 6.0.11 and 5.2.20 to PyPI at 12:54 UTC. The security releases fix seven vulnerabilities, and the team rates two of them as high severity. There is no denial-of-service bug in this batch.
Seven security issues in one Django security update
According to the announcement on the Django weblog, every supported series is affected: 6.1, 6.0, 5.2 and the main branch. The two high-severity CVEs hit very different kinds of projects. One lives in GeoDjango, the geospatial add-on, and only matters for apps that use RasterField on PostGIS. The other is an SQL injection in the ORM, the layer that turns Python calls such as filter() into SQL. On top of that come a cross-site scripting (XSS) vulnerability and four low-severity security issues.
| CVE | Area | Severity |
|---|---|---|
| CVE-2026-124827 | File write via RasterField, possible code execution depending on the driver |
high |
| CVE-2026-132092 | SQL injection in the range and in lookups |
high |
| CVE-2026-115868 | XSS in the truncatechars_html filter |
moderate |
| CVE-2026-125673 | Cache poisoning via dot segments in request paths | low |
| CVE-2026-119642 | Admin changelist leak via the pk alias |
low |
| CVE-2026-127929 | Admin changelist leak via reverse relations | low |
| CVE-2026-132809 | Heap buffer overflow in OGRGeometry.wkb above 4 GB |
low |
We installed Django 6.1.3 and 6.1.4 side by side in two virtual environments on Python 3.13.5, diffed the wheels from PyPI and rebuilt three of the bugs with small scripts. The patches touch just 17 Python files, which makes the release easy to review.
Cache poisoning: one request poisons the page for everyone
Django’s cache middleware derives the key for a stored response from request.build_absolute_uri(). Up to 6.1.3, that method normalized paths containing . or .., so /pages/../news/ became http://testserver/news/. The URL resolver, however, matches the raw path and routes the request to the pages/<path:slug> pattern. Whatever that view returns gets stored under the key for /news/.
# poc.py (excerpt): cache middleware enabled, LocMemCache
def news(request):
return HttpResponse("Latest news")
def page(request, slug):
return HttpResponse(f"Page {slug!r}")
urlpatterns = [
path("news/", news),
path("pages/<path:slug>", page),
]
c = Client()
print(c.get("/pages/../news/").content.decode())
print(c.get("/news/").content.decode())
6.1.3:
build_absolute_uri: http://testserver/news/
1. /pages/../news/ -> Page '../news/'
2. /news/ -> Page '../news/'
6.1.4:
build_absolute_uri: http://testserver/pages/../news/
1. /pages/../news/ -> Page '../news/'
2. /news/ -> Latest news
On 6.1.3, the second request is perfectly ordinary and still gets the attacker’s response from the cache. On 6.1.4, build_absolute_uri() keeps the dot segments, so the two requests end up under different keys. The fix is a small change in django/http/request.py.
The team still rates this one as low, and that seems fair. An attacker needs a URL pattern that swallows .. as part of a parameter, for example a path converter for slugs or file names. The reverse proxy in front also has to forward the path untouched. Browsers and curl normalize such paths on their own; curl only sends them with --path-as-is, which is also the easiest way to check whether your own stack lets them through. The operational catch: entries that were poisoned before the upgrade stay in the cache until they expire.
XSS in truncatechars_html, but only at exactly the right length
The truncatechars_html filter shortens HTML without cutting tags in half. It had a special code path for one edge case: when the text length matched the truncation length and the whole input had been consumed, the parser appended the text without escaping it. Quotes came through raw. In our test, a 29-character teaser goes into an alt attribute:
<img src="/x.png" alt="{{ teaser|safe|truncatechars_html:29 }}">
teaser = 'New: " onerror="alert(1)" x="' # exactly 29 characters
6.1.3: <img src="/x.png" alt="New: " onerror="alert(1)" x="">
6.1.4: <img src="/x.png" alt="New: " onerror="alert(1)" x="">
On 6.1.3, the text breaks out of the attribute and attaches an onerror handler, which any browser runs as JavaScript as soon as the image fails to load. One character more or less and the effect is gone. Without |safe, nothing happened in our test, because autoescaping masks the output a second time. The templates at risk are the ones that truncate HTML already marked safe, typically rich text from an editor, and place the result in an attribute such as title, alt or a meta tag’s content.
Content Security Policy headers as a second line of defense
Patch or no patch, this is a good moment to look at Content Security Policy (CSP), an HTTP header that tells the browser which script sources to trust. Since 6.0, the framework ships ContentSecurityPolicyMiddleware and the SECURE_CSP setting. A policy that allows scripts only with a nonce and drops 'unsafe-inline' blocks inline handlers like onerror even when an escaping bug slips through. Your own inline scripts then need nonce="{{ csp_nonce }}", which requires the django.template.context_processors.csp context processor.
# settings.py (Django 6.0 and later)
from django.utils.csp import CSP
MIDDLEWARE += ["django.middleware.csp.ContentSecurityPolicyMiddleware"]
SECURE_CSP = {
"default-src": [CSP.SELF],
"script-src": [CSP.SELF, CSP.NONCE],
}
SQL injection in the ORM: what changed in range and in
The second high-severity bug sounds worse than it is for most projects. According to the Django 6.1.4 release notes, it required aliases or key transforms containing percent signs, such as annotations with custom names or JSON keys that end up in a filter as data__somekey. The __range variant also needed someone to pass more than two values, and the __in variant needed a bilateral transform. If you build lookup names from user input, as in filter(**{f"data__{key}": value}), check that code anyway and use an allowlist of keys.
User.objects.filter(id__range=(1, 5, 9))
6.1.3: TypeError: not all arguments converted during string formatting
6.1.4: ValueError: too many values to unpack (expected 2)
The diff is tiny. BETWEEN now unpacks the right-hand side with start, end = rhs, and parameters are paired with zip(..., strict=True). Our test shows the effect: three values on 6.1.3 produced a string formatting error deep inside the SQL compiler, exactly where placeholders and parameters drift apart. On 6.1.4, the query fails immediately and clearly. Percent signs in column aliases and key transforms have been deprecated since Django 6.0 and go away in Django 2028.
GeoDjango and the admin: the remaining CVEs
The RasterField bug affects few apps, but it hits them hard. Assigning a raster definition with a user-controlled name and any driver other than the in-memory MEM driver makes GDAL write a file wherever the attacker wants. Depending on the driver, that can lead to code execution. Because the field falls back to a CharField form field, the flaw was reachable by default through the Django admin, ModelForms and writable serializers. Our test box had no GDAL, so we checked this part against the patch only:
# contrib/gis/db/models/fields.py, RasterField in 6.1.4
def __init__(self, *args, **kwargs):
kwargs.setdefault("editable", False)
super().__init__(*args, **kwargs)
The field no longer shows up in forms automatically, and assigning a dict or JSON string with a non-MEM driver now raises GDALException. Trusted definitions can still be wrapped in GDALRaster(). No new migration is generated, because deconstruct() hides the new default. The release notes warn that server-side request forgery remains possible if untrusted input reaches the field.
Both admin bugs require a logged-in staff user with view permission, who could guess values on related models one lookup at a time by tweaking the changelist querystring. Models using multi-table inheritance were exposed by default, because Django creates a OneToOneField primary key for them. The reverse-relation variant is a regression from Django 5.0.3, and the weblog credits OpenAI with reporting it. The heap buffer overflow in OGRGeometry.wkb only triggers on geometries larger than 4 GB.
How to apply the Django security update
Should you upgrade? The project’s download page answers that itself: patch releases stay compatible within a series, so the answer is always yes. On 6.1, install 6.1.4; on 6.0, install 6.0.11; on the 5.2 LTS, install 5.2.20.
# Which version is running?
python -m django --version
# pip: move to the patched release of your series
pip install --upgrade "Django~=6.1.4" # or ~=6.0.11 / ~=5.2.20
# uv: bump only this package in the lockfile
uv lock --upgrade-package django && uv sync
# check settings, then clear the cache
python manage.py check --deploy
python manage.py shell -c "from django.core.cache import caches; caches['default'].clear()"
# find affected spots in your project
grep -rn "truncatechars_html" --include="*.html" .
grep -rn "RasterField\|__range" --include="*.py" .
Running check --deploy also flags missing settings such as HSTS headers or insecure cookies. After deploying, keep an eye on your logs: an app that relied on passing three values to __range will now raise the ValueError shown above instead of failing somewhere in the SQL layer. 6.1.4 also carries seven regular bug fixes, including one where a non-nullable ForeignKey could return None under the FETCH_PEERS fetch mode. If you manage dependencies with uv, our guide to securing Python dependencies with uv, hashes and audits covers the matching CI step. For a full inventory of what runs inside a container, an SBOM built with Syft and Grype does the job.
Django 4.2 is out of support: which series still get patches
Extended support for the 4.2 LTS ended on April 7, 2026, so it gets none of this week’s patches. If you are stuck there, plan the jump to Django 5.2, which receives security updates until April 2028. The 6.0 series is covered until April 2027. The django-upgrade tool rewrites deprecated calls automatically when you move between feature releases, and if you install Django from distribution packages, watch the python-django source package in Debian or Ubuntu.
Our take
Install this today, but in a sensible order. GeoDjango projects that expose RasterField in the admin or an API come first, because the bug is directly reachable there. Next are sites with the cache middleware or cache_page: upgrade, clear the cache, done. Everyone else can use their normal patch window, since the effort is small anyway. The pattern behind the bugs is the interesting part. As with the middleware bypass flaws in Fastify plugins and Livewire, the trouble does not come from core request handling but from places where two layers read the same path or value differently. Those seams deserve a second look in your own code.




