# CVE-2024-27351: Regular expression denial-of-service in Django

> Attackers can cause denial of service in Django applications via crafted strings triggering regex backtracking in text truncation utilities.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 15 Mar 2024
- **Updated:** 4 Nov 2025
- **Also known as:** BIT-django-2024-27351, CLSA-2025-1754352700, DEBIAN-CVE-2024-27351, GHSA-vm8q-m57g-pff3, MGASA-2024-0075, OESA-2024-1254, PYSEC-2024-47, RHSA-2025:4187, SUSE-SU-2024:0902-1, SUSE-SU-2024:1140-1, SUSE-SU-2024:1141-1, UBUNTU-CVE-2024-27351, USN-6674-1, USN-6674-2, openSUSE-SU-2024:0077-1, openSUSE-SU-2024:0080-1, openSUSE-SU-2024:13749-1

## What is CVE-2024-27351?

CVE-2024-27351 is a medium-severity denial of service vulnerability in Djangoproject Django, published on 15 Mar 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

In Django 3.2 before 3.2.25, 4.2 before 4.2.11, and 5.0 before 5.0.3, the django.utils.text.Truncator.words() method (with html=True) and the truncatewords_html template filter are subject to a potential regular expression denial-of-service attack via a crafted string. NOTE: this issue exists because of an incomplete fix for CVE-2019-14232 and CVE-2023-43665.

Weakness: CWE-1333 (Inefficient Regular Expression Complexity)

## Which versions are affected by CVE-2024-27351?

8 open source packages ship an affected version, including django and Django. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `django` | Bitnami | From 3.2.0 | 3.2.25, 4.2.11, 5.0.3 |
| `django` | PyPI | From 3.2 | 3.2.25, 4.2.11, 5.0.3 |
| `django` | PyPI | From 3.2 | 3.2.25 |
| `django` | PyPI | From 4.2 | 4.2.11 |
| `django` | PyPI | From 5.0 | 5.0.3 |
| `Django` | PyPI | From 3.2 | 3.2.25 |
| `Django` | PyPI | From 4.2 | 4.2.11 |
| `Django` | PyPI | From 5.0 | 5.0.3 |
| `python-django` | Red Hat:openstack:17.1::el9 | All versions | 0:2.2.24-9.el9ost |
| `python3-django` | Red Hat:openstack:17.1::el9 | All versions | 0:2.2.24-9.el9ost |
| `python-Django` | SUSE:HPE Helion OpenStack 8 | All versions | 1.11.29-3.62.1 |
| `venv-openstack-horizon-hpe` | SUSE:HPE Helion OpenStack 8 | All versions | 12.0.5~dev6-14.56.1 |
| `python-Django` | SUSE:OpenStack Cloud 8 | All versions | 1.11.29-3.62.1 |
| `venv-openstack-horizon` | SUSE:OpenStack Cloud 8 | All versions | 12.0.5~dev6-14.56.1 |
| `python-Django1` | SUSE:OpenStack Cloud 9 | All versions | 1.11.29-3.61.1 |
| `venv-openstack-horizon` | SUSE:OpenStack Cloud 9 | All versions | 14.1.1~dev11-4.53.1 |
| `python-Django` | SUSE:OpenStack Cloud Crowbar 8 | All versions | 1.11.29-3.62.1 |
| `python-Django1` | SUSE:OpenStack Cloud Crowbar 9 | All versions | 1.11.29-3.61.1 |
| `python-Django` | SUSE:Package Hub 15 SP5 | All versions | 2.2.28-bp155.7.9.1 |
| `python-Django1` | SUSE:Package Hub 15 SP5 | All versions | 1.11.29-bp155.4.9.1 |
| `python-Django` | openSUSE:Leap 15.5 | All versions | 2.0.7-150000.1.17.1 |
| `python-Django` | openSUSE:Leap 15.5 | All versions | 2.2.28-bp155.7.9.1 |
| `python-Django1` | openSUSE:Leap 15.5 | All versions | 1.11.29-bp155.4.9.1 |
| `python-Django` | openSUSE:Tumbleweed | All versions | 4.2.11-1.1 |

Products: Djangoproject Django.

## How do I fix CVE-2024-27351?

Upgrade django to a fixed version for your release line: 3.2.25, 4.2.11 or 5.0.3.

## Is CVE-2024-27351 being exploited?

There is no known exploitation of CVE-2024-27351 in the wild and no public exploit code.

## Other vulnerabilities in Djangoproject Django

- [CVE-2026-4277](https://insights.sbomify.com/CVE-2026-4277/): Privilege abuse in GenericInlineModelAdmin (critical 9.8)
- [CVE-2024-53908](https://insights.sbomify.com/CVE-2024-53908/): Django SQL injection in HasKey(lhs, rhs) on Oracle (critical 9.8)
- [CVE-2024-42005](https://insights.sbomify.com/CVE-2024-42005/): Django SQL injection vulnerability (critical 9.8)
- [CVE-2023-31047](https://insights.sbomify.com/CVE-2023-31047/): Django bypasses validation when using one form field to upload multiple files (critical 9.8)
- [CVE-2022-34265](https://insights.sbomify.com/CVE-2022-34265/): Django `Trunc()` and `Extract()` database functions vulnerable to SQL Injection (critical 9.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-27351 and fix it if it is affected.

What it is: CVE-2024-27351 is a medium-severity denial of service vulnerability in Djangoproject Django, published on 15 Mar 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2024-27351 in the wild and no public exploit code.

Affected packages and fixed versions:
- django (Bitnami): affected from 3.2.0; fixed in 3.2.25, 4.2.11, 5.0.3
- django (PyPI): affected from 3.2; fixed in 3.2.25, 4.2.11, 5.0.3
- django (PyPI): affected from 3.2; fixed in 3.2.25
- django (PyPI): affected from 4.2; fixed in 4.2.11
- django (PyPI): affected from 5.0; fixed in 5.0.3
- Django (PyPI): affected from 3.2; fixed in 3.2.25
- Django (PyPI): affected from 4.2; fixed in 4.2.11
- Django (PyPI): affected from 5.0; fixed in 5.0.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-27351/ (Markdown: https://insights.sbomify.com/CVE-2024-27351/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-27351
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-27351
- OSV: https://osv.dev/vulnerability/CVE-2024-27351

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-27351/
Summaries are generated and may contain mistakes; the official description above is the record.
