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

🚨 [security] Update express 4.15.2 β†’ 4.21.2 (minor) #485

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

Conversation

depfu[bot]
Copy link

@depfu depfu bot commented Dec 12, 2024


🚨 Your current dependencies have known security vulnerabilities 🚨

This dependency update fixes known security vulnerabilities. Please see the details below and assess their impact carefully. We recommend to merge and deploy this as soon as possible!


Here is everything you need to know about this upgrade. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ express (4.15.2 β†’ 4.21.2) Β· Repo Β· Changelog

Security Advisories 🚨

🚨 express vulnerable to XSS via response.redirect()

Impact

In express <4.20.0, passing untrusted user input - even after sanitizing it - to response.redirect() may execute untrusted code

Patches

this issue is patched in express 4.20.0

Workarounds

users are encouraged to upgrade to the patched version of express, but otherwise can workaround this issue by making sure any untrusted inputs are safe, ideally by validating them against an explicit allowlist

Details

successful exploitation of this vector requires the following:

  1. The attacker MUST control the input to response.redirect()
  2. express MUST NOT redirect before the template appears
  3. the browser MUST NOT complete redirection before:
  4. the user MUST click on the link in the template

🚨 Express.js Open Redirect in malformed URLs

Impact

Versions of Express.js prior to 4.19.2 and pre-release alpha and beta versions before 5.0.0-beta.3 are affected by an open redirect vulnerability using malformed URLs.

When a user of Express performs a redirect using a user-provided URL Express performs an encode using encodeurl on the contents before passing it to the location header. This can cause malformed URLs to be evaluated in unexpected ways by common redirect allow list implementations in Express applications, leading to an Open Redirect via bypass of a properly implemented allow list.

The main method impacted is res.location() but this is also called from within res.redirect().

Patches

0867302
0b74695

An initial fix went out with [email protected], we then patched a feature regression in 4.19.1 and added improved handling for the bypass in 4.19.2.

Workarounds

The fix for this involves pre-parsing the url string with either require('node:url').parse or new URL. These are steps you can take on your own before passing the user input string to res.location or res.redirect.

References

#5539
koajs/koa#1800
https://expressjs.com/en/4x/api.html#res.location

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ content-disposition (indirect, 0.5.2 β†’ 0.5.4) Β· Repo Β· Changelog

Release Notes

0.5.4

0.5.3

  • Use safe-buffer for improved Buffer API

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 73 commits:

↗️ finalhandler (indirect, 1.0.6 β†’ 1.3.1) Β· Repo Β· Changelog

Release Notes

1.2.1 (from changelog)

  • Gracefully handle when handling an error and socket is null

1.2.0

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ forwarded (indirect, 0.1.2 β†’ 0.2.0) Β· Repo Β· Changelog

Release Notes

0.2.0

  • Use req.socket over deprecated req.connection

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ fresh (indirect, 0.5.0 β†’ 0.5.2) Β· Repo Β· Changelog

Security Advisories 🚨

🚨 Regular Expression Denial of Service in fresh

Affected versions of fresh are vulnerable to regular expression denial of service when parsing specially crafted user input.

Recommendation

Update to version 0.5.2 or later.

Release Notes

0.5.2 (from changelog)

  • Fix regression matching multiple ETags in If-None-Match
  • perf: improve If-None-Match token parsing

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 23 commits:

↗️ ipaddr.js (indirect, 1.4.0 β†’ 1.9.1) Β· Repo Β· Changelog

Commits

See the full diff on Github. The new version differs by 38 commits:

↗️ path-to-regexp (indirect, 0.1.7 β†’ 0.1.12) Β· Repo Β· Changelog

Security Advisories 🚨

🚨 Unpatched `path-to-regexp` ReDoS in 0.1.x

Impact

The regular expression that is vulnerable to backtracking can be generated in the 0.1.x release of path-to-regexp, originally reported in CVE-2024-45296

Patches

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

🚨 path-to-regexp outputs backtracking regular expressions

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

0.1.12

Fixed

  • Improved backtracking protection for 0.1.x, will break some previously valid paths (see previous advisory: GHSA-9wv6-86v2-598j)

v0.1.11...v0.1.12

0.1.10

Fixed

  • Add backtrack protection to parameters 29b96b4
    • This will break some edge cases but should improve performance

v0.1.9...v0.1.10

0.1.9

Added

component/path-to-regexp@v0.1.8...v0.1.9

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 11 commits:

↗️ proxy-addr (indirect, 1.1.5 β†’ 2.0.7) Β· Repo Β· Changelog

Release Notes

2.0.7

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ send (indirect, 0.15.1 β†’ 0.19.0) Β· Repo Β· Changelog

