CVE-2018-7536: Django - Catastrophic Backtracking Vulnerability in urlize() Function
Summary
CVE-2018-7536: An issue was discovered in Django 2.0 before 2.0.3, 1.11 before 1.11.11, and 1.8 before 1.8.19. Affects django across 3 version ranges.
>= 1.8, < 1.8.19
>= 1.11, < 1.11.11
>= 2.0, < 2.0.3
Fixed in 1.8.19, 1.11.11 or 2.0.3, depending on the release line you run. How to fix ↓
Also tracked for
- py-django · Alpine:v3.10
The same CVE-2018-7536 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 popular Python web framework that provides a set of tools and libraries for building web applications. It includes various features such as an ORM, template engine, and authentication system. The urlize() function in Django is used to implement the urlize and urlizetrunc template filters, which automatically convert URLs in text into clickable links. However, versions of Django prior to 2.0.3, 1.11.11, and 1.8.19 are vulnerable to a catastrophic backtracking vulnerability in the urlize() function.
Vulnerability Detail
The urlize() function in Django is susceptible to catastrophic backtracking due to two regular expressions (one in Django 1.8.x) that evaluate certain inputs very slowly. This vulnerability allows an attacker to craft malicious input that can cause the function to consume excessive CPU resources, leading to denial of service (DoS) attacks. The urlize() function is commonly used in Django templates, making it a potential target for exploitation. The vulnerability was assigned CVE-2018-7536 and has been documented in the PyPI advisory database.
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.
-
>= 1.8, < 1.8.191.8.19pip install --upgrade "django==1.8.19" -
>= 1.11, < 1.11.111.11.11pip install --upgrade "django==1.11.11" -
>= 2.0, < 2.0.32.0.3pip install --upgrade "django==2.0.3"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If upgrading Django is not immediately feasible, a temporary workaround is to avoid using the urlize and urlizetrunc template filters in Django templates. Instead, developers can manually sanitize and convert URLs in their code to mitigate the risk of exploitation. Here's an example of how to manually sanitize and convert URLs using the Django URLValidator:
from django.core.validators import URLValidator
from django.core.exceptions import ValidationError
def sanitize_and_convert_url(url):
validator = URLValidator()
try:
validator(url)
return '<a href="' + url + '">' + url + '</a>'
except ValidationError:
return url
This code snippet demonstrates a basic approach to sanitize and convert URLs, but it may need to be adapted based on specific application requirements.
Conclusion
The catastrophic backtracking vulnerability in the urlize() function of Django versions prior to 2.0.3, 1.11.11, and 1.8.19 can be mitigated by upgrading to the fixed versions. It is crucial to promptly address this vulnerability to prevent potential denial of service attacks and ensure the security and stability of Django applications. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for django →
FAQ
The vulnerability allows an attacker to craft malicious input that can cause the urlize() function to consume excessive CPU resources, leading to denial of service (DoS) attacks. This can result in degraded performance or unavailability of the affected Django application.
Versions of Django prior to 2.0.3, 1.11.11, and 1.8.19 are affected by this vulnerability. It is recommended to upgrade to the fixed versions to mitigate the risk.
At the time of this advisory, there are no known public exploits specifically targeting this vulnerability. However, it is important to apply the recommended patches or upgrades to protect against potential exploitation.
As this vulnerability was not assessed using the CVSS scoring system, a specific score is not available. However, given the potential for DoS attacks, it is important to address the vulnerability promptly.
You can find more information about this vulnerability in the PyPI advisory database. The provided source link in the vulnerability details section of this report will direct you to the relevant page.
Related vulnerabilities
Recent vulnerabilities recorded for django.