==========================
Django 6.1.4 release notes
==========================

*December 2, 2026*

Django 6.1.4 fixes two security issues with severity "high", one security issue
with severity "moderate", four security issues with severity "low", and several
bugs in 6.1.3. It also incorporates the latest string translations from
Transifex.

CVE-2026-124827: Server-side file-write via ``RasterField`` assignment
======================================================================

Assigning a raster :ref:`data definition <gdal-raster-ds-input>` to
:class:`~django.contrib.gis.db.models.RasterField` with a user-controlled
``name`` parameter and a non-default ``driver`` could cause GDAL to write a
file to an attacker-controlled location. Depending on the raster driver, this
could enable remote code execution. Because ``RasterField`` falls back to the
:class:`~django.forms.CharField` form field, the flaw was reachable by default
on models with ``RasterField`` registered in the admin or using
:class:`~django.forms.ModelForm`\s or writable model serializers.

``RasterField`` now defaults :attr:`~django.db.models.Field.editable` to
``False``, excluding it from a :class:`~django.forms.ModelForm` unless
explicitly included. ``RasterField`` also now raises ``GDALException`` when
assigning a ``dict`` or JSON string specifying a non-default driver. To use
other drivers, wrap the definition in
:class:`~django.contrib.gis.gdal.GDALRaster` to signify the value is trusted.
This exception only limits server-side file writes. Server-side request forgery
is still possible if untrusted input is assigned to ``RasterField``. See
:ref:`raster security considerations <raster-security>` and implement
validation before accepting untrusted input.

Geometry fields were not affected.
:class:`~django.contrib.gis.db.models.RasterField` is only implemented on
PostGIS.

This issue has severity "high" according to the :ref:`Django security policy
<severity-levels>`.

CVE-2026-132092: Potential SQL injection in ``range`` and ``in`` lookups
========================================================================

The :lookup:`range` and :lookup:`in` lookups were subject to SQL injection in
queries involving aliases or key transforms containing percent signs. The
``__range`` flaw required incorrectly using more than two right-hand side
values. The ``__in`` flaw required a :attr:`bilateral transform
<django.db.models.Transform.bilateral>`.

The :lookup:`range` lookup now requires exactly two right-hand side values.

Note that using percent signs in column aliases and key transforms was
deprecated in Django 6.0 and is scheduled for removal in Django 2028.

This issue has severity "high" according to the :ref:`Django security policy
<severity-levels>`.

CVE-2026-115868: Potential cross-site scripting vulnerability in ``truncatechars_html``
=======================================================================================

The :tfilter:`truncatechars_html` template filter and the
``django.utils.text.Truncator.chars()`` method (with ``html=True``) were
subject to a potential cross-site scripting (XSS) attack when certain inputs
whose text length matched the truncation length were processed and rendered in
an HTML attribute.

This issue has severity "moderate" according to the :ref:`Django security
policy <severity-levels>`.

CVE-2026-125673: Potential cache poisoning via dot segments in request paths
============================================================================

:class:`~django.middleware.cache.UpdateCacheMiddleware` and
:func:`~django.views.decorators.cache.cache_page` were affected by a bug in
:meth:`~django.http.HttpRequest.build_absolute_uri`, which incorrectly
normalized request paths containing ``.`` or ``..`` segments. Under certain
deployment and URL configurations, this could allow an unauthenticated attacker
to cause cached responses to be served for unintended URLs.

:meth:`~django.http.HttpRequest.build_absolute_uri` now preserves dot segments
in the request path when called without a location. Existing cached responses
are not invalidated, so users should clear any potentially affected caches
after upgrading.

This issue has severity "low" according to the :ref:`Django security policy
<severity-levels>`.

CVE-2026-119642: Information leakage in admin changelist via "pk" alias for ``OneToOneField``
=============================================================================================

The admin changelist allowed staff users with view permissions on a registered
model with a custom :class:`~django.db.models.OneToOneField` primary key to
enumerate data from those models by including the ``pk`` alias in the
querystring and performing repeated lookup searches. This requires sufficient
knowledge of the fields on the related model. It is a special case of
:cve:`2010-4534`.

Models using multi-table inheritance were affected by default, as the implicit
primary key field created by Django is a ``OneToOneField``.

This issue has severity "low" according to the :ref:`Django security policy
<severity-levels>`.

CVE-2026-127929: Information leakage in admin changelist via reverse relations
==============================================================================

The admin changelist allowed staff users with view permissions on a registered
model to enumerate values on those models via manipulating the querystring to
perform repeated lookup searches. This requires knowledge of the related model
names or :attr:`~django.db.models.ForeignKey.related_query_name` overrides. It
is a special case of :cve:`2010-4534` that regressed in Django 5.0.3.

This issue has severity "low" according to the :ref:`Django security policy
<severity-levels>`.

CVE-2026-132809: Heap buffer overflow in ``OGRGeometry.wkb``
============================================================

The :attr:`OGRGeometry.wkb <django.contrib.gis.gdal.OGRGeometry.wkb>` property
allocated an undersized buffer for geometries larger than 4GB on 64-bit
platforms. This could result in segmentation faults or undefined behavior. The
:attr:`~django.contrib.gis.gdal.OGRGeometry.hex` and
:attr:`~django.contrib.gis.gdal.OGRGeometry.geos` properties of
:class:`~django.contrib.gis.gdal.OGRGeometry` and its pickling were also
affected.

This issue has severity "low" according to the :ref:`Django security policy
<severity-levels>`.

Bugfixes
========

* Fixed a bug in Django 6.1 where the ``models.E050`` system check did not
  detect mixed ``on_delete`` variants for models with a
  :class:`~django.contrib.contenttypes.fields.GenericRelation`
  (:ticket:`37471`).

* Fixed a bug in Django 6.1 where accessing a non-nullable
  :class:`~django.db.models.ForeignKey` with the
  :attr:`~django.db.models.FETCH_PEERS` fetch mode could return ``None``
  instead of raising :exc:`~django.core.exceptions.ObjectDoesNotExist` when the
  related object had been deleted (:ticket:`37513`).

* Fixed a regression in Django 6.1.3 where a :exc:`RecursionError` from a
  GeoJSON value was not reraised as a
  :exc:`~django.core.exceptions.ValidationError` by the
  :class:`~django.contrib.gis.forms.GeometryField` form field
  (:ticket:`37491`).

* Fixed a regression in Django 6.1.3 where ``executemany()`` on Oracle crashed
  if some but not all string parameters were over 4,000 characters long
  (:ticket:`37506`).

* Fixed a regression in Django 6.1 where combining querysets with
  :meth:`.QuerySet.union`, :meth:`.QuerySet.intersection`, or
  :meth:`.QuerySet.difference` could crash when the model's
  :attr:`.Options.ordering` referenced related fields (:ticket:`37505`).

* Added compatibility with :pypi:`pylibmc` 1.8.0 (:ticket:`37529`).

* Fixed a regression in Django 6.1 on SQLite where negating a nullable
  :class:`~django.db.models.BooleanField` with ``~F()`` returned ``False``
  instead of ``None`` for ``NULL`` values (:ticket:`37520`). MySQL and Oracle
  23+ had the same longstanding flaw and are now fixed.