Security Advisories 🚨

🚨 send vulnerable to template injection that can lead to XSS

Impact

passing untrusted user input - even after sanitizing it - to SendStream.redirect() may execute untrusted code

Patches

this issue is patched in send 0.19.0

Workarounds

users are encouraged to upgrade to the patched version of express, but otherwise can workaround this issue by making sure any untrusted inputs are safe, ideally by validating them against an explicit allowlist

Details

successful exploitation of this vector requires the following:

  1. The attacker MUST control the input to response.redirect()
  2. express MUST NOT redirect before the template appears
  3. the browser MUST NOT complete redirection before:
  4. the user MUST click on the link in the template
Release Notes

0.19.0

What's Changed

  • Remove link renderization in html while redirecting (#235)

New Contributors

Full Changelog: 0.18.0...0.19.0

0.18.0 (from changelog)

0.17.2 (from changelog)

0.17.1 (from changelog)

  • Set stricter CSP header in redirect & error responses
  • deps: range-parser@~1.2.1

0.17.0 (from changelog)

  • deps: http-errors@~1.7.2
    • Set constructor name when possible
    • Use toidentifier module to make class names
    • deps: depd@~1.1.2
    • deps: [email protected]
    • deps: statuses@'>= 1.5.0 < 2'
  • deps: [email protected]
    • Add extensions for JPEG-2000 images
    • Add new font/* types from IANA
    • Add WASM mapping
    • Update .bdoc to application/bdoc
    • Update .bmp to image/bmp
    • Update .m4a to audio/mp4
    • Update .rtf to application/rtf
    • Update .wav to audio/wav
    • Update .xml to application/xml
    • Update generic extensions to application/octet-stream: .deb, .dll, .dmg, .exe, .iso, .msi
    • Use mime-score module to resolve extension conflicts
  • deps: [email protected]
    • Add week/w support
    • Fix negative number handling
  • deps: statuses@~1.5.0
  • perf: remove redundant path.normalize call

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ serve-static (indirect, 1.12.1 β†’ 1.16.2) Β· Repo Β· Changelog

Security Advisories 🚨

🚨 serve-static vulnerable to template injection that can lead to XSS

Impact

passing untrusted user input - even after sanitizing it - to redirect() may execute untrusted code

Patches

this issue is patched in serve-static 1.16.0

Workarounds

users are encouraged to upgrade to the patched version of express, but otherwise can workaround this issue by making sure any untrusted inputs are safe, ideally by validating them against an explicit allowlist

Details

successful exploitation of this vector requires the following:

  1. The attacker MUST control the input to response.redirect()
  2. express MUST NOT redirect before the template appears
  3. the browser MUST NOT complete redirection before:
  4. the user MUST click on the link in the template
Release Notes

1.16.0

What's Changed

  • Remove link renderization in html while redirecting (#173)

New Contributors

Full Changelog: v1.15.0...1.16.0

1.15.0

1.14.2

1.14.1 (from changelog)

  • Set stricter CSP header in redirect response
  • deps: [email protected]
    • deps: range-parser@~1.2.1

1.14.0

1.13.2

  • Fix incorrect end tag in redirects
  • deps: encodeurl@~1.0.2
    • Fix encoding % as last character
  • deps: [email protected]
    • deps: depd@~1.1.2
    • deps: encodeurl@~1.0.2
    • deps: statuses@~1.4.0

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ utils-merge (indirect, 1.0.0 β†’ 1.0.1) Β· Repo

Commits

See the full diff on Github. The new version differs by 13 commits:

πŸ†• call-bind (added, 1.0.8)

πŸ†• call-bind-apply-helpers (added, 1.0.1)

πŸ†• call-bound (added, 1.0.2)

πŸ†• define-data-property (added, 1.1.4)

πŸ†• dunder-proto (added, 1.0.0)

πŸ†• es-define-property (added, 1.0.1)

πŸ†• es-errors (added, 1.3.0)

πŸ†• es-object-atoms (added, 1.0.0)

πŸ†• get-intrinsic (added, 1.2.6)

πŸ†• gopd (added, 1.2.0)

πŸ†• has-property-descriptors (added, 1.0.2)

πŸ†• hasown (added, 2.0.2)

πŸ†• math-intrinsics (added, 1.0.0)

πŸ†• set-function-length (added, 1.2.2)

πŸ†• side-channel (added, 1.1.0)

πŸ†• side-channel-list (added, 1.0.0)

πŸ†• side-channel-map (added, 1.0.1)

πŸ†• side-channel-weakmap (added, 1.0.2)

πŸ†• toidentifier (added, 1.0.1)


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu cancel merge
Cancels automatic merging of this PR
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants