fix(deps): update dependency path-to-regexp to v6 [security] #39360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.1.12
->6.3.0
GitHub Vulnerability Alerts
CVE-2024-45296
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
.Patches
For users of 0.1, upgrade to
0.1.10
. All other users should upgrade to8.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.
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
CVE-2024-52798
Impact
The regular expression that is vulnerable to backtracking can be generated in versions before 0.1.12 of
path-to-regexp
, originally reported in CVE-2024-45296Patches
Upgrade to 0.1.12.
Workarounds
Avoid using two parameters within a single path segment, when the separator is not
.
(e.g. no/:a-:b
). Alternatively, you can define the regex used for both parameters and ensure they do not overlap to allow backtracking.References
Release Notes
pillarjs/path-to-regexp (path-to-regexp)
v6.3.0
: Fix backtracking in 6.xCompare Source
Fixed
f1253b4
v6.2.2
: Updated READMECompare Source
No API changes. Documentation only release.
Changed
c7ec332
e828000
v6.2.1
: Fix matching:name*
parameterCompare Source
Fixed
:name*
parameter (#261)762bc6b
86baef8
Added
ae9e576
77df638
b39edd4
v6.2.0
: Named Capturing GroupsCompare Source
Added
Fixed
strict
flag documentation (#227)v6.1.0
: Use `/#?` as Default DelimiterCompare Source
Fixed
/#?
as default delimiter to avoid matching on query or fragment parametersdelimiter: '.'
v6.0.0
: Custom Prefix and Suffix GroupsCompare Source
This release reverts the prefix behavior added in v3 back to the behavior seen in v2. For the most part, path matching is backward compatible with v2 with these enhancements:
/(abc(?=d))
/{abc(.*)def}
/test(foo
previously worked treating(
as a literal character, now it expects(
to be closed and is treated as a group/test\(foo
Changed
prefixes
option to configure this (starts as/.
which acts like every version since 0.x again){}
to capture prefix/suffix explicitly, enables custom use-cases like/:attr1{-:attr2}?
v5.0.0
: Remove Default Encode URI ComponentCompare Source
No changes to path rules since 3.x, except support for nested RegEx parts in 4.x.
Changed
RegexpOptions
interface toTokensToRegexpOptions
normalizePathname
from library, document solution in READMEencodeURIComponent
v4.0.5
: Decode URICompare Source
Removed
whitelist
in favor ofdecodeURI
(advanced behavior can happen outsidepath-to-regexp
)v4.0.4
: RemoveString#normalize
Compare Source
Fixed
String.prototype.normalize
to continue supporting IEv4.0.3
: Normalize Path WhitelistCompare Source
Added
/%.-
)v4.0.2
: AllowRegexpOptions
inmatch
Compare Source
Fixed
RegexpOptions
inmatch(...)
functionv4.0.1
: Fix Spelling of RegexpCompare Source
Fixed
regexp
spelling across 4.xv4.0.0
: ES2015 Package for BundlersCompare Source
All path rules are backward compatible with 3.x, except for nested
()
and other RegEx special characters that were previously ignored.Changed
match
does not default todecodeURIComponent
Added
normalizePathname
utility for supporting unicode paths in librariesv3.3.0
: Add backtracking protectionCompare Source
Fixed
d31670a
v3.2.0
: Match FunctionCompare Source
Added
match
function to libraryv3.1.0
: Validate and sensitive optionsCompare Source
sensitive
option fortokensToFunction
(#191)validate
option to path functions (#178)v3.0.0
Compare Source
/:att1-:att2-:att3-:att4-:att5
)partial
support, prefer escaping the prefix delimiter explicitly (e.g.\\/(apple-)?icon-:res(\\d+).png
)v2.4.0
Compare Source
start
option to disable anchoring from beginning of the stringv2.3.0
Compare Source
delimiter
when processing repeated matching groups (e.g.foo/bar
has no prefix, but has a delimiter)v2.2.1
Compare Source
end: false
to match both relative and absolute pathsv2.2.0
Compare Source
token
as second argument toencode
option (e.g.encode(value, token)
)v2.1.0
Compare Source
/foo/
before required either/foo/
or/foo//
to match in non-ending modev2.0.0
Compare Source
endsWith
to match paths like/test?query=string
up to the query stringdelimiters
for specific characters to be treated as parameter prefixes (e.g./:test
)isarray
dependency/test/
is now treated as/test/
instead of/test
when matching)keys
argument that acceptedoptions
keys
list attached to theRegExp
outputtokensToFunction
(e.g.compile
) to accept anencode
function for pretty encoding (e.g. pass your own implementation)v1.9.0
: Fix backtracking in 1.xCompare Source
Fixed
925ac8e
re.exec(&#​39;/test/route&#​39;)
result (#267)32a14b0
v1.8.0
: Backport token to function optionsCompare Source
Added
TokensToFunctionOptions
v1.7.0
Compare Source
delimiter
option to be passed in withtokensToRegExp
which will be used for "non-ending" token match situationsv1.6.0
Compare Source
RegExp.keys
when using thetokensToRegExp
method (making it consistent with the main export)delimiter
option to be passed in withparse
Keys
andOptions
updatedv1.5.3
Compare Source
\\
to the ignore character group to avoid backtracking on mismatched parensv1.5.2
Compare Source
\\
in string segments of regexpv1.5.1
Compare Source
index.d.ts
to NPM packagev1.5.0
Compare Source
v1.4.0
Compare Source
v1.3.0
Compare Source
/:foo?-bar
)v1.2.1
Compare Source
v1.2.0
Compare Source
*
) as an unnamed match everything group ((.*)
)v1.1.1
Compare Source
v1.1.0
Compare Source
v1.0.3
Compare Source
files
topackage.json
v1.0.2
Compare Source
Array.isArray
shimv1.0.1
Compare Source
v1.0.0
Compare Source
v0.2.5
Compare Source
v0.2.4
Compare Source
v0.2.3
Compare Source
v0.2.2
Compare Source
v0.2.1
Compare Source
v0.2.0
Compare Source
*
,+
and?
Configuration
📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.