Packages / brace-expansion / Security
brace-expansion: Large numeric range defeats documented `max` DoS protection
Affected releases · brace-expansion
- 5.x5.0.2 – 5.0.5Fixed in 5.0.6
On 5.x, the newest line:
npm install brace-expansion@5.0.6Every release on a timeline
Not affected
0.0.0 – 4.0.1
52 releases
Affected
5.0.2 – 5.0.5
4 releases
Fixed
5.0.6 – 5.0.13
8 releases, latest
What happens
The max option was being applied too late:
When expanding a single large numeric range like {1..10000000}, the sequence generation loop generates all 10 million intermediate elements before the max limit is applied With max=10, the output is correctly limited to 10 items, but the process still allocates ~505 MB and spends ~800ms building the full intermediate array.
Workaround
Ensure the string to be expanded doesn't contain more values than the desired max item count.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.