Improved version of #2568 #2603
Merged
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.
This is experiment PR to improve false-positive rate in #2568. The rule is split into 3 parts:
#942520 - blocks SQL Auth bypasses with expressions resulting in low-false-positive rates.
#942521 - adds expressions for detecting
(and|or)
preceded with an odd number of quotes.#942522 - adds an expression for detecting bypass to #942521 with escaped quotes.
PL2 942520
The below expressions were proved to yield very little false-positives.
PL2 942521
This is a quite expensive regular expression for detecting odd number of quotes. It uses the principal of
b*a*(b*a*b*a*)*
which is a formal definition of odd number of a's. It's a chained rule that will only capture the first word after the odd number of quotes and then check if it's (and|or). This rule doesn't cause ReDos, but it might be quite expensive as test server sometimes times out for the input".'"*9800+"or"
. I added two smaller performance tests (~1k quotes). It should take linearly many steps in regards to number of input characters. link.This only should be an expensive expression for malicious payloads with lots of quotes
PL2 942522
This rule is quite simple. It will detect if there is any sequence of escaped quote (
\'
) followed by'?(and|or)
. Without this rule #942521 could be easilly bypassed@lifeforms