CVE-2021-35065
Description
The glob-parent package before 6.0.1 for Node.js allows ReDoS (regular expression denial of service) attacks against the enclosure regular expression.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
glob-parent before 6.0.1 is vulnerable to ReDoS via crafted input that causes catastrophic backtracking.
Vulnerability
Overview
The glob-parent package before version 6.0.1 contains a regular expression denial of service (ReDoS) vulnerability. The enclosure regular expression used for parsing glob patterns can exhibit catastrophic backtracking when processing specially crafted inputs, leading to excessive CPU consumption [2][4].
Exploitation
An attacker can trigger the vulnerability by providing a malicious string, such as a sequence of repeated forward slashes, to any function that uses glob-parent. No authentication or special network position is required; the input can be supplied via user-controlled filenames or paths in Node.js applications [1]. Performance tests demonstrate that processing such inputs results in quadratic runtime (O(n²)), causing significant delays [1].
Impact
Successful exploitation leads to a denial of service (DoS) condition, where the application becomes unresponsive due to CPU exhaustion. This can affect server-side applications that parse user-provided glob patterns without proper input validation [4].
Mitigation
The vulnerability is fixed in glob-parent version 6.0.1 and later [3]. Users should upgrade to the patched version immediately. There are no known workarounds, as the fix modifies the underlying regular expression to prevent catastrophic backtracking [1].
AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
glob-parentnpm | >= 6.0.0, < 6.0.1 | 6.0.1 |
Affected products
10- osv-coords10 versionspkg:bitnami/gulppkg:npm/glob-parentpkg:rpm/almalinux/nodejspkg:rpm/almalinux/nodejs-develpkg:rpm/almalinux/nodejs-docspkg:rpm/almalinux/nodejs-full-i18npkg:rpm/almalinux/nodejs-nodemonpkg:rpm/almalinux/nodejs-packagingpkg:rpm/almalinux/nodejs-packaging-bundlerpkg:rpm/almalinux/npm
>= 6.0.0, < 6.0.1+ 9 more
- (no CPE)range: >= 6.0.0, < 6.0.1
- (no CPE)range: >= 6.0.0, < 6.0.1
- (no CPE)range: < 1:16.19.1-1.module_el8.7.0+3496+a59a3324
- (no CPE)range: < 1:16.19.1-1.module_el8.7.0+3496+a59a3324
- (no CPE)range: < 1:16.19.1-1.module_el8.7.0+3496+a59a3324
- (no CPE)range: < 1:16.19.1-1.module_el8.7.0+3496+a59a3324
- (no CPE)range: < 2.0.20-3.module_el8.7.0+3496+a59a3324
- (no CPE)range: < 25-1.module_el8.5.0+2605+45d748af
- (no CPE)range: < 2021.06-4.module_el8.7.0+3343+ea2b7901
- (no CPE)range: < 1:8.19.3-1.16.19.1.1.module_el8.7.0+3496+a59a3324
Patches
23e9f04a3b434fix: Resolve ReDoS vulnerability from CVE-2021-35065 (#49)
2 files changed · +43 −2
index.js+25 −2 modified@@ -6,7 +6,6 @@ var isWin32 = require('os').platform() === 'win32'; var slash = '/'; var backslash = /\\/g; -var enclosure = /[{[].*\/.*[}\]]$/; var globby = /(^|[^\\])([{[]|\([^)]+$)/; var escaped = /\\([!*?|[\](){}])/g; @@ -24,7 +23,7 @@ module.exports = function globParent(str, opts) { } // special case for strings ending in enclosure containing path separator - if (enclosure.test(str)) { + if (isEnclosure(str)) { str += slash; } @@ -39,3 +38,27 @@ module.exports = function globParent(str, opts) { // remove escape chars and return result return str.replace(escaped, '$1'); }; + + +function isEnclosure(str) { + var lastChar = str.slice(-1) + + var enclosureStart; + switch (lastChar) { + case '}': + enclosureStart = '{'; + break; + case ']': + enclosureStart = '['; + break; + default: + return false; + } + + var foundIndex = str.indexOf(enclosureStart); + if (foundIndex < 0) { + return false; + } + + return str.slice(foundIndex + 1, -1).includes(slash); +}
test/index.test.js+18 −0 modified@@ -224,6 +224,24 @@ describe('glob2base test patterns', function () { done(); }); + + it('should finish in reasonable time for \'{\' + \'/\'.repeat(n) [CVE-2021-35065]', function(done) { + this.timeout(1000); + gp('{' + '/'.repeat(500000)); + done(); + }); + + it('should finish in reasonable time for \'{\'.repeat(n)', function(done) { + this.timeout(1000); + gp('{'.repeat(500000)); + done(); + }); + + it('should finish in reasonable time for \'(\'.repeat(n)', function(done) { + this.timeout(1000); + gp('('.repeat(500000)); + done(); + }); }); if (isWin32) {
32f6d52663b7fix!: Correct mishandled escaped path separators (#34)
2 files changed · +5 −5
index.js+1 −1 modified@@ -6,7 +6,7 @@ var isWin32 = require('os').platform() === 'win32'; var slash = '/'; var backslash = /\\/g; -var enclosure = /[{[].*[}\]]$/; +var enclosure = /[{[].*\/.*[}\]]$/; var globby = /(^|[^\\])([{[]|\([^)]+$)/; var escaped = /\\([!*?|[\](){}])/g;
test/index.test.js+4 −4 modified@@ -77,10 +77,10 @@ describe('glob-parent', function () { 'path/[foo bar]/subdir' ); expect(gp('path/\\[bar]/')).toEqual('path/[bar]'); - expect(gp('path/\\[bar]')).toEqual('path/[bar]'); + expect(gp('path/\\[bar]')).toEqual('path'); expect(gp('[bar]')).toEqual('.'); expect(gp('[bar]/')).toEqual('.'); - expect(gp('./\\[bar]')).toEqual('./[bar]'); + expect(gp('./\\[bar]')).toEqual('.'); expect(gp('\\[bar]/')).toEqual('[bar]'); expect(gp('\\!dir/*')).toEqual('!dir'); expect(gp('[bar\\]/')).toEqual('.'); @@ -95,9 +95,9 @@ describe('glob-parent', function () { expect(gp('foo-\\(bar\\).md')).toEqual('foo-'); } else { expect(gp('foo-\\(bar\\).md')).toEqual('.'); - expect(gp('\\[bar]')).toEqual('[bar]'); + expect(gp('\\[bar]')).toEqual('.'); expect(gp('[bar\\]')).toEqual('.'); - expect(gp('\\{foo,bar\\}')).toEqual('{foo,bar}'); + expect(gp('\\{foo,bar\\}')).toEqual('.'); expect(gp('{foo,bar\\}')).toEqual('.'); }
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
10- github.com/advisories/GHSA-cj88-88mr-972wghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-35065ghsaADVISORY
- github.com/gulpjs/glob-parent/commit/32f6d52663b7addac38d0dff570d8127edf03f47ghsaWEB
- github.com/gulpjs/glob-parent/commit/3e9f04a3b4349db7e1962d87c9a7398cda51f339ghsaWEB
- github.com/gulpjs/glob-parent/pull/49ghsaWEB
- github.com/gulpjs/glob-parent/releases/tag/v6.0.1ghsaWEB
- github.com/opensearch-project/OpenSearch-Dashboards/issues/1103ghsaWEB
- security.netapp.com/advisory/ntap-20230214-0010ghsaWEB
- security.snyk.io/vuln/SNYK-JS-GLOBPARENT-1314294ghsaWEB
- www.mend.io/vulnerability-database/CVE-2021-35065ghsaWEB
News mentions
0No linked articles in our index yet.