CVE-2024-53907: Django Denial-of-Service Vulnerability via strip_tags() Method
Summary
CVE-2024-53907: An issue was discovered in Django 5.1 before 5.1.4, 5.0 before 5.0.10, and 4.2 before 4.2.17. Affects django across 3 version ranges.
>= 4.2, < 4.2.17
>= 5.0, < 5.0.10
>= 5.1, < 5.1.4
Fixed in 4.2.17, 5.0.10 or 5.1.4, depending on the release line you run. How to fix ↓
Also tracked for
- django · Bitnami
- python-django · Debian:11
The same CVE-2024-53907 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It provides a robust set of features for building web applications, including an ORM, templating engine, and security features. However, certain versions of Django are vulnerable to a denial-of-service attack due to improper handling of nested incomplete HTML entities in the strip_tags() method and striptags template filter.
Vulnerability Detail
An issue was discovered in Django versions 5.1 before 5.1.4, 5.0 before 5.0.10, and 4.2 before 4.2.17. The vulnerability arises from the strip_tags() method and striptags template filter, which can be exploited through inputs containing large sequences of nested incomplete HTML entities. This can lead to a denial-of-service condition, where the application may become unresponsive or crash due to excessive resource consumption.
How To Fix
Latest published version: 6.1.2 as of 22 Oct 2026
pip install --upgrade "django==6.1.2"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
>= 4.2, < 4.2.174.2.17pip install --upgrade "django==4.2.17" -
>= 5.0, < 5.0.105.0.10pip install --upgrade "django==5.0.10" -
>= 5.1, < 5.1.45.1.4pip install --upgrade "django==5.1.4"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If you cannot immediately update Django, consider sanitizing inputs to the strip_tags() method and striptags template filter to prevent large sequences of nested incomplete HTML entities from being processed. This can be done by implementing a custom input validation function that limits the depth of nested HTML entities.
Conclusion
The vulnerability identified as CVE-2024-53907 poses a significant risk to applications using affected versions of Django. It is crucial to update to the latest patched versions to mitigate the risk of denial-of-service attacks. Additionally, implementing input validation can serve as a temporary workaround until an upgrade can be performed.
See every vulnerability recorded for django →
FAQ
Django versions 5.1 before 5.1.4, 5.0 before 5.0.10, and 4.2 before 4.2.17 are affected.
The vulnerability can lead to a denial-of-service attack, causing the application to become unresponsive or crash.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.
Yes, you can implement input validation to limit the depth of nested HTML entities processed by the strip_tags() method and striptags template filter.
More information can be found in the official Django security advisory and the GitHub advisory database.
Related vulnerabilities
Recent vulnerabilities recorded for django.