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

Bump path-to-regexp to 8.0.0 [SECURITY] - abandoned #4074

Closed
wants to merge 16 commits into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Sep 10, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
path-to-regexp 7.1.0 -> 8.0.0 age adoption passing confidence
path-to-regexp 6.2.2 -> 8.0.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 this library 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)

v8.0.0: Simpler API

Compare Source

Heads up! This is a fairly large change (again) and I need to apologize in advance. If I foresaw what this version would have ended up being I would not have released version 7. A longer blog post and explanation will be incoming this week, but the pivot has been due to work on Express.js v5 and this will the finalized syntax used in Express moving forward.

Added

  • Adds key names to wildcards using *name syntax, aligns with : behavior but using an asterisk instead

Changed

  • Removes group suffixes of ?, +, and * - only optional exists moving forward (use wildcards for +, {*foo} for *)
  • Parameter names follow JS identifier rules and allow unicode characters

Added

  • Parameter names can now be quoted, e.g. :"foo-bar"

Removed

  • Removes loose mode
  • Removes regular expression overrides of parameters

v7.2.0: Support array inputs (again)

Compare Source

Added

  • Support array inputs for match and pathToRegexp 3fdd88f

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), 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 these updates again.


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

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

Closes #4125

@renovate renovate bot added dependencies Update of dependencies priority: important This change can make a difference labels Sep 10, 2024
Copy link
Contributor Author

renovate bot commented Sep 11, 2024

Edited/Blocked Notification

Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.

You can manually request rebase by checking the rebase/retry box above.

⚠️ Warning: custom changes will be lost.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 11, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 11, 2024
@Janpot
Copy link
Member

Janpot commented Sep 12, 2024

@apedroferreira Will this upgrade have an effect on navigation item patterns? Is that feature sufficiently covered by tests for *, + and ??

@apedroferreira
Copy link
Member

apedroferreira commented Sep 12, 2024

@apedroferreira Will this upgrade have an effect on navigation item patterns? Is that feature sufficiently covered by tests for *, + and ??

Oh I didn't expect that kind of breaking changes, need to cover them in tests then.
Also there seems to be some incompatibility between v8 and the browser testing libraries we use, still have to figure that out...

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 15, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 16, 2024
@Janpot
Copy link
Member

Janpot commented Sep 20, 2024

@apedroferreira Since this will be blocked for a while, how do you feel about bringing those new tests on master, that way we can let renovatebot take over again in rebasing this PR

@apedroferreira
Copy link
Member

@apedroferreira Since this will be blocked for a while, how do you feel about bringing those new tests on master, that way we can let renovatebot take over again in rebasing this PR

I had just commented the same in the other PR :D

@renovate renovate bot changed the title Bump path-to-regexp to 8.0.0 [SECURITY] Bump path-to-regexp to 8.0.0 [SECURITY] - abandoned Sep 20, 2024
Copy link
Contributor Author

renovate bot commented Sep 20, 2024

Autoclosing Skipped

This PR has been flagged for autoclosing. However, it is being skipped due to the branch being already modified. Please close/delete it manually or report a bug if you think this is in error.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 20, 2024
@apedroferreira
Copy link
Member

Moved over the test changes to #4104 so we can reset the modifications in this PR.

@Janpot
Copy link
Member

Janpot commented Sep 20, 2024

Closing this one for now

@Janpot Janpot closed this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Update of dependencies PR: out-of-date The pull request has merge conflicts and can't be merged priority: important This change can make a difference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@toolpad/core 6 depends on vulnerable versions of path-to-regexp
2 participants