CVE-2018-7537: Django denial-of-service in truncatechars_html and truncatewords_html filters

CVE-2018-7537 · Severity: low · CVSS 3 · Published 2018-03-09

Django is a widely-used Python web application framework. The truncatechars_html and truncatewords_html template filters, used to shorten and sanitize HTML text in web pages, contained a regular expression with catastrophic backtracking behavior. An attacker could provide specially crafted input to these filters, causing the server to consume excessive CPU resources and become unresponsive, disrupting service availability.

Technologies: Django (PyPI). Vendors: PyPI.

Quick answers

Is CVE-2018-7537 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2018-7537 being exploited in the wild.
How severe is CVE-2018-7537?
Low severity, with a CVSS score of 3, published 9 March 2018.
Which products and versions are affected?
Django (PyPI) ECOSYSTEM:introduced=1.8,fixed=1.8.19,introduced=1.11,fixed=1.11.11,introduced=2.0,fixed=2.0.3, ECOSYSTEM:introduced=2.0,fixed=2.0.3.
Is there a fix for CVE-2018-7537?
Yes. Django (PyPI): upgrade to 2.0.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2018-7537 attacked?
It is attacked over the network.
Am I affected by CVE-2018-7537?
Check whether you run Django (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • Django (PyPI): upgrade to 2.0.3 or later
    pip install "Django>=2.0.3"

Technical details

The vulnerability exists in Django's django.utils.text.Truncator class, specifically in the chars() and words() methods when invoked with html=True. These methods use a regular expression susceptible to catastrophic backtracking (CWE-185), which causes exponential time complexity when processing certain malicious inputs. The vulnerable template filters—truncatechars_html and truncatewords_html—are typically reachable whenever user-controlled or attacker-influenced data is processed through these filters. No authentication is required; an attacker simply needs to send a request containing specially crafted HTML input. The fix involved replacing the vulnerable regular expression with one that does not exhibit backtracking vulnerabilities. Patches were released in Django 2.0.3, 1.11.11, and 1.8.19.

Affected products

  • Django Django 1.8 before 1.8.19, 1.11 before 1.11.11, 2.0 before 2.0.3

Identifiers

  • CVE-2018-7537
  • GHSA-2f9x-5v75-3qv4
  • PYSEC-2018-6

Timeline

  • 2019-01-04: disclosed: Vulnerability published via GHSA-2f9x-5v75-3qv4
  • 2018-03: patched: Security releases issued: Django 1.8.19, 1.11.11, 2.0.3

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.