HIGH 7.5

CVE-2024-45296

path-to-regexp vulnerable to Regular Expression Denial of Service via multiple route parameters

Description

Impact

A bad regular expression is generated any time you have three or more parameters within a single segment, separated by something that is not a period (.). For example, /:a-:b-:c or /:a-:b-:c-:d. The backtrack protection added in path-to-regexp@0.1.12 only prevents ambiguity for two parameters. With three or more, the generated lookahead does not block single separator characters, so capture groups overlap and cause catastrophic backtracking.

Patches

Upgrade to path-to-regexp@0.1.13

Custom regex patterns in route definitions (e.g., /:a-:b([^-/]+)-:c([^-/]+)) are not affected because they override the default capture group.

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-:c to /:a-:b([^-/]+)-:c([^-/]+).

If paths cannot be rewritten and versions cannot be upgraded, another alternative is to limit the URL length.

References

Affected Maven artifacts (2)

ArtifactAffected versionsFixed in
org.mvnpm » path-to-regexpvia npm path-to-regexp
< 0.1.13< 0.1.10>= 0.2.0, < 1.9.0>= 2.0.0, < 3.3.0>= 4.0.0, < 6.3.0>= 7.0.0, < 8.0.0
0.1.13, 0.1.10, 1.9.0, 3.3.0, 6.3.0, 8.0.0
org.webjars.npm » path-to-regexpvia npm path-to-regexp
< 0.1.13< 0.1.10>= 0.2.0, < 1.9.0>= 2.0.0, < 3.3.0>= 4.0.0, < 6.3.0>= 7.0.0, < 8.0.0
0.1.13, 0.1.10, 1.9.0, 3.3.0, 6.3.0, 8.0.0

Blast radius

2affected artifacts
24affected versions
369dependent artifacts (est.)
16,956dependent versions

39% of the dependent artifacts (144) still pull an affected version in their latest release.

DepthDependent versions
Direct
269
2 hops
403
3 hops
6,067
4 hops
7,978
5 hops
1,976
6 hops
263

Most used dependents

Computed from the dependency graph of build 20261127.1117 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.

Other ecosystems

Also affects npm (1 package) . See all on OSV