Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit e0bea23

Browse files
fgschdune73
authored andcommitted
Pattern cleanup across several rules (#1643)
* Drop unneeded non-capture groups * No need to escape "-" outside character classes And only if it is not at the end. * Improve rule 941350 Previously, this rule will also match on the equivalent to "<..<". Rewrite it so it is only triggered by the equivalent to "<..>", simplifying the pattern quite a bit as a bonus. While here add a link describing the bypass for future reference. * Fix test Was using the equivalent to "<...<" instead of "<...>".
1 parent aec3f39 commit e0bea23

File tree

7 files changed

+11
-10
lines changed

7 files changed

+11
-10
lines changed

rules/REQUEST-903.9002-WORDPRESS-EXCLUSION-RULES.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ SecRule REQUEST_FILENAME "@endsWith /wp-comments-post.php" \
8989
#
9090

9191
# Gutenberg
92-
SecRule REQUEST_FILENAME "@rx ^/wp\-json/wp/v[0-9]+/(?:posts|pages)" \
92+
SecRule REQUEST_FILENAME "@rx ^/wp-json/wp/v[0-9]+/(?:posts|pages)" \
9393
"id:9002140,\
9494
phase:1,\
9595
pass,\

rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ SecRule REQUEST_METHOD "@rx ^POST$" \
266266
# https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
267267
# http://seclists.org/fulldisclosure/2011/Aug/175
268268
#
269-
SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx (\d+)\-(\d+)\," \
269+
SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx (\d+)-(\d+)\," \
270270
"id:920190,\
271271
phase:2,\
272272
block,\
@@ -1135,7 +1135,7 @@ SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 2" "id:920014,phase:2,pass,nolog,skipAf
11351135
# https://httpd.apache.org/security/CVE-2011-3192.txt
11361136

11371137

1138-
SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=(?:(?:\d+)?\-(?:\d+)?\s*,?\s*){6}" \
1138+
SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=(?:(?:\d+)?-(?:\d+)?\s*,?\s*){6}" \
11391139
"id:920200,\
11401140
phase:2,\
11411141
block,\
@@ -1176,7 +1176,7 @@ SecRule REQUEST_BASENAME "@endsWith .pdf" \
11761176
ver:'OWASP_CRS/3.2.0',\
11771177
severity:'WARNING',\
11781178
chain"
1179-
SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=(?:(?:\d+)?\-(?:\d+)?\s*,?\s*){63}" \
1179+
SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=(?:(?:\d+)?-(?:\d+)?\s*,?\s*){63}" \
11801180
"setvar:'tx.anomaly_score_pl2=+%{tx.warning_anomaly_score}'"
11811181

11821182

@@ -1419,7 +1419,7 @@ SecRule REQUEST_BASENAME "@endsWith .pdf" \
14191419
ver:'OWASP_CRS/3.2.0',\
14201420
severity:'WARNING',\
14211421
chain"
1422-
SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=(?:(?:\d+)?\-(?:\d+)?\s*,?\s*){6}" \
1422+
SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=(?:(?:\d+)?-(?:\d+)?\s*,?\s*){6}" \
14231423
"setvar:'tx.anomaly_score_pl4=+%{tx.warning_anomaly_score}'"
14241424

14251425

rules/REQUEST-921-PROTOCOL-ATTACK.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ SecRule ARGS_NAMES "@rx [\n\r]" \
171171
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
172172

173173

174-
SecRule ARGS_GET_NAMES|ARGS_GET "@rx (?:\n|\r)+(?:\s|location|refresh|(?:set-)?cookie|(?:x-)?(?:forwarded-(?:for|host|server)|host|via|remote-ip|remote-addr|originating-IP))\s*:" \
174+
SecRule ARGS_GET_NAMES|ARGS_GET "@rx [\n\r]+(?:\s|location|refresh|(?:set-)?cookie|(?:x-)?(?:forwarded-(?:for|host|server)|host|via|remote-ip|remote-addr|originating-IP))\s*:" \
175175
"id:921160,\
176176
phase:1,\
177177
block,\

rules/REQUEST-941-APPLICATION-ATTACK-XSS.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,12 @@ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAME
646646
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
647647

648648
#
649+
# https://nedbatchelder.com/blog/200704/xss_with_utf7.html
649650
# UTF-7 encoding XSS filter evasion for IE.
650651
# Reported by Vladimir Ivanov
651652
#
652653

653-
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?:\+ADw\-|\+AD4\-).*(?:\+ADw\-|\+AD4\-|>)|(?:\+ADw\-|\+AD4\-|<).*(?:\+ADw\-|\+AD4\-)" \
654+
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx \+ADw-.*(?:\+AD4-|>)|<.*\+AD4-" \
654655
"id:941350,\
655656
phase:2,\
656657
block,\

rules/RESPONSE-951-DATA-LEAKAGES-SQL.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ SecRule TX:sql_error_match "@eq 1" \
348348
ver:'OWASP_CRS/3.2.0',\
349349
severity:'CRITICAL',\
350350
chain"
351-
SecRule RESPONSE_BODY "@rx (?i)(?:System\.Data\.OleDb\.OleDbException|\[Microsoft\]\[ODBC SQL Server Driver\]|\[Macromedia\]\[SQLServer JDBC Driver\]|\[SqlException|System\.Data\.SqlClient\.SqlException|Unclosed quotation mark after the character string|'80040e14'|mssql_query\(\)|Microsoft OLE DB Provider for ODBC Drivers|Microsoft OLE DB Provider for SQL Server|Incorrect syntax near|Sintaxis incorrecta cerca de|Syntax error in string in query expression|Procedure or function .* expects parameter|Unclosed quotation mark before the character string|Syntax error .* in query expression|Data type mismatch in criteria expression\.|ADODB\.Field \(0x800A0BCD\)|the used select statements have different number of columns|OLE DB.*SQL Server|Warning.*mssql_.*|Driver.*SQL[\-\_\ ]*Server|SQL Server.*Driver|SQL Server.*[0-9a-fA-F]{8}|Exception.*\WSystem\.Data\.SqlClient\.)" \
351+
SecRule RESPONSE_BODY "@rx (?i)(?:System\.Data\.OleDb\.OleDbException|\[Microsoft\]\[ODBC SQL Server Driver\]|\[Macromedia\]\[SQLServer JDBC Driver\]|\[SqlException|System\.Data\.SqlClient\.SqlException|Unclosed quotation mark after the character string|'80040e14'|mssql_query\(\)|Microsoft OLE DB Provider for ODBC Drivers|Microsoft OLE DB Provider for SQL Server|Incorrect syntax near|Sintaxis incorrecta cerca de|Syntax error in string in query expression|Procedure or function .* expects parameter|Unclosed quotation mark before the character string|Syntax error .* in query expression|Data type mismatch in criteria expression\.|ADODB\.Field \(0x800A0BCD\)|the used select statements have different number of columns|OLE DB.*SQL Server|Warning.*mssql_.*|Driver.*SQL[ _-]*Server|SQL Server.*Driver|SQL Server.*[0-9a-fA-F]{8}|Exception.*\WSystem\.Data\.SqlClient\.)" \
352352
"capture,\
353353
setvar:'tx.outbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}',\
354354
setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\

rules/RESPONSE-953-DATA-LEAKAGES-PHP.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ SecRule RESPONSE_BODY "@rx <\?(?!xml)" \
106106
ver:'OWASP_CRS/3.2.0',\
107107
severity:'ERROR',\
108108
chain"
109-
SecRule RESPONSE_BODY "!@rx (?:\x1f\x8b\x08|\b(?:(?:i(?:nterplay|hdr|d3)|m(?:ovi|thd)|r(?:ar!|iff)|(?:ex|jf)if|f(?:lv|ws)|varg|cws)\b|gif)|B(?:%pdf|\.ra)\b|^wOF(?:F|2))" \
109+
SecRule RESPONSE_BODY "!@rx (?:\x1f\x8b\x08|\b(?:(?:i(?:nterplay|hdr|d3)|m(?:ovi|thd)|r(?:ar!|iff)|(?:ex|jf)if|f(?:lv|ws)|varg|cws)\b|gif)|B(?:%pdf|\.ra)\b|^wOF[F2])" \
110110
"capture,\
111111
t:none,\
112112
setvar:'tx.outbound_anomaly_score_pl1=+%{tx.error_anomaly_score}',\

tests/regression/tests/REQUEST-941-APPLICATION-ATTACK-XSS/941350.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
dest_addr: 127.0.0.1
1616
method: GET
1717
port: 80
18-
uri: /xx?id=%25252bADw-script%25252bADw-
18+
uri: /xx?id=%25252bADw-script%25252bAD4-
1919
headers:
2020
Accept: "*/*"
2121
Host: localhost

0 commit comments

Comments
 (0)