BugFix:Regular Expression in parseDuration Function #5554
Closed
+47
−1
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.
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma
Tick the checkbox if you understand [x]:
Description
Fixes #(5553)
Original Issue Summary:
A Regular Expression Denial of Service (ReDoS) vulnerability existed in the
parseDuration
function due to an inefficient regular expression:This vulnerability allowed an attacker to exploit catastrophic backtracking by providing specially crafted input, potentially leading to excessive CPU consumption and service unavailability.
The vulnerability was identified in the
@uptime-kuma/server/modules/apicache/apicache.js
file. The issue is discussed in the corresponding gist link: ReDos in @uptime-kuma/server/modules/apicache /apicache.js.Solution:
The issue was resolved by updating the regular expression to:
This new regular expression eliminates the possibility of catastrophic backtracking and resolves the ReDoS vulnerability. The fix has been successfully tested and confirmed not to affect the existing project structure. The test file can be found at:
test/backend-test/test-apicache-ReDos.js.
Type of change
Checklist
Screenshots (if any)