CVE-2018-7537: Django Truncator Catastrophic Backtracking Vulnerability

django Updated 02 Oct 2025

Summary

09/03/2018
Yes i
Low
5.3

CVE-2018-7537: 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

The same CVE-2018-7537 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Django is a popular Python web framework that simplifies the development of web applications. It provides various utilities and features to handle common web development tasks. One of these utilities is the Truncator class in the django.utils.text module, which is responsible for truncating text in a safe and efficient manner. 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 Truncator class when the html=True argument is passed to the chars() and words() methods. This vulnerability can lead to extremely slow evaluation of certain inputs, making the application susceptible to denial-of-service attacks.

Vulnerability Detail

The vulnerability arises from a regular expression used in the Truncator class. When the html=True argument is provided, the regular expression can exhibit catastrophic backtracking behavior, causing the evaluation to take an excessive amount of time for certain inputs. This can be exploited by an attacker to consume significant server resources and potentially render the application unresponsive. The vulnerable methods, chars() and words(), are used to implement the truncatechars_html and truncatewords_html template filters, which means that any usage of these filters in Django templates can trigger the vulnerability.

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.19 1.8.19
    pip install --upgrade "django==1.8.19"
  • >= 1.11, < 1.11.11 1.11.11
    pip install --upgrade "django==1.11.11"
  • >= 2.0, < 2.0.3 2.0.3
    pip 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 can be applied by avoiding the usage of the truncatechars_html and truncatewords_html template filters. Instead, developers can implement custom template filters or use alternative approaches to achieve the desired text truncation functionality. Here is an example of a custom template filter that truncates text without triggering the vulnerability:

from django import template
from django.utils.text import Truncator

register = template.Library()

@register.filter
def safe_truncatechars_html(value, arg):
    return Truncator(value).chars(arg)

Conclusion

The Django Truncator catastrophic backtracking vulnerability can lead to denial-of-service attacks and application unresponsiveness. It is crucial to upgrade Django to the fixed versions or apply the provided workaround to mitigate the risk. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for django →

Share this vulnerability

FAQ

The vulnerability can be exploited by an attacker to cause a denial-of-service condition, potentially rendering the affected Django application unresponsive.

Versions of Django prior to 2.0.3, 1.11.11, and 1.8.19 are affected by this vulnerability.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock file, and Vulert will analyze it for open-source vulnerabilities, including this specific Django vulnerability.

Yes, upgrading Django to version 2.0.3, 1.11.11, or 1.8.19 will fix this vulnerability. It is recommended to upgrade to the latest stable release to ensure the application benefits from the latest security patches and improvements.

If immediate upgrading is not possible, a temporary workaround is to avoid using the truncatechars_html and truncatewords_html template filters. Custom template filters or alternative approaches can be implemented to achieve the desired text truncation functionality.

Related vulnerabilities

Recent vulnerabilities recorded for django.

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.19 1.8.19
    pip install --upgrade "django==1.8.19"
  • >= 1.11, < 1.11.11 1.11.11
    pip install --upgrade "django==1.11.11"
  • >= 2.0, < 2.0.3 2.0.3
    pip 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback