endpointlabs / VulnerableDotNetCore3Project

.Net Core 3.0
0 stars 0 forks source link

CVE-2024-45296 | path-to-regexp:0.1.7 #103

Open zisanyavuz opened 1 week ago

zisanyavuz commented 1 week ago

Due Date: 2024-09-11

A high severity vulnerability has been discovered in your project.

Project Name: qa6-after-update

Scanner Name: sbomradar

File: /src/packages/services/api/package-lock.json

Packages:

References:

Tool Description: ### Impact

In certain cases, path-to-regexp will output a regular expression that can be exploited to cause poor performance.

Patches

For users of 0.1, upgrade to 0.1.10. All other users should upgrade to 8.0.0.

Version 0.1.10 adds backtracking protection when a custom regular expression is not provided, so it's still possible to manually create a ReDoS vulnerability if you are providing custom regular expressions.

Version 8.0.0 removes all features that can cause a ReDoS and stops exposing the regular expression directly.

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

Because JavaScript is single threaded and regex matching runs on the main thread, poor performance will block the event loop and 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.

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

References

Custom Description: test

Kondukto Link: http://10.20.104.4/projects/66cc2e5e632415b4ae1e7906/vulns/appsec?page=1&perPage=15&id=in:66e025db10271169b2e2b086 Deeplink: There is no available deeplink