CVE-2022-21670: markdown-it denial of service via regex backtracking

CVE-2022-21670 · Severity: low · CVSS 3.1 · Published 2022-01-12

markdown-it is a popular JavaScript library for parsing and rendering Markdown. A specially crafted Markdown document containing patterns longer than 50KB can cause the parser to consume excessive CPU resources and become unresponsive, potentially disrupting any application that relies on it to process user-supplied content.

Technologies: markdown-it (npm). Vendors: npm.

Quick answers

Is CVE-2022-21670 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2022-21670 being exploited in the wild.
How severe is CVE-2022-21670?
Low severity, with a CVSS score of 3.1, published 12 January 2022.
Which products and versions are affected?
markdown-it (npm) SEMVER:introduced=0,fixed=12.3.2.
Is there a fix for CVE-2022-21670?
Yes. markdown-it (npm): upgrade to 12.3.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2022-21670 attacked?
It is attacked over the network.
Am I affected by CVE-2022-21670?
Check whether you run markdown-it (npm) 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

  • markdown-it (npm): upgrade to 12.3.2 or later
    npm install markdown-it@12.3.2

Technical details

The vulnerability is a Regular Expression Denial of Service (ReDoS) / uncontrolled resource consumption flaw in the newline rule regex processing. Attackers can craft Markdown input with specific patterns (e.g., large sequences of whitespace) exceeding 50KB that trigger excessive backtracking in the parser's regex engine, causing significant CPU consumption and parser slowdown. The vulnerability requires no authentication and can be triggered by providing malicious input to the render() function. An attacker can cause a denial of service by making the application hang or become unresponsive. The vulnerability is fixed in version 12.3.2 and later.

Affected products

  • markdown-it markdown-it <12.3.2

Identifiers

  • CVE-2022-21670
  • GHSA-6vfc-qv3f-vr6c

Timeline

  • 2022-01-08: disclosed: Security advisory published
  • 2022-01-12: patched: Fixed in version 12.3.2

References

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