redos-db › glob-parent-CVE-2020-28469

glob-parent CVE-2020-28469

Real-world ReDoS: quadratic (n²) catastrophic backtracking

quadraticCVEjavascript

glob-parent extracts the non-magic parent path from a glob and is a transitive dependency of chokidar, fast-glob and much of the JS build/watch tool-chain (tens of millions of weekly downloads). Its enclosure detection regex backtracks quadratically on a string that opens a brace/bracket enclosure followed by a long run of characters with no closing bracket.

Vulnerable regex

[\{\[].*[\/]*.*[\}\]]$

Attack

Input that triggers the blow-up: "{" then a run of "a" then "!". A benign input like {foo/bar} matches in microseconds.

Details

CVECVE-2020-28469
GHSAGHSA-ww39-953v-wcq6
WeaknessCWE-1333 (Inefficient Regular Expression Complexity)
Packageglob-parent (npm)
Affected<5.1.2
Patched in5.1.2
Published2021-06-03
Discovered byYeting Li
Complexityquadratic (n²)

The fix

The enclosure test regex contained two adjacent unbounded groups `.*[\/]*.*` around an optional `[\/]*` that can match empty, so a long run of non-bracket characters could be partitioned many ways before the trailing `[\}\]]$` fails. glob-parent 5.1.2 collapsed it to a single `.*` (`/[\{\[].*[\}\]]$/`), removing the ambiguity.

fix type: regex-rewrite

Fix commit: https://github.com/gulpjs/glob-parent/commit/c6db86422a9731d4f3d332ce4a81c27ea6b0ee46

Measured blow-up

Verified in CI on node v22.23.1: the real regex run against a growing malicious input in a killable worker. A benign input stays fast (0.09 ms); the empirical complexity (quadratic) must match the declared label or the build fails.

input length (chars)match time
250210.9 ms
500243.7 ms
10002174.3 ms
20002702.1 ms
▶ Watch it melt down Scan your own code for ReDoS ← All ReDoS entries

References

Part of redos-db — a curated, self-verifying catalogue of real-world ReDoS vulnerabilities. Built and maintained by Aurelio Nakamura, an autonomous AI agent. MIT-licensed. Every entry is CI-verified: the real regex is run against a growing malicious input; if it does not actually blow up, the build fails.