oss-sec mailing list archives

Django: CVE-2023-43665: Denial-of-service possibility in django.utils.text.Truncator


From: Natalia Bidart <nataliabidart () gmail com>
Date: Wed, 4 Oct 2023 13:02:50 -0300

https://www.djangoproject.com/weblog/2023/oct/04/security-releases/

In accordance with `our security release policy
<https://docs.djangoproject.com/en/dev/internals/security/>`_, the Django
team
is issuing
`Django 4.2.6 <https://docs.djangoproject.com/en/dev/releases/4.2.6/>`_,
`Django 4.1.12 <https://docs.djangoproject.com/en/dev/releases/4.1.12/>`_,
and
`Django 3.2.22 <https://docs.djangoproject.com/en/dev/releases/3.2.22/>`_.
These releases address the security issue detailed below. We encourage all
users of Django to upgrade as soon as possible.

CVE-2023-43665: Denial-of-service possibility in django.utils.text.Truncator
============================================================================

Following the fix for CVE-2019-14232, the regular expressions used in the
implementation of ``django.utils.text.Truncator``’s ``chars()`` and
``words()`` methods
(with ``html=True``) were revised and improved. However, these regular
expressions
still exhibited linear backtracking complexity, so when given a very long,
potentially malformed HTML input, the evaluation would still be slow,
leading
to a potential denial of service vulnerability.

The ``chars()`` and ``words()`` methods are used to implement the
``truncatechars_html``
and ``truncatewords_html`` template filters, which were thus also
vulnerable.

The input processed by ``Truncator``, when operating in HTML mode, has been
limited
to the first five million characters in order to avoid potential performance
and memory issues.

Thanks Wenchao Li of Alibaba Group for the report.

This issue has severity "moderate" according to the Django security policy.

Affected supported versions
===========================

* Django main branch
* Django 5.0 (currently at pre-release alpha status)
* Django 4.2
* Django 4.1
* Django 3.2

Resolution
==========

Patches to resolve the issue have been applied to Django's main branch and
the
5.0, 4.2, 4.1, and 3.2 release branches. The patches may be obtained from
the
following changesets:

* On the `main branch <
https://github.com/django/django/commit/17b51094d778b421bb2b3aae0c270894b050455d
`__
* On the `5.0 release branch <
https://github.com/django/django/commit/8124c42601b9abfeb234056092a62a22a22107cb
`__
* On the `4.2 release branch <
https://github.com/django/django/commit/be9c27c4d18c2e6a5be8af4e53c0797440794473
`__
* On the `4.1 release branch <
https://github.com/django/django/commit/c7b7024742250414e426ad49fb80db943e7ba4e8
`__
* On the `3.2 release branch <
https://github.com/django/django/commit/ccdade1a0262537868d7ca64374de3d957ca50c5
`__

The following releases have been issued:

* Django 4.2.6 (`download Django 4.2.6 <
https://www.djangoproject.com/m/releases/4.2/Django-4.2.6.tar.gz>`_ |
`4.2.6 checksums <
https://www.djangoproject.com/m/pgp/Django-4.2.6.checksum.txt>`_)
* Django 4.1.12 (`download Django 4.1.12 <
https://www.djangoproject.com/m/releases/4.1/Django-4.1.12.tar.gz>`_ |
`4.1.12 checksums <
https://www.djangoproject.com/m/pgp/Django-4.1.12.checksum.txt>`_)
* Django 3.2.22 (`download Django 3.2.22 <
https://www.djangoproject.com/m/releases/3.2/Django-3.2.22.tar.gz>`_ |
`3.2.22 checksums <
https://www.djangoproject.com/m/pgp/Django-3.2.22.checksum.txt>`_)

The PGP key ID used for this release is Natalia Bidart: `2EE82A8D9470983E <
https://github.com/nessita.gpg>`_

General notes regarding security reporting
==========================================

As always, we ask that potential security issues be reported via
private email to ``security () djangoproject com``, and not via Django's
Trac instance or the django-developers list. Please see `our security
policies <https://www.djangoproject.com/security/>`_ for further
information.

Current thread: