simple-markdown regular expression denial of service

Severity: low · CVSS 3.1 · Published 2020-09-03

simple-markdown is a JavaScript markdown parser used to convert markdown-like text into structured content. Versions before 0.5.2 are vulnerable to a regular expression denial of service (ReDoS) attack through specially crafted inline code blocks with many spaces. An attacker can send such content to cause the parser to consume excessive CPU resources and slow down or temporarily unavail applications that use the library. The vulnerability is fixed in version 0.5.2 and later.

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

Quick answers

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

  • simple-markdown (npm): upgrade to 0.5.2 or later
    npm install simple-markdown@0.5.2

Technical details

The vulnerability is a regular expression denial of service (ReDoS) in the inline code parsing regex used by the SimpleMarkdown.defaultInlineParse() function. The vulnerable regex pattern contained overlapping alternatives—specifically, spaces could be matched by either the `\s*` quantifiers or the `[\S\s]*` capture group—leading to catastrophic backtracking when processing strings with many consecutive spaces. The attack requires no authentication and is exploitable remotely via any code path that parses user-supplied markdown input. An attacker can cause severe performance degradation or temporary denial of service. The fix, deployed in commit 89797fe and released in version 0.5.2, removes the problematic `\s*` parts from the regex and instead handles escaping logic post-parsing.

Affected products

  • Khan Academy simple-markdown <0.5.2

Timeline

  • 2019-08-30: disclosed
  • 2020-09-03: advisory
  • 2019: patched: Fix committed in version 0.5.2

References

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