braces regular expression denial of service

Severity: low · CVSS 3.1 · Published 2019-06-06

braces is a JavaScript library for Bash-like brace expansion commonly used in build tools and file pattern matching. Versions before 2.3.1 contain a flaw in regular expression parsing that allows an attacker to send specially crafted input causing excessive CPU consumption and application hang, resulting in service unavailability.

Technologies: braces (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 6 June 2019.
Which products and versions are affected?
braces (npm) SEMVER:introduced=0,fixed=2.3.1.
Is there a fix for This vulnerability?
Yes. braces (npm): upgrade to 2.3.1 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.
Am I affected?
Check whether you run braces (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

  • braces (npm): upgrade to 2.3.1 or later
    npm install braces@2.3.1

Technical details

The vulnerability is a Regular Expression Denial of Service (ReDoS) affecting the regex pattern used to detect empty braces: ^\{(,+(?:(\{,+\})*),*|,*(?:(\{,+\})*),+)\}. The vulnerable component is the parser library's regex matching logic. An attacker can exploit this via network if the application processes untrusted brace expansion patterns, causing catastrophic backtracking in the regex engine—testing shows ~10 seconds of CPU consumption for 50KB of crafted input. No authentication is required. The fix was released in version 2.3.1, which optimizes the regex pattern to prevent backtracking.

Affected products

  • braces braces <2.3.1

Timeline

  • 2018-02-19: disclosed
  • 2018-02-18: patched: Version 2.3.1 released with regex optimization fix

References

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