Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency path-to-regexp to v1 [security] #1454

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Sep 9, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
path-to-regexp 0.2.5 -> 1.9.0 age adoption passing confidence

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 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.

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


Release Notes

pillarjs/path-to-regexp (path-to-regexp)

v1.9.0: Fix backtracking in 1.x

Compare Source

Fixed

v1.8.0: Backport token to function options

Compare Source

Added

  • Backport TokensToFunctionOptions

v1.7.0

Compare Source

  • Allow a delimiter option to be passed in with tokensToRegExp which will be used for "non-ending" token match situations

v1.6.0

Compare Source

  • Populate RegExp.keys when using the tokensToRegExp method (making it consistent with the main export)
  • Allow a delimiter option to be passed in with parse
  • Updated TypeScript definition with Keys and Options updated

v1.5.3

Compare Source

  • Add \\ to the ignore character group to avoid backtracking on mismatched parens

v1.5.2

Compare Source

  • Escape \\ in string segments of regexp

v1.5.1

Compare Source

  • Add index.d.ts to NPM package

v1.5.0

Compare Source

  • Handle partial token segments (better)
  • Allow compile to handle asterisk token segments

v1.4.0

Compare Source

  • Handle RegExp unions in path matching groups

v1.3.0

Compare Source

  • Clarify README language and named parameter token support
  • Support advanced Closure Compiler with type annotations
  • Add pretty paths options to compiled function output
  • Add TypeScript definition to project
  • Improved prefix handling with non-complete segment parameters (E.g. /:foo?-bar)

v1.2.1

Compare Source

  • Encode values before validation with path compilation function
  • More examples of using compilation in README

v1.2.0

Compare Source

  • Add support for matching an asterisk (*) as an unnamed match everything group ((.*))

v1.1.1

Compare Source

  • Expose methods for working with path tokens

v1.1.0

Compare Source

  • Expose the parser implementation to consumers
  • Implement a compiler function to generate valid strings
  • Huge refactor of tests to be more DRY and cover new parse and compile functions
  • Use chai in tests
  • Add .editorconfig

v1.0.3

Compare Source

  • Optimised function runtime
  • Added files to package.json

v1.0.2

Compare Source

  • Use Array.isArray shim
  • Remove ES5 incompatible code
  • Fixed repository path
  • Added new readme badges

v1.0.1

Compare Source

  • Ensure installation works correctly on 0.8

v1.0.0

Compare Source

  • No more API changes

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.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot changed the title fix(deps): update dependency path-to-regexp to v8 [security] fix(deps): update dependency path-to-regexp to v8 [security] - autoclosed Sep 9, 2024
@renovate renovate bot closed this Sep 9, 2024
@renovate renovate bot deleted the renovate/npm-path-to-regexp-vulnerability branch September 9, 2024 23:20
@renovate renovate bot changed the title fix(deps): update dependency path-to-regexp to v8 [security] - autoclosed fix(deps): update dependency path-to-regexp to v8 [security] Sep 11, 2024
@renovate renovate bot reopened this Sep 11, 2024
@renovate renovate bot restored the renovate/npm-path-to-regexp-vulnerability branch September 11, 2024 17:37
@renovate renovate bot changed the title fix(deps): update dependency path-to-regexp to v8 [security] fix(deps): update dependency path-to-regexp to v1 [security] Sep 11, 2024
@renovate renovate bot force-pushed the renovate/npm-path-to-regexp-vulnerability branch from 868e47b to 4229ba6 Compare September 11, 2024 17:38
@oFlo193o
Copy link

Any chance this will be merged soon? @micalevisk
I saw you contribution here and this is basically the same vulnerability: nestjs/nest#13971

@micalevisk
Copy link
Member

@oFlo193o should be but there is no ETA.

@micalevisk
Copy link
Member

tbf, I'm not sure if we can just merge this because we are moving from v0 to v1 here.

@oFlo193o
Copy link

@micalevisk
It is save to update as per
pillarjs/path-to-regexp#320 (comment)

@joonashak
Copy link

Hoping to see this merged soon, too 👍

According to the PR comment linked by @oFlo193o it would indeed seem that there were no API changes between 0.2.5 and 1.0.0 so this should be safe to merge? See https://github.com/pillarjs/path-to-regexp/blob/7aff887e73ee8bca5cc98ee6239616da07eb8523/History.md#100--2014-08-17

@BeataKr
Copy link

BeataKr commented Sep 20, 2024

any update? :)

@JesseObrien
Copy link

Looking for an update on this as well 👀

@kekiel
Copy link

kekiel commented Sep 26, 2024

Yes, it would be nice to have it merged, since using "override" in the root package.json is not working and this is reported as a high-risk CVE.

@CleberL
Copy link

CleberL commented Sep 27, 2024

Any predictions for this pr to be integrated?

@GowthamanT
Copy link

Reviewers have accepted the change. Can you please merge this @micalevisk
I am also looking for this change.

@micalevisk
Copy link
Member

Only Kamil can merge PRs

@micalevisk
Copy link
Member

micalevisk commented Oct 1, 2024

I'm not sure if we can address this issue without introducing breaking changes

@lethanhan97
Copy link

Hey guys, looking for an update on this as well

@Zimovets
Copy link

Zimovets commented Oct 4, 2024

when i try to change dependencies i faceed an issue - https://stackoverflow.com/questions/79051743/npm-override-overrides-not-only-the-package-i-specify , npm override change not only specified package but others too, some ideas how to fix it?

@pyr3-dev
Copy link

pyr3-dev commented Oct 5, 2024

any updates?

@kamilmysliwiec
Copy link
Member

This would introduce a breaking change so we need to wait till the next major release

@nestjs nestjs locked and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.