CVE-2024-27351: Django Regular Expression Denial-of-service Vulnerability

MODERATE
Advisory Identifier: GHSA-vm8q-m57g-pff3
CVSS 5.3
CWE-1333
Published
Advisory Summary

CVE-2024-27351 is a MODERATE (CVSS 5.3) regular expression denial-of-service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Django libraries in the PyPI ecosystem. The issue involves regular expression denial-of-service in django. Remediation is available by upgrading affected packages to version 3.2.25, 4.2.11, 5.0.3.

CVE-2024-27351 at a Glance

CVE Identifier CVE-2024-27351
GHSA Identifier GHSA-vm8q-m57g-pff3
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Django
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2024-27351

To remediate this vulnerability, upgrade all affected Django dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Django fixed: 3.2.25
pip install Django>=3.2.25
Django fixed: 4.2.11
pip install Django>=4.2.11
Django fixed: 5.0.3
pip install Django>=5.0.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Django

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-27351, inspect your installed packages using pip:

pip show Django

Analyze the terminal output to locate any version of Django in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.2.25), your application is affected.

Note: The pip show Django command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Django, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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.

CVE-2024-27351 Affected Django Versions

3 component(s)
Fixed Versions:
3.2.254.2.115.0.3
Product / Package Ecosystem Affected Versions Fixed Version
Django
PyPI
≥ 3.2
< 3.2.25
3.2.25
Django
PyPI
≥ 4.2
< 4.2.11
4.2.11
Django
PyPI
≥ 5.0
< 5.0.3
5.0.3

References

Django Source Repository REPOSITORY
https://github.com/pypa/advisory-database/tree/main/vulns/django/PYSEC-2024-47.yaml
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/D2JIRXEDP4ZET5KFMAPPYSK663Q52NEX
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/SN2PLJGYSAAG5KUVIUFJYKD3BLQ4OSN6
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ZQJOMNRMVPCN5WMIZ7YSX5LQ7IR2NY4D
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/D2JIRXEDP4ZET5KFMAPPYSK663Q52NEX
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SN2PLJGYSAAG5KUVIUFJYKD3BLQ4OSN6
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZQJOMNRMVPCN5WMIZ7YSX5LQ7IR2NY4D
NVD — CVE-2024-27351 NVD
https://nvd.nist.gov/vuln/detail/CVE-2024-27351
Security Fix Commit FIX COMMIT
https://github.com/django/django/commit/072963e4c4d0b3a7a8c5412bc0c7d27d1a9c3521
Security Fix Commit FIX COMMIT
https://github.com/django/django/commit/3394fc6132436eca89e997083bae9985fb7e761e
Security Fix Commit FIX COMMIT
https://github.com/django/django/commit/3c9a2771cc80821e041b16eb36c1c37af5349d4a
Django Release RELEASE
https://docs.djangoproject.com/en/5.0/releases/security
Django Source Repository REPOSITORY
https://github.com/django/django
groups.google.com/forum/ WEB
https://groups.google.com/forum/#%21forum/django-announce
Django Release RELEASE
https://www.djangoproject.com/weblog/2024/mar/04/security-releases
Django Security Information SECURITY
http://www.openwall.com/lists/oss-security/2024/03/04/1

Frequently Asked Questions

What is CVE-2024-27351?
CVE-2024-27351 is a security vulnerability in Django involving Regular expression denial-of-service in Django under CWE-1333: Inefficient Regular Expression Complexity.
Which Django versions are affected?
Affected versions include releases prior to 3.2.25, 4.2.11, 5.0.3 across affected packages: Django.
What version fixes CVE-2024-27351?
Upgrading to 3.2.25, 4.2.11, 5.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Django affected?
Yes, Django is affected in releases prior to 3.2.25, 4.2.11, 5.0.3. Upgrade your dependency to 3.2.25, 4.2.11, 5.0.3 or later.
What is the CVSS score of CVE-2024-27351?
CVE-2024-27351 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2024-27351?
CVE-2024-27351 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check PyPI dependencies for CVE-2024-27351?
Run the dependency tree command: 'pip show Django'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vm8q-m57g-pff3",
  "modified" : "2025-11-04T21:31:20Z",
  "published" : "2024-03-15T21:30:43Z",
  "aliases" : [ "CVE-2024-27351" ],
  "summary" : "Regular expression denial-of-service in Django",
  "details" : "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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.2"
      }, {
        "fixed" : "3.2.25"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.2"
      }, {
        "fixed" : "4.2.11"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0"
      }, {
        "fixed" : "5.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-27351"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/072963e4c4d0b3a7a8c5412bc0c7d27d1a9c3521"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/3394fc6132436eca89e997083bae9985fb7e761e"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/3c9a2771cc80821e041b16eb36c1c37af5349d4a"
  }, {
    "type" : "WEB",
    "url" : "https://docs.djangoproject.com/en/5.0/releases/security"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/django/django"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/django/PYSEC-2024-47.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/forum/#%21forum/django-announce"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/D2JIRXEDP4ZET5KFMAPPYSK663Q52NEX"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/SN2PLJGYSAAG5KUVIUFJYKD3BLQ4OSN6"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ZQJOMNRMVPCN5WMIZ7YSX5LQ7IR2NY4D"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/D2JIRXEDP4ZET5KFMAPPYSK663Q52NEX"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SN2PLJGYSAAG5KUVIUFJYKD3BLQ4OSN6"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZQJOMNRMVPCN5WMIZ7YSX5LQ7IR2NY4D"
  }, {
    "type" : "WEB",
    "url" : "https://www.djangoproject.com/weblog/2024/mar/04/security-releases"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2024/03/04/1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-03-18T20:36:41Z",
    "nvd_published_at" : "2024-03-15T20:15:09Z"
  }
}