CVE-2022-21680: marked ReDoS in block.def regular expression

CVE-2022-21680 · Severity: low · CVSS 3.1 · Published 2022-01-14

marked is a JavaScript markdown parser used by thousands of applications to convert markdown text into HTML. An attacker can craft a malicious markdown string that causes the parser to hang or consume excessive CPU resources, effectively denying service to legitimate users. This can impact any application that processes untrusted markdown without resource limits.

Technologies: marked (npm). Vendors: npm.

Quick answers

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

  • marked (npm): upgrade to 4.0.10 or later
    npm install marked@4.0.10

Technical details

A Regular Expression Denial of Service (ReDoS) vulnerability exists in the block.def regular expression used by marked's markdown parsing engine. The regex exhibits cubic catastrophic backtracking when processing specially crafted input strings containing repeated whitespace, causing exponential computational complexity. The vulnerability is triggered when untrusted markdown is parsed without safeguards; a proof-of-concept payload with 1500 repeated spaces triggers excessive CPU consumption. No authentication or user interaction is required—an attacker needs only the ability to submit markdown for parsing. The issue has been patched in version 4.0.10; workarounds include running marked on a worker thread with a time limit or avoiding parsing of untrusted markdown.

Affected products

  • markedjs marked before 4.0.10

Identifiers

  • CVE-2022-21680
  • GHSA-rrrm-qjm4-v8hf

Timeline

  • 2022-01-14: disclosed
  • 2022-01-14: patched: version 4.0.10 released

References

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