CVE-2024-4067: Regular Expression Denial of Service (ReDoS) in micromatch
Medium CVSS 5.3
- OSV id
- GHSA-952p-6rrq-rcjv
- Also known as
- CVE-2024-4067
- Published
- Last modified
Affected packages
| Package | Affected versions | Fixed in |
|---|---|---|
| micromatch npm |
< 4.0.8 | 4.0.8 |
Versions we track that it affects: micromatch 4.0.7
How to fix it
Upgrade micromatch to 4.0.8 or later.
npm install micromatch@4.0.8
# if it is an indirect dependency: npm update micromatch (or npm audit fix)
- If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
Not sure whether your project uses an affected version? Check your lockfile below for free.
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.
References
- GHSA-952p-6rrq-rcjv on OSV.dev
- Advisory: https://nvd.nist.gov/vuln/detail/CVE-2024-4067
- Web: https://github.com/micromatch/micromatch/issues/243
- Web: https://github.com/micromatch/micromatch/pull/247
- Web: https://github.com/micromatch/micromatch/pull/266
- Web: https://github.com/micromatch/micromatch/commit/03aa8052171e878897eee5d7bb2ae0ae83ec2ade
- Web: https://github.com/micromatch/micromatch/commit/500d5d6f42f0e8dfa1cb5464c6cb420b1b6aaaa0
- Web: https://advisory.checkmarx.net/advisory/CVE-2024-4067
- Web: https://devhub.checkmarx.com/cve-details/CVE-2024-4067
- Package: https://github.com/micromatch/micromatch
- Web: https://github.com/micromatch/micromatch/blob/2c56a8604b68c1099e7bc0f807ce0865a339747a/index.js#L448
- Web: https://github.com/micromatch/micromatch/releases/tag/4.0.8
Am I affected?
Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.
About this data
Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.