Vulnerabilities in pkg:npm/micromatch

PACKAGE
Advisory Identifier: GHSA-952p-6rrq-rcjv
Advisory Summary

CVE-2024-4067 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Micromatch libraries in the npm ecosystem. The issue involves regular expression denial of service (redos) in micromatch. Remediation is available by upgrading affected packages to version 4.0.8.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/micromatch

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/micromatch. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-952p-6rrq-rcjv CVE-2024-4067 MODERATE Regular Expression Denial of Service (ReDoS) in micromatch

CVE-2024-4067 at a Glance

CVE Identifier CVE-2024-4067
GHSA Identifier GHSA-952p-6rrq-rcjv
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Micromatch
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability Low (A:L)

How to Fix CVE-2024-4067

To remediate this vulnerability, upgrade all affected Micromatch dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

micromatch fixed: 4.0.8
npm install micromatch@4.0.8
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls micromatch

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-4067, inspect your project dependencies using npm:

npm ls micromatch

Analyze the terminal output to locate any version of Micromatch in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.0.8), your application is affected.

Note: The npm ls micromatch command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Micromatch, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The NPM package `micromatch` prior to version 4.0.8 is vulnerable to Regular Expression Denial of Service (ReDoS). The vulnerability occurs in `micromatch.braces()` in `index.js` because the pattern `.*` will greedily match anything. By passing a malicious payload, the pattern matching will keep backtracking to the input while it doesn't find the closing bracket. As the input size increases, the consumption time will also increase until it causes the application to hang or slow down. There was a merged fix but further testing shows the issue persisted prior to https://github.com/micromatch/micromatch/pull/266. This issue should be mitigated by using a safe pattern that won't start backtracking the regular expression due to greedy matching.

CVE-2024-4067 Affected Micromatch Versions

1 component(s)
Fixed Versions:
4.0.8
Product / Package Ecosystem Affected Versions Fixed Version
micromatch
npm
< 4.0.8
4.0.8

References

Frequently Asked Questions

What is CVE-2024-4067?
CVE-2024-4067 is a security vulnerability in Micromatch involving Regular Expression Denial of Service (ReDoS) in micromatch under CWE-1333: Inefficient Regular Expression Complexity.
Which Micromatch versions are affected?
Affected versions include releases prior to 4.0.8 across affected packages: micromatch.
What version fixes CVE-2024-4067?
Upgrading to 4.0.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is micromatch affected?
Yes, micromatch is affected in releases prior to 4.0.8. Upgrade your dependency to 4.0.8 or later.
What is the CVSS score of CVE-2024-4067?
CVE-2024-4067 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2024-4067?
CVE-2024-4067 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check npm dependencies for CVE-2024-4067?
Run the dependency tree command: 'npm ls micromatch'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-952p-6rrq-rcjv",
  "modified" : "2024-08-28T13:12:26Z",
  "published" : "2024-05-14T18:30:54Z",
  "aliases" : [ "CVE-2024-4067" ],
  "summary" : "Regular Expression Denial of Service (ReDoS) in micromatch",
  "details" : "The NPM package `micromatch` prior to version 4.0.8 is vulnerable to Regular Expression Denial of Service (ReDoS). The vulnerability occurs in `micromatch.braces()` in `index.js` because the pattern `.*` will greedily match anything. By passing a malicious payload, the pattern matching will keep backtracking to the input while it doesn't find the closing bracket. As the input size increases, the consumption time will also increase until it causes the application to hang or slow down. There was a merged fix but further testing shows the issue persisted prior to https://github.com/micromatch/micromatch/pull/266. This issue should be mitigated by using a safe pattern that won't start backtracking the regular expression due to greedy matching.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "micromatch"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.0.8"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-4067"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/micromatch/issues/243"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/micromatch/pull/247"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/micromatch/pull/266"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/micromatch/commit/03aa8052171e878897eee5d7bb2ae0ae83ec2ade"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/micromatch/commit/500d5d6f42f0e8dfa1cb5464c6cb420b1b6aaaa0"
  }, {
    "type" : "WEB",
    "url" : "https://advisory.checkmarx.net/advisory/CVE-2024-4067"
  }, {
    "type" : "WEB",
    "url" : "https://devhub.checkmarx.com/cve-details/CVE-2024-4067"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/micromatch/micromatch"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/micromatch/blob/2c56a8604b68c1099e7bc0f807ce0865a339747a/index.js#L448"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/micromatch/releases/tag/4.0.8"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-08-21T22:58:52Z",
    "nvd_published_at" : "2024-05-14T15:42:47Z"
  }
}