Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions regex-assembly/942420.ra
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
##!<
16 changes: 16 additions & 0 deletions regex-assembly/942421.ra
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
##!<
15 changes: 15 additions & 0 deletions regex-assembly/942430.ra
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
##!<
17 changes: 17 additions & 0 deletions regex-assembly/942431.ra
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
##!<
17 changes: 17 additions & 0 deletions regex-assembly/942432.ra
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
##!<
38 changes: 38 additions & 0 deletions regex-assembly/include/sql-special-chars-anomaly.ra
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 [^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'`<>]
Comment thread
fzipi marked this conversation as resolved.

##! 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
##!<
35 changes: 30 additions & 5 deletions rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,12 @@ SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES|REQUEST_HEADERS|ARGS_NAMES|ARGS|XM
# SecRuleUpdateTargetById 942430 "!ARGS:foo"
#

Comment thread
fzipi marked this conversation as resolved.
SecRule ARGS_NAMES|ARGS|XML:/* "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){12})" \
# Regular expression generated from regex-assembly/942430.ra.
# To update the regular expression run the following shell script
# (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
# crs-toolchain regex update 942430
#
SecRule ARGS_NAMES|ARGS|XML:/* "@rx ((?:(?:[!-\+\-:->@\[\]\^`\{-~]|\x{c2}\x{b4}|\x{e2}\x80[\x98\x99])[^!-\+\-:->@\[\]\^`\{-~]*?){12})" \
"id:942430,\
phase:2,\
block,\
Expand Down Expand Up @@ -1725,7 +1730,12 @@ SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx [\"'`]
# SecRuleUpdateTargetById 942420 "!REQUEST_COOKIES:foo_id"
#

SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){8})" \
# Regular expression generated from regex-assembly/942420.ra.
# To update the regular expression run the following shell script
# (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
# crs-toolchain regex update 942420
#
SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES "@rx ((?:(?:[!-\+\-:->@\[\]\^`\{-~]|\x{c2}\x{b4}|\x{e2}\x80[\x98\x99])[^!-\+\-:->@\[\]\^`\{-~]*?){8})" \
"id:942420,\
phase:1,\
block,\
Expand Down Expand Up @@ -1754,7 +1764,12 @@ SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\
# [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
#

SecRule ARGS_NAMES|!ARGS_NAMES:/^[\w]+\[[\w\-]+\]\[[\w\-]*?\]$/|!ARGS_NAMES:/^[\w]+\[[\w\-]+\]\[[\w\-]+\]\[[\w\-]*?\]$/|ARGS|XML:/* "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){6})" \
# Regular expression generated from regex-assembly/942431.ra.
# To update the regular expression run the following shell script
# (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
# crs-toolchain regex update 942431
#
SecRule ARGS_NAMES|!ARGS_NAMES:/^[\w]+\[[\w\-]+\]\[[\w\-]*?\]$/|!ARGS_NAMES:/^[\w]+\[[\w\-]+\]\[[\w\-]+\]\[[\w\-]*?\]$/|ARGS|XML:/* "@rx ((?:(?:[!-\+\-:->@\[\]\^`\{-~]|\x{c2}\x{b4}|\x{e2}\x80[\x98\x99])[^!-\+\-:->@\[\]\^`\{-~]*?){6})" \
"id:942431,\
phase:2,\
block,\
Expand Down Expand Up @@ -1907,7 +1922,12 @@ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 4" "id:942018,phase:2,pass,nolog,tag:'O
# This is a stricter sibling of rule 942420.
#

SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){3})" \
# Regular expression generated from regex-assembly/942421.ra.
# To update the regular expression run the following shell script
# (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
# crs-toolchain regex update 942421
#
SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES "@rx ((?:(?:[!-\+\-:->@\[\]\^`\{-~]|\x{c2}\x{b4}|\x{e2}\x80[\x98\x99])[^!-\+\-:->@\[\]\^`\{-~]*?){3})" \
"id:942421,\
phase:1,\
block,\
Expand Down Expand Up @@ -1936,7 +1956,12 @@ SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\
# [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
#

SecRule ARGS_NAMES|ARGS|XML:/* "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){2})" \
# Regular expression generated from regex-assembly/942432.ra.
# To update the regular expression run the following shell script
# (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
# crs-toolchain regex update 942432
#
SecRule ARGS_NAMES|ARGS|XML:/* "@rx ((?:(?:[!-\+\-:->@\[\]\^`\{-~]|\x{c2}\x{b4}|\x{e2}\x80[\x98\x99])[^!-\+\-:->@\[\]\^`\{-~]*?){2})" \
"id:942432,\
phase:2,\
block,\
Expand Down
Loading
Loading