-
-
Notifications
You must be signed in to change notification settings - Fork 456
fix: handle multi-byte UTF-8 chars in SQL special char detection #4458
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ##! Please refer to the documentation at | ||
| ##! https://coreruleset.org/docs/development/regex_assembly/. | ||
|
|
||
| ##! Rule 942420: Restricted SQL Character Anomaly Detection (cookies) | ||
| ##! Matches when 8 or more special characters appear. | ||
| ##! See: https://github.com/coreruleset/coreruleset/issues/3325 | ||
|
|
||
| ##!> include sql-special-chars-anomaly | ||
|
|
||
| ##!^ ( | ||
| ##!$ {8}) | ||
|
|
||
| ##!> assemble | ||
| ##!=> sql-special-chars-anomaly | ||
| ##!< |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ##! Please refer to the documentation at | ||
| ##! https://coreruleset.org/docs/development/regex_assembly/. | ||
|
|
||
| ##! Rule 942421: Restricted SQL Character Anomaly Detection (cookies) | ||
| ##! Stricter sibling of rule 942420 (PL4). | ||
| ##! Matches when 3 or more special characters appear. | ||
| ##! See: https://github.com/coreruleset/coreruleset/issues/3325 | ||
|
|
||
| ##!> include sql-special-chars-anomaly | ||
|
|
||
| ##!^ ( | ||
| ##!$ {3}) | ||
|
|
||
| ##!> assemble | ||
| ##!=> sql-special-chars-anomaly | ||
| ##!< |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ##! Please refer to the documentation at | ||
| ##! https://coreruleset.org/docs/development/regex_assembly/. | ||
|
|
||
| ##! Rule 942430: Restricted SQL Character Anomaly Detection (args) | ||
| ##! Matches when 12 or more special characters appear. | ||
| ##! See: https://github.com/coreruleset/coreruleset/issues/3325 | ||
|
|
||
| ##!> include sql-special-chars-anomaly | ||
|
|
||
| ##!^ ( | ||
| ##!$ {12}) | ||
|
|
||
| ##!> assemble | ||
| ##!=> sql-special-chars-anomaly | ||
| ##!< |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ##! Please refer to the documentation at | ||
| ##! https://coreruleset.org/docs/development/regex_assembly/. | ||
|
|
||
| ##! Rule 942431: Restricted SQL Character Anomaly Detection (args) | ||
| ##! Stricter sibling of rule 942430 (PL3). | ||
| ##! Matches when 6 or more special characters appear. | ||
| ##! Also triggered by: SAP CRM Java vulnerability CVE-2018-2380 | ||
| ##! See: https://github.com/coreruleset/coreruleset/issues/3325 | ||
|
|
||
| ##!> include sql-special-chars-anomaly | ||
|
|
||
| ##!^ ( | ||
| ##!$ {6}) | ||
|
|
||
| ##!> assemble | ||
| ##!=> sql-special-chars-anomaly | ||
| ##!< |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ##! Please refer to the documentation at | ||
| ##! https://coreruleset.org/docs/development/regex_assembly/. | ||
|
|
||
| ##! Rule 942432: Restricted SQL Character Anomaly Detection (args) | ||
| ##! Stricter sibling of rule 942430 (PL4). | ||
| ##! Matches when 2 or more special characters appear. | ||
| ##! Also triggered by: SAP CRM Java vulnerability CVE-2018-2380 | ||
| ##! See: https://github.com/coreruleset/coreruleset/issues/3325 | ||
|
|
||
| ##!> include sql-special-chars-anomaly | ||
|
|
||
| ##!^ ( | ||
| ##!$ {2}) | ||
|
|
||
| ##!> assemble | ||
| ##!=> sql-special-chars-anomaly | ||
| ##!< |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| ##! Please refer to the documentation at | ||
| ##! https://coreruleset.org/docs/development/regex_assembly/. | ||
|
|
||
| ##! Shared definitions for the SQL special character anomaly detection rules | ||
| ##! (942420, 942421, 942430, 942431, 942432). | ||
| ##! | ||
| ##! These rules detect SQL injection attempts by counting special characters. | ||
| ##! | ||
| ##! UTF-8 multi-byte characters (U+00B4, U+2018, U+2019) are specified as | ||
| ##! alternations outside character classes to prevent byte-by-byte matching | ||
| ##! which causes false positives with non-Latin scripts. | ||
| ##! See: https://github.com/coreruleset/coreruleset/issues/3325 | ||
|
|
||
| ##! ASCII special characters commonly used in SQL injection. | ||
| ##!> define ascii-special [~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'`<>] | ||
|
|
||
| ##! Negated ASCII class (multi-byte bytes pass through as non-special) | ||
| ##!> define non-special [^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'`<>] | ||
|
|
||
| ##! Special character alternation: ASCII class plus UTF-8 quote-like chars | ||
| ##! U+00B4 ACUTE ACCENT -> \xC2\xB4 | ||
| ##! U+2018 LEFT SINGLE QUOTATION -> \xE2\x80\x98 | ||
| ##! U+2019 RIGHT SINGLE QUOTATION -> \xE2\x80\x99 | ||
| ##!> assemble | ||
| {{ascii-special}} | ||
| \xC2\xB4 | ||
| \xE2\x80\x98 | ||
| \xE2\x80\x99 | ||
| ##!=< sql-special-chars | ||
| ##!< | ||
|
|
||
| ##! Full anomaly unit: one special char followed by any non-special chars | ||
| ##!> assemble | ||
| ##!=> sql-special-chars | ||
| ##!=> | ||
| {{non-special}}*? | ||
| ##!=< sql-special-chars-anomaly | ||
| ##!< | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.