Django just fixed 7 security bugs. Here is how to tell which ones actually hit your app
On December 2, 2026, the Django team shipped Django 6.1.4, 6.0.11 and 5.2.20. Together they fix seven security issues. Two are rated high under Django's security policy: one can let an attacker write files on your server
On December 2, 2026, the Django team shipped Django 6.1.4, 6.0.11 and 5.2.20. Together they fix seven security issues. Two are rated high under Django's security policy: one can let an attacker write files on your server, which Django says "could enable remote code execution" depending on the setup, and the other is a SQL injection in two common query lookups.
The good news is that most Django apps are not exposed to the scary ones by default. The bad news is that you cannot know that without checking, and a lot of teams are running a Django version that did not get a fix at all.
This post walks through what each bug needs in order to matter, how to check your code for it in a few minutes, and how to upgrade cleanly.
The short version
- Upgrade to 6.1.4, 6.0.11 or 5.2.20, depending on the series you are on. Django's own advice is to upgrade "as soon as possible".
- If you are on Django 4.2, 5.0 or 5.1, you are on an unsupported series. Django 4.2 LTS reached the end of extended support on April 7, 2026, and 5.1 on December 3, 2025. The advisory lists only main, 6.1, 6.0 and 5.2 as the affected supported versions, and unsupported series get no patches.
-
After upgrading, clear your cache if you use Django's cache middleware or
cache_page(). One of the fixes does not clean up responses that were already cached.
The seven issues, in plain words
The two high severity ones
CVE-2026-124827: server side file write via RasterField. This only matters if you use GeoDjango with rasters. RasterField is only implemented on PostGIS. If a user can control the raster definition assigned to a RasterField, including its name and a non default driver, GDAL could write a file to a location the attacker picks. From the advisory:
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 ModelForms or writable model serializers.
After the fix, RasterField defaults to editable=False and refuses a dict or JSON string that names a non default driver. Django also notes that server side request forgery is still possible if you assign untrusted input to a RasterField, so validation is still your job. Geometry fields were not affected.
CVE-2026-132092: SQL injection in range and in lookups. This one needs an unusual pattern: queries involving aliases or key transforms that contain a percent sign. The __range variant also required "incorrectly using more than two right-hand side values", and the __in variant required a bilateral transform. After the fix, range requires exactly two values. Most apps never put a % in an alias, but apps that build JSON key lookups from user input should check.
The moderate one
CVE-2026-115868: XSS in truncatechars_html. The template filter, and Truncator.chars() with html=True, could produce an XSS when certain inputs, whose text length matched the truncation length, were rendered inside an HTML attribute. If you use truncatechars_html inside something like title="..." or alt="...", this applies to you.
The four low ones
-
CVE-2026-125673: cache poisoning via dot segments.
build_absolute_uri()normalized.and..in request paths incorrectly. WithUpdateCacheMiddlewareorcache_page(), and under certain deployment and URL setups, an unauthenticated attacker could get cached responses served for the wrong URLs. -
CVE-2026-119642 and CVE-2026-127929: admin changelist information leaks. Staff users with only view permission could enumerate data through crafted querystrings, either through the
pkalias on a model with a customOneToOneFieldprimary key (multi table inheritance is affected by default) or through reverse relations. The second one is a regression from Django 5.0.3. -
CVE-2026-132809: heap buffer overflow in
OGRGeometry.wkbfor geometries larger than 4 GB on 64 bit platforms. Another GeoDjango only issue.
Step 1: find out which Django you are running
On every environment, not just your laptop:
python -m django --version
Or from a requirements or lock file:
grep -riE "^django([=<>~ ]|$)" requirements*.txt poetry.lock uv.lock Pipfile.lock 2>/dev/null
For a container image:
docker run --rm --entrypoint python your-image:tag -m django --version
Compare against the fixed versions:
| Series | Fixed in | Status |
|---|---|---|
| 6.1 | 6.1.4 | supported |
| 6.0 | 6.0.11 | supported (extended support until April 2027) |
| 5.2 LTS | 5.2.20 | supported (extended support until April 2028) |
| 5.1 and older, including 4.2 LTS | no fix | unsupported, plan the upgrade |
Step 2: check whether the high severity bugs touch your code
These greps run from your project root. They are not proof either way, but they tell you quickly where to look.
Do you use RasterField at all?
grep -rn "RasterField" --include="*.py" .
No results means CVE-2026-124827 and the OGRGeometry overflow are very unlikely to matter for you. If you do get results, check whether that model is in the admin, in a ModelForm or in a writable serializer. Those are the paths the advisory calls out.
Do you put percent signs in aliases or build lookups from user input?
grep -rnE "(annotate|alias)\(.*%" --include="*.py" .
grep -rnE "filter\(\*\*|exclude\(\*\*" --include="*.py" .
The second grep finds places where lookup names are built dynamically, for example filter(**{f"data__{key}": value}) on a JSONField. If key comes from a request, that is the pattern to review.
Do you render truncatechars_html inside attributes?
grep -rn "truncatechars_html" --include="*.html" .
Anything inside a quoted attribute value deserves a look until you have upgraded.
Step 3: upgrade
Pin to the fixed patch release of your series. For example, on the 5.2 LTS line:
python -m pip install --upgrade "Django>=5.2.20,<5.3"
python -m django --version
On 6.1:
python -m pip install --upgrade "Django>=6.1.4,<6.2"
Then update your lock file the way your tool expects (pip freeze, poetry lock, uv lock) and rebuild images. A fixed version in requirements.txt protects nothing until the running containers are replaced.
Two behaviour changes to watch in your test suite:
-
RasterFieldis noweditable=Falseby default. If you intentionally edit rasters through a form, include the field explicitly and wrap trusted definitions inGDALRaster, as the advisory describes. -
__rangenow needs exactly two values. Code that passed a longer list was already wrong, but it will now fail loudly.
Step 4: clear the cache
If you use UpdateCacheMiddleware or cache_page(), the advisory says "existing cached responses are not invalidated". Clear them after the upgrade:
python manage.py shell -c "from django.core.cache import cache; cache.clear()"
If your cache is shared with things you do not want to lose, clear only the keys or the cache alias used for page caching instead.
If you are still on Django 4.2
This is the uncomfortable part. Django 4.2 was a long term support release, so many production apps stayed on it, and its extended support ended on April 7, 2026. The December releases do not include a 4.2 patch, and Django does not assess or fix unsupported series.
The realistic path is 4.2 to 5.2 LTS, which is supported until April 2028. Django's release notes for 5.0, 5.1 and 5.2 list the deprecations to clear along the way. Running your test suite with warnings turned on (python -Wd manage.py test) on 4.2 first shows most of what will break.
What this one teaches
Know your support window. Most of these bugs need a specific setup, but the 4.2 situation catches far more teams than any single CVE. A one line check of each app's Django series against the supported versions table, done once a quarter, prevents a stressful upgrade in the middle of an incident.
Form fallbacks are attack surface. The RasterField bug became reachable because the field quietly fell back to a text input in the admin and in ModelForms. Any field you expose through a form or serializer should be one you meant to expose.
Dynamic lookups deserve a whitelist. Building filter(**{...}) keys from request data is convenient and easy to get wrong. Map user choices to a fixed set of allowed lookups instead of passing them through.
Sources
- Django weblog, "Django security releases issued: 6.1.4, 6.0.11, and 5.2.20" (December 2, 2026): https://www.djangoproject.com/weblog/2026/dec/02/security-releases/
- Django download page, supported and unsupported versions: https://www.djangoproject.com/download/
- Django security policy: https://docs.djangoproject.com/en/dev/internals/security/
Keep reading
- Node.js just fixed 16 security bugs. Here is how to find every Node you need to upgrade
- Microsoft's agent-framework on PyPI shipped a credential stealer. Did any of your environments run it?
Let's stay in touch
I'm Amit Shukla, a software engineer working across DevOps, cloud and applied AI. Behind the Stack is where I write up the things I learn the hard way, with working code and honest tradeoffs.
- Instagram: a short, practical build every day at @amitshuklabag. Comment the keyword on any Reel and I'll send you the full guide.
- LinkedIn: connect with me for longer discussions.
- X: @amitshuklabag
If this saved you some time, a reaction or a comment helps more people find it.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.