Executive brief
path-to-regexp is a popular JavaScript library that converts URL path strings (like `/user/:name`) into regular expressions for routing in web applications. When developers use multiple wildcard patterns in certain combinations, the library can generate a regex prone to ReDoS attacks—where specially crafted input causes the regex engine to consume excessive CPU resources, slowing or stopping the application. An attacker can trigger this by sending requests matching the vulnerable pattern, resulting in denial of service.
Technical details
The vulnerability is a Regular Expression Denial of Service (ReDoS / CWE-1333) that occurs when path-to-regexp generates regexes from patterns containing multiple wildcards combined with at least one parameter, where the second wildcard is not at the end of the path. Examples of vulnerable patterns include `/*foo-*bar-:baz`, `/*a-:b-*c-:d`, and `/x/*a-:b/*c/y`. The generated regex exhibits catastrophic backtracking due to overlapping quantifiers, causing exponential time complexity on malicious input. The attack requires only network access with no authentication or user interaction needed. An attacker can craft HTTP requests with paths matching the vulnerable pattern to trigger excessive CPU consumption and cause denial of service. The issue affects path-to-regexp versions 8.0.0 through 8.3.0 and is resolved in version 8.4.0.
Affected products
- pillarjs path-to-regexp 8.0.0 to 8.3.0
Timeline
- 2026-03-26: disclosed: Vulnerability disclosed via GitHub Security Advisory GHSA-27v5-c462-wpq7
- 2026-03-27: patched: Fixed in version 8.4.0