fix: sanitize metadata search regex to prevent ReDoS#6137
Open
RinZ27 wants to merge 1 commit intoscality:development/9.2from
Open
fix: sanitize metadata search regex to prevent ReDoS#6137RinZ27 wants to merge 1 commit intoscality:development/9.2from
RinZ27 wants to merge 1 commit intoscality:development/9.2from
Conversation
Signed-off-by: RinZ27 <222222878+RinZ27@users.noreply.github.com>
Contributor
Hello rinz27,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Author
|
/approve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Motivation and context
Fixes a potential ReDoS (Regular Expression Denial of Service) in the metadata search logic. The current implementation in parseLikeExpression directly uses raw user input to create new RegExp objects, which I noticed could lead to catastrophic backtracking. By escaping special regex characters, we ensure that the input is treated as a literal string, effectively neutralizing malicious patterns while maintaining expected functionality for LIKE queries.
Everything is green locally, and I verified the fix with a reproduction script that reduced execution time for a malicious payload from over 138 seconds to 0ms.
Related issues
N/A
Checklist
Add tests to cover the changes
Verified with a standalone reproduction script.
Code conforms with the style guide
Yes.
Sign your work
Signed-off.
Thank you again for contributing! We will try to test and integrate the change as soon as we can.