CVE-2024-45296

CVE-2024-45296 is a high-severity inefficient regular expression (ReDoS) vulnerability in path-to-regexp (npm), affecting versions < 0.1.10. It is fixed in 0.1.10, 1.9.0, 3.3.0, 8.0.0, 6.3.0.

Summary

Workarounds

All versions can be patched by providing a custom regular expression for parameters after the first in a single segment. As long as the custom regular expression does not match the text before the parameter, you will be safe. For example, change /:a-:b to /:a-:b([^-/]+).

If paths cannot be rewritten and versions cannot be upgraded, another alternative is to limit the URL length. For example, halving the attack string improves performance by 4x faster.

Details

Using /:a-:b will produce the regular expression /^\/([^\/]+?)-([^\/]+?)\/?$/. This can be exploited by a path such as /a${'-a'.repeat(8_000)}/a. OWASP has a good example of why this occurs, but the TL;DR is the /a at the end ensures this route would never match but due to naive backtracking it will still attempt every combination of the :a-:b on the repeated 8,000 -a.

Because JavaScript is single threaded and regex matching runs on the main thread, poor performance will block the event loop and can lead to a DoS. In local benchmarks, exploiting the unsafe regex will result in performance that is over 1000x worse than the safe regex. In a more realistic environment using Express v4 and 10 concurrent connections, this translated to average latency of ~600ms vs 1ms.

References

Impact

A bad regular expression is generated any time you have two parameters within a single segment, separated by something that is not a period (.). For example, /:a-:b.

A regular expression with worst-case exponential or polynomial matching time is applied to untrusted input, causing excessive CPU use. Typical impact: denial of service when input is crafted to trigger backtracking.

CVE-2024-45296 has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (0.1.10, 1.9.0, 3.3.0, 8.0.0, 6.3.0); upgrading removes the vulnerable code path.

Affected versions

path-to-regexp (< 0.1.10) path-to-regexp (>= 0.2.0, < 1.9.0) path-to-regexp (>= 2.0.0, < 3.3.0) path-to-regexp (>= 7.0.0, < 8.0.0) path-to-regexp (>= 4.0.0, < 6.3.0)

Security releases

path-to-regexp → 0.1.10 (npm) path-to-regexp → 1.9.0 (npm) path-to-regexp → 3.3.0 (npm) path-to-regexp → 8.0.0 (npm) path-to-regexp → 6.3.0 (npm)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

For users of 0.1, upgrade to 0.1.10. All other users should upgrade to 8.0.0.

These versions add backtrack protection when a custom regex pattern is not provided:

They do not protect against vulnerable user supplied capture groups. Protecting against explicit user patterns is out of scope for old versions and not considered a vulnerability.

Version 7.1.0 can enable strict: true and get an error when the regular expression might be bad.

Version 8.0.0 removes the features that can cause a ReDoS.

Frequently Asked Questions

  1. What is CVE-2024-45296? CVE-2024-45296 is a high-severity inefficient regular expression (ReDoS) vulnerability in path-to-regexp (npm), affecting versions < 0.1.10. It is fixed in 0.1.10, 1.9.0, 3.3.0, 8.0.0, 6.3.0. A regular expression with worst-case exponential or polynomial matching time is applied to untrusted input, causing excessive CPU use.
  2. How severe is CVE-2024-45296? CVE-2024-45296 has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of path-to-regexp are affected by CVE-2024-45296? path-to-regexp (npm) versions < 0.1.10 is affected.
  4. Is there a fix for CVE-2024-45296? Yes. CVE-2024-45296 is fixed in 0.1.10, 1.9.0, 3.3.0, 8.0.0, 6.3.0. Upgrade to this version or later.
  5. Is CVE-2024-45296 exploitable, and should I be worried? Whether CVE-2024-45296 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2024-45296 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2024-45296?
    • Upgrade path-to-regexp to 0.1.10 or later
    • Upgrade path-to-regexp to 1.9.0 or later
    • Upgrade path-to-regexp to 3.3.0 or later
    • Upgrade path-to-regexp to 8.0.0 or later
    • Upgrade path-to-regexp to 6.3.0 or later

Other vulnerabilities in path-to-regexp

CVE-2026-4923CVE-2026-4926CVE-2024-52798CVE-2024-45296

Stop the waste.
Protect your environment with Kodem.