@abtnode/router-provider 1.16.38-beta-20250115-235439-bb5a1c1b → 1.16.38-beta-20250118-033334-2da05ae8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/lib/nginx/includes/security/crs4/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf.example +200 -0
  2. package/lib/nginx/includes/security/crs4/rules/REQUEST-901-INITIALIZATION.conf +470 -0
  3. package/lib/nginx/includes/security/crs4/rules/REQUEST-905-COMMON-EXCEPTIONS.conf +57 -0
  4. package/lib/nginx/includes/security/crs4/rules/REQUEST-911-METHOD-ENFORCEMENT.conf +76 -0
  5. package/lib/nginx/includes/security/crs4/rules/REQUEST-913-SCANNER-DETECTION.conf +86 -0
  6. package/lib/nginx/includes/security/crs4/rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf +1915 -0
  7. package/lib/nginx/includes/security/crs4/rules/REQUEST-921-PROTOCOL-ATTACK.conf +558 -0
  8. package/lib/nginx/includes/security/crs4/rules/REQUEST-922-MULTIPART-ATTACK.conf +120 -0
  9. package/lib/nginx/includes/security/crs4/rules/REQUEST-930-APPLICATION-ATTACK-LFI.conf +203 -0
  10. package/lib/nginx/includes/security/crs4/rules/REQUEST-931-APPLICATION-ATTACK-RFI.conf +189 -0
  11. package/lib/nginx/includes/security/crs4/rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf +1875 -0
  12. package/lib/nginx/includes/security/crs4/rules/REQUEST-933-APPLICATION-ATTACK-PHP.conf +774 -0
  13. package/lib/nginx/includes/security/crs4/rules/REQUEST-934-APPLICATION-ATTACK-GENERIC.conf +366 -0
  14. package/lib/nginx/includes/security/crs4/rules/REQUEST-941-APPLICATION-ATTACK-XSS.conf +1071 -0
  15. package/lib/nginx/includes/security/crs4/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf +1978 -0
  16. package/lib/nginx/includes/security/crs4/rules/REQUEST-943-APPLICATION-ATTACK-SESSION-FIXATION.conf +132 -0
  17. package/lib/nginx/includes/security/crs4/rules/REQUEST-944-APPLICATION-ATTACK-JAVA.conf +463 -0
  18. package/lib/nginx/includes/security/crs4/rules/REQUEST-949-BLOCKING-EVALUATION.conf +270 -0
  19. package/lib/nginx/includes/security/crs4/rules/RESPONSE-950-DATA-LEAKAGES.conf +156 -0
  20. package/lib/nginx/includes/security/crs4/rules/RESPONSE-951-DATA-LEAKAGES-SQL.conf +417 -0
  21. package/lib/nginx/includes/security/crs4/rules/RESPONSE-952-DATA-LEAKAGES-JAVA.conf +108 -0
  22. package/lib/nginx/includes/security/crs4/rules/RESPONSE-953-DATA-LEAKAGES-PHP.conf +158 -0
  23. package/lib/nginx/includes/security/crs4/rules/RESPONSE-954-DATA-LEAKAGES-IIS.conf +152 -0
  24. package/lib/nginx/includes/security/crs4/rules/RESPONSE-955-WEB-SHELLS.conf +558 -0
  25. package/lib/nginx/includes/security/crs4/rules/RESPONSE-959-BLOCKING-EVALUATION.conf +280 -0
  26. package/lib/nginx/includes/security/crs4/rules/RESPONSE-980-CORRELATION.conf +138 -0
  27. package/lib/nginx/includes/security/crs4/rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example +76 -0
  28. package/lib/nginx/includes/security/crs4/rules/iis-errors.data +59 -0
  29. package/lib/nginx/includes/security/crs4/rules/java-classes.data +64 -0
  30. package/lib/nginx/includes/security/crs4/rules/java-code-leakages.data +17 -0
  31. package/lib/nginx/includes/security/crs4/rules/java-errors.data +10 -0
  32. package/lib/nginx/includes/security/crs4/rules/lfi-os-files.data +722 -0
  33. package/lib/nginx/includes/security/crs4/rules/php-config-directives.data +571 -0
  34. package/lib/nginx/includes/security/crs4/rules/php-errors-pl2.data +7 -0
  35. package/lib/nginx/includes/security/crs4/rules/php-errors.data +2147 -0
  36. package/lib/nginx/includes/security/crs4/rules/php-function-names-933150.data +245 -0
  37. package/lib/nginx/includes/security/crs4/rules/php-function-names-933151.data +2201 -0
  38. package/lib/nginx/includes/security/crs4/rules/php-variables.data +30 -0
  39. package/lib/nginx/includes/security/crs4/rules/restricted-files.data +284 -0
  40. package/lib/nginx/includes/security/crs4/rules/restricted-upload.data +177 -0
  41. package/lib/nginx/includes/security/crs4/rules/scanners-user-agents.data +119 -0
  42. package/lib/nginx/includes/security/crs4/rules/sql-errors.data +172 -0
  43. package/lib/nginx/includes/security/crs4/rules/ssrf.data +177 -0
  44. package/lib/nginx/includes/security/crs4/rules/unix-shell.data +670 -0
  45. package/lib/nginx/includes/security/crs4/rules/web-shells-php.data +167 -0
  46. package/lib/nginx/includes/security/crs4/rules/windows-powershell-commands.data +425 -0
  47. package/lib/nginx/includes/security/unicode.mapping +96 -0
  48. package/lib/nginx/index.js +50 -3
  49. package/lib/nginx/templates/security/crs4/crs-setup.conf.js +857 -0
  50. package/lib/nginx/templates/security/modsecurity.conf.js +244 -0
  51. package/package.json +7 -6
@@ -0,0 +1,1978 @@
1
+ # ------------------------------------------------------------------------
2
+ # OWASP CRS ver.4.9.0
3
+ # Copyright (c) 2006-2020 Trustwave and contributors. All rights reserved.
4
+ # Copyright (c) 2021-2024 CRS project. All rights reserved.
5
+ #
6
+ # The OWASP CRS is distributed under
7
+ # Apache Software License (ASL) version 2
8
+ # Please see the enclosed LICENSE file for full details.
9
+ # ------------------------------------------------------------------------
10
+
11
+ #
12
+ # -= Paranoia Level 0 (empty) =- (apply unconditionally)
13
+ #
14
+
15
+
16
+
17
+ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 1" "id:942011,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.9.0',skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
18
+ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 1" "id:942012,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.9.0',skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
19
+ #
20
+ # -= Paranoia Level 1 (default) =- (apply only when tx.detection_paranoia_level is sufficiently high: 1 or higher)
21
+ #
22
+
23
+ #
24
+ # References:
25
+ #
26
+ # SQL Injection Knowledgebase (via @LightOS) -
27
+ # http://websec.ca/kb/sql_injection
28
+ #
29
+ # SQLi Filter Evasion Cheat Sheet -
30
+ # http://websec.wordpress.com/2010/12/04/sqli-filter-evasion-cheat-sheet-mysql/
31
+ #
32
+ # SQL Injection Cheat Sheet -
33
+ # http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/
34
+ #
35
+ # SQLMap's Tamper Scripts (for evasions)
36
+ # https://github.com/sqlmapproject/sqlmap
37
+ #
38
+
39
+ #
40
+ # -=[ LibInjection Check ]=-
41
+ #
42
+ # There is a stricter sibling of this rule at 942101. It covers REQUEST_BASENAME and REQUEST_FILENAME.
43
+ #
44
+ # Ref: https://github.com/libinjection/libinjection
45
+ #
46
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|REQUEST_HEADERS:User-Agent|REQUEST_HEADERS:Referer|ARGS_NAMES|ARGS|XML:/* "@detectSQLi" \
47
+ "id:942100,\
48
+ phase:2,\
49
+ block,\
50
+ capture,\
51
+ t:none,t:utf8toUnicode,t:urlDecodeUni,t:removeNulls,\
52
+ msg:'SQL Injection Attack Detected via libinjection',\
53
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
54
+ tag:'application-multi',\
55
+ tag:'language-multi',\
56
+ tag:'platform-multi',\
57
+ tag:'attack-sqli',\
58
+ tag:'paranoia-level/1',\
59
+ tag:'OWASP_CRS',\
60
+ tag:'capec/1000/152/248/66',\
61
+ tag:'PCI/6.5.2',\
62
+ ver:'OWASP_CRS/4.9.0',\
63
+ severity:'CRITICAL',\
64
+ multiMatch,\
65
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}',\
66
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}'"
67
+
68
+
69
+ #
70
+ # -=[ Detect DB Names ]=-
71
+ #
72
+ # Regular expression generated from regex-assembly/942140.ra.
73
+ # To update the regular expression run the following shell script
74
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
75
+ # crs-toolchain regex update 942140
76
+ #
77
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\b(?:d(?:atabas|b_nam)e[^0-9A-Z_a-z]*\(|(?:information_schema|m(?:aster\.\.sysdatabases|s(?:db|ys(?:ac(?:cess(?:objects|storage|xml)|es)|modules2?|(?:object|querie|relationship)s))|ysql\.db)|northwind|pg_(?:catalog|toast)|tempdb)\b|s(?:chema(?:_name\b|[^0-9A-Z_a-z]*\()|(?:qlite_(?:temp_)?master|ys(?:aux|\.database_name))\b))" \
78
+ "id:942140,\
79
+ phase:2,\
80
+ block,\
81
+ capture,\
82
+ t:none,t:urlDecodeUni,\
83
+ msg:'SQL Injection Attack: Common DB Names Detected',\
84
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
85
+ tag:'application-multi',\
86
+ tag:'language-multi',\
87
+ tag:'platform-multi',\
88
+ tag:'attack-sqli',\
89
+ tag:'paranoia-level/1',\
90
+ tag:'OWASP_CRS',\
91
+ tag:'capec/1000/152/248/66',\
92
+ tag:'PCI/6.5.2',\
93
+ ver:'OWASP_CRS/4.9.0',\
94
+ severity:'CRITICAL',\
95
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
96
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
97
+
98
+
99
+ #
100
+ # -=[ SQL Function Names ]=-
101
+ #
102
+ # This rule has a stricter sibling to this rule (942152) that checks for SQL function names in
103
+ # request headers referer and user-agent.
104
+ #
105
+ # Regular expression generated from regex-assembly/942151.ra.
106
+ # To update the regular expression run the following shell script
107
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
108
+ # crs-toolchain regex update 942151
109
+ #
110
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\b(?:a(?:dd(?:dat|tim)e|es_(?:de|en)crypt|s(?:cii(?:str)?|in)|tan2?)|b(?:enchmark|i(?:n_to_num|t_(?:and|count|length|x?or)))|c(?:har(?:acter)?_length|iel(?:ing)?|o(?:alesce|ercibility|llation|(?:mpres)?s|n(?:cat(?:_ws)?|nection_id|v(?:ert(?:_tz)?)?)|t)|r32|ur(?:(?:dat|tim)e|rent_(?:date|setting|time(?:stamp)?|user)))|d(?:a(?:t(?:abase(?:_to_xml)?|e(?:_(?:add|format|sub)|diff))|y(?:name|of(?:month|week|year)))|count|e(?:code|grees|s_(?:de|en)crypt)|ump)|e(?:lt|n(?:c(?:ode|rypt)|ds_?with)|x(?:p(?:ort_set)?|tract(?:value)?))|f(?:i(?:el|n)d_in_set|ound_rows|rom_(?:base64|days|unixtime))|g(?:e(?:ometrycollection|t(?:_(?:format|lock)|pgusername))|(?:r(?:eates|oup_conca)|tid_subse)t)|hex(?:toraw)?|i(?:fnull|n(?:et6?_(?:aton|ntoa)|s(?:ert|tr)|terval)|s(?:_(?:(?:free|used)_lock|ipv(?:4(?:_(?:compat|mapped))?|6)|n(?:ot(?:_null)?|ull)|superuser)|null))|json(?:_(?:a(?:gg|rray(?:_(?:elements(?:_text)?|length))?)|build_(?:array|object)|e(?:ac|xtract_pat)h(?:_text)?|object(?:_(?:agg|keys))?|populate_record(?:set)?|strip_nulls|t(?:o_record(?:set)?|ypeof))|b(?:_(?:array(?:_(?:elements(?:_text)?|length))?|build_(?:array|object)|object(?:_(?:agg|keys))?|e(?:ac|xtract_pat)h(?:_text)?|insert|p(?:ath_(?:(?:exists|match)(?:_tz)?|query(?:_(?:(?:array|first)(?:_tz)?|tz))?)|opulate_record(?:set)?|retty)|s(?:et(?:_lax)?|trip_nulls)|t(?:o_record(?:set)?|ypeof)))?|path)?|l(?:ast_(?:day|inser_id)|case|e(?:as|f)t|i(?:kel(?:ihood|y)|nestring)|o(?:_(?:from_bytea|put)|ad_file|ca(?:ltimestamp|te)|g(?:10|2)|wer)|pad|trim)|m(?:a(?:ke(?:_set|date)|ster_pos_wait)|d5|i(?:crosecon)?d|onthname|ulti(?:linestring|po(?:int|lygon)))|n(?:ame_const|ot_in|ullif)|o(?:ct(?:et_length)?|(?:ld_passwo)?rd)|p(?:eriod_(?:add|diff)|g_(?:client_encoding|(?:databas|read_fil)e|l(?:argeobject|s_dir)|sleep|user)|o(?:(?:lyg|siti)on|w)|rocedure_analyse)|qu(?:arter|ery_to_xml|ote)|r(?:a(?:dians|nd|wtohex)|elease_lock|ow_(?:count|to_json)|pad|trim)|s(?:chema|e(?:c_to_time|ssion_user)|ha[12]?|in|oundex|pace|q(?:lite_(?:compileoption_(?:get|used)|source_id)|rt)|t(?:arts_?with|d(?:dev_(?:po|sam)p)?|r(?:_to_date|cmp))|ub(?:(?:dat|tim)e|str(?:ing(?:_index)?)?)|ys(?:date|tem_user))|t(?:ime(?:_(?:format|to_sec)|diff|stamp(?:add|diff)?)|o(?:_(?:base64|jsonb?)|n?char|(?:day|second)s)|r(?:im|uncate))|u(?:case|n(?:compress(?:ed_length)?|hex|i(?:str|x_timestamp)|likely)|(?:pdatexm|se_json_nul)l|tc_(?:date|time(?:stamp)?)|uid(?:_short)?)|var(?:_(?:po|sam)p|iance)|we(?:ek(?:day|ofyear)|ight_string)|xmltype|yearweek)[^0-9A-Z_a-z]*\(" \
111
+ "id:942151,\
112
+ phase:2,\
113
+ block,\
114
+ capture,\
115
+ t:none,t:urlDecodeUni,\
116
+ msg:'SQL Injection Attack: SQL function name detected',\
117
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
118
+ tag:'application-multi',\
119
+ tag:'language-multi',\
120
+ tag:'platform-multi',\
121
+ tag:'attack-sqli',\
122
+ tag:'paranoia-level/1',\
123
+ tag:'OWASP_CRS',\
124
+ tag:'capec/1000/152/248/66',\
125
+ tag:'PCI/6.5.2',\
126
+ ver:'OWASP_CRS/4.9.0',\
127
+ severity:'CRITICAL',\
128
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
129
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
130
+
131
+
132
+ #
133
+ # -=[ PHPIDS - Converted SQLI Filters ]=-
134
+ #
135
+ # https://raw.githubusercontent.com/PHPIDS/PHPIDS/master/lib/IDS/default_filter.xml
136
+ #
137
+ # The rule 942160 prevents time-based blind SQL injection attempts
138
+ # by prohibiting sleep() or benchmark(,) functions:
139
+ #
140
+ # * The sleep command takes a number of seconds as an argument.
141
+ # * The benchmark command executes the specified expression multiple times.
142
+ #
143
+ # Using a long sleep time or high number of executions, you can create a delay
144
+ # with the response from the server. This allows to determine whether the
145
+ # query has been executed or not. A high response time proves that the SQLi
146
+ # worked successfully. It can now be equipped with the real payload.
147
+ #
148
+ # Therefore this rule does not prevent the attack itself, but blocks an
149
+ # attacker from using the standard utils to tinker with blind SQLi.
150
+ #
151
+ # A positive side effect is that it prevents certain DoS attacks via the directives
152
+ # described above.
153
+ #
154
+ SecRule REQUEST_FILENAME|REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i:sleep\(\s*?\d*?\s*?\)|benchmark\(.*?\,.*?\))" \
155
+ "id:942160,\
156
+ phase:2,\
157
+ block,\
158
+ capture,\
159
+ t:none,t:urlDecodeUni,\
160
+ t:replaceComments,\
161
+ msg:'Detects blind sqli tests using sleep() or benchmark()',\
162
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
163
+ tag:'application-multi',\
164
+ tag:'language-multi',\
165
+ tag:'platform-multi',\
166
+ tag:'attack-sqli',\
167
+ tag:'paranoia-level/1',\
168
+ tag:'OWASP_CRS',\
169
+ tag:'capec/1000/152/248/66',\
170
+ ver:'OWASP_CRS/4.9.0',\
171
+ severity:'CRITICAL',\
172
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
173
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
174
+
175
+ # Regular expression generated from regex-assembly/942170.ra.
176
+ # To update the regular expression run the following shell script
177
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
178
+ # crs-toolchain regex update 942170
179
+ #
180
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)(?:select|;)[\s\x0b]+(?:benchmark|if|sleep)[\s\x0b]*?\([\s\x0b]*?\(?[\s\x0b]*?[0-9A-Z_a-z]+" \
181
+ "id:942170,\
182
+ phase:2,\
183
+ block,\
184
+ capture,\
185
+ t:none,t:urlDecodeUni,\
186
+ msg:'Detects SQL benchmark and sleep injection attempts including conditional queries',\
187
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
188
+ tag:'application-multi',\
189
+ tag:'language-multi',\
190
+ tag:'platform-multi',\
191
+ tag:'attack-sqli',\
192
+ tag:'paranoia-level/1',\
193
+ tag:'OWASP_CRS',\
194
+ tag:'capec/1000/152/248/66',\
195
+ tag:'PCI/6.5.2',\
196
+ ver:'OWASP_CRS/4.9.0',\
197
+ severity:'CRITICAL',\
198
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
199
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
200
+
201
+ # Regular expression generated from regex-assembly/942190.ra.
202
+ # To update the regular expression run the following shell script
203
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
204
+ # crs-toolchain regex update 942190
205
+ #
206
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)[\"'`](?:[\s\x0b]*![\s\x0b]*[\"'0-9A-Z_-z]|;?[\s\x0b]*(?:having|select|union\b[\s\x0b]*(?:all|(?:distin|sele)ct))\b[\s\x0b]*[^\s\x0b])|\b(?:(?:(?:c(?:onnection_id|urrent_user)|database|schema|user)[\s\x0b]*?|select.*?[0-9A-Z_a-z]?user)\(|exec(?:ute)?[\s\x0b]+master\.|from[^0-9A-Z_a-z]+information_schema[^0-9A-Z_a-z]|into[\s\x0b\+]+(?:dump|out)file[\s\x0b]*?[\"'`]|union(?:[\s\x0b]select[\s\x0b]@|[\s\x0b\(0-9A-Z_a-z]*?select))|[\s\x0b]*?exec(?:ute)?.*?[^0-9A-Z_a-z]xp_cmdshell|[^0-9A-Z_a-z]iif[\s\x0b]*?\(" \
207
+ "id:942190,\
208
+ phase:2,\
209
+ block,\
210
+ capture,\
211
+ t:none,t:urlDecodeUni,t:removeCommentsChar,\
212
+ msg:'Detects MSSQL code execution and information gathering attempts',\
213
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
214
+ tag:'application-multi',\
215
+ tag:'language-multi',\
216
+ tag:'platform-multi',\
217
+ tag:'attack-sqli',\
218
+ tag:'paranoia-level/1',\
219
+ tag:'OWASP_CRS',\
220
+ tag:'capec/1000/152/248/66',\
221
+ tag:'PCI/6.5.2',\
222
+ ver:'OWASP_CRS/4.9.0',\
223
+ severity:'CRITICAL',\
224
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
225
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
226
+
227
+ # Magic number crash in PHP strtod from 2011:
228
+ # https://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/
229
+
230
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx ^(?i:-0000023456|4294967295|4294967296|2147483648|2147483647|0000012345|-2147483648|-2147483649|0000023456|2.2250738585072007e-308|2.2250738585072011e-308|1e309)$" \
231
+ "id:942220,\
232
+ phase:2,\
233
+ block,\
234
+ capture,\
235
+ t:none,t:urlDecodeUni,\
236
+ msg:'Looking for integer overflow attacks, these are taken from skipfish, except 2.2.2250738585072011e-308 is the \"magic number\" crash',\
237
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
238
+ tag:'application-multi',\
239
+ tag:'language-multi',\
240
+ tag:'platform-multi',\
241
+ tag:'attack-sqli',\
242
+ tag:'paranoia-level/1',\
243
+ tag:'OWASP_CRS',\
244
+ tag:'capec/1000/152/248/66',\
245
+ tag:'PCI/6.5.2',\
246
+ ver:'OWASP_CRS/4.9.0',\
247
+ severity:'CRITICAL',\
248
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
249
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
250
+
251
+ # Regular expression generated from regex-assembly/942230.ra.
252
+ # To update the regular expression run the following shell script
253
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
254
+ # crs-toolchain regex update 942230
255
+ #
256
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)[\s\x0b\(\)]case[\s\x0b]+when.*?then|\)[\s\x0b]*?like[\s\x0b]*?\(|select.*?having[\s\x0b]*?[^\s\x0b]+[\s\x0b]*?[^\s\x0b0-9A-Z_a-z]|if[\s\x0b]?\([0-9A-Z_a-z]+[\s\x0b]*?[<->~]" \
257
+ "id:942230,\
258
+ phase:2,\
259
+ block,\
260
+ capture,\
261
+ t:none,t:urlDecodeUni,\
262
+ msg:'Detects conditional SQL injection attempts',\
263
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
264
+ tag:'application-multi',\
265
+ tag:'language-multi',\
266
+ tag:'platform-multi',\
267
+ tag:'attack-sqli',\
268
+ tag:'paranoia-level/1',\
269
+ tag:'OWASP_CRS',\
270
+ tag:'capec/1000/152/248/66',\
271
+ tag:'PCI/6.5.2',\
272
+ ver:'OWASP_CRS/4.9.0',\
273
+ severity:'CRITICAL',\
274
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
275
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
276
+
277
+ # Regular expression generated from regex-assembly/942240.ra.
278
+ # To update the regular expression run the following shell script
279
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
280
+ # crs-toolchain regex update 942240
281
+ #
282
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)alter[\s\x0b]*?[0-9A-Z_a-z]+.*?char(?:acter)?[\s\x0b]+set[\s\x0b]+[0-9A-Z_a-z]+|[\"'`](?:;*?[\s\x0b]*?waitfor[\s\x0b]+(?:time|delay)[\s\x0b]+[\"'`]|;.*?:[\s\x0b]*?goto)" \
283
+ "id:942240,\
284
+ phase:2,\
285
+ block,\
286
+ capture,\
287
+ t:none,t:urlDecodeUni,\
288
+ msg:'Detects MySQL charset switch and MSSQL DoS attempts',\
289
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
290
+ tag:'application-multi',\
291
+ tag:'language-multi',\
292
+ tag:'platform-multi',\
293
+ tag:'attack-sqli',\
294
+ tag:'paranoia-level/1',\
295
+ tag:'OWASP_CRS',\
296
+ tag:'capec/1000/152/248/66',\
297
+ tag:'PCI/6.5.2',\
298
+ ver:'OWASP_CRS/4.9.0',\
299
+ severity:'CRITICAL',\
300
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
301
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
302
+
303
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i:merge.*?using\s*?\(|execute\s*?immediate\s*?[\"'`]|match\s*?[\w(),+-]+\s*?against\s*?\()" \
304
+ "id:942250,\
305
+ phase:2,\
306
+ block,\
307
+ capture,\
308
+ t:none,t:urlDecodeUni,\
309
+ msg:'Detects MATCH AGAINST, MERGE and EXECUTE IMMEDIATE injections',\
310
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
311
+ tag:'application-multi',\
312
+ tag:'language-multi',\
313
+ tag:'platform-multi',\
314
+ tag:'attack-sqli',\
315
+ tag:'paranoia-level/1',\
316
+ tag:'OWASP_CRS',\
317
+ tag:'capec/1000/152/248/66',\
318
+ tag:'PCI/6.5.2',\
319
+ ver:'OWASP_CRS/4.9.0',\
320
+ severity:'CRITICAL',\
321
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
322
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
323
+
324
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)union.*?select.*?from" \
325
+ "id:942270,\
326
+ phase:2,\
327
+ block,\
328
+ capture,\
329
+ t:none,t:urlDecodeUni,\
330
+ msg:'Looking for basic sql injection. Common attack string for mysql, oracle and others',\
331
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
332
+ tag:'application-multi',\
333
+ tag:'language-multi',\
334
+ tag:'platform-multi',\
335
+ tag:'attack-sqli',\
336
+ tag:'paranoia-level/1',\
337
+ tag:'OWASP_CRS',\
338
+ tag:'capec/1000/152/248/66',\
339
+ tag:'PCI/6.5.2',\
340
+ ver:'OWASP_CRS/4.9.0',\
341
+ severity:'CRITICAL',\
342
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
343
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
344
+
345
+ # Regular expression generated from regex-assembly/942280.ra.
346
+ # To update the regular expression run the following shell script
347
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
348
+ # crs-toolchain regex update 942280
349
+ #
350
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)select[\s\x0b]*?pg_sleep|waitfor[\s\x0b]*?delay[\s\x0b]?[\"'`]+[\s\x0b]?[0-9]|;[\s\x0b]*?shutdown[\s\x0b]*?(?:[#;\{]|/\*|--)" \
351
+ "id:942280,\
352
+ phase:2,\
353
+ block,\
354
+ capture,\
355
+ t:none,t:urlDecodeUni,\
356
+ msg:'Detects Postgres pg_sleep injection, waitfor delay attacks and database shutdown attempts',\
357
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
358
+ tag:'application-multi',\
359
+ tag:'language-multi',\
360
+ tag:'platform-multi',\
361
+ tag:'attack-sqli',\
362
+ tag:'paranoia-level/1',\
363
+ tag:'OWASP_CRS',\
364
+ tag:'capec/1000/152/248/66',\
365
+ tag:'PCI/6.5.2',\
366
+ ver:'OWASP_CRS/4.9.0',\
367
+ severity:'CRITICAL',\
368
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
369
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
370
+
371
+ # Regular expression generated from regex-assembly/942290.ra.
372
+ # To update the regular expression run the following shell script
373
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
374
+ # crs-toolchain regex update 942290
375
+ #
376
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\[?\$(?:n(?:e|in?|o[rt])|e(?:q|xists|lemMatch)|l(?:te?|ike)|mod|a(?:ll|nd)|(?:s(?:iz|lic)|wher)e|t(?:ype|ext)|x?or|div|between|regex|jsonSchema)\]?" \
377
+ "id:942290,\
378
+ phase:2,\
379
+ block,\
380
+ capture,\
381
+ t:none,t:urlDecodeUni,\
382
+ msg:'Finds basic MongoDB SQL injection attempts',\
383
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
384
+ tag:'application-multi',\
385
+ tag:'language-multi',\
386
+ tag:'platform-multi',\
387
+ tag:'attack-sqli',\
388
+ tag:'paranoia-level/1',\
389
+ tag:'OWASP_CRS',\
390
+ tag:'capec/1000/152/248/66',\
391
+ tag:'PCI/6.5.2',\
392
+ ver:'OWASP_CRS/4.9.0',\
393
+ severity:'CRITICAL',\
394
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
395
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
396
+
397
+ # This rule has a stricter sibling (942321) that checks for MySQL and PostgreSQL procedures / functions in
398
+ # request headers referer and user-agent.
399
+ #
400
+ # Regular expression generated from regex-assembly/942320.ra.
401
+ # To update the regular expression run the following shell script
402
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
403
+ # crs-toolchain regex update 942320
404
+ #
405
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)create[\s\x0b]+(?:function|procedure)[\s\x0b]*?[0-9A-Z_a-z]+[\s\x0b]*?\([\s\x0b]*?\)[\s\x0b]*?-|d(?:eclare[^0-9A-Z_a-z]+[#@][\s\x0b]*?[0-9A-Z_a-z]+|iv[\s\x0b]*?\([\+\-]*[\s\x0b\.0-9]+,[\+\-]*[\s\x0b\.0-9]+\))|exec[\s\x0b]*?\([\s\x0b]*?@|(?:lo_(?:impor|ge)t|procedure[\s\x0b]+analyse)[\s\x0b]*?\(|;[\s\x0b]*?(?:declare|open)[\s\x0b]+[\-0-9A-Z_a-z]+|::(?:b(?:igint|ool)|double[\s\x0b]+precision|int(?:eger)?|numeric|oid|real|(?:tex|smallin)t)" \
406
+ "id:942320,\
407
+ phase:2,\
408
+ block,\
409
+ capture,\
410
+ t:none,t:urlDecodeUni,\
411
+ msg:'Detects MySQL and PostgreSQL stored procedure/function injections',\
412
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
413
+ tag:'application-multi',\
414
+ tag:'language-multi',\
415
+ tag:'platform-multi',\
416
+ tag:'attack-sqli',\
417
+ tag:'paranoia-level/1',\
418
+ tag:'OWASP_CRS',\
419
+ tag:'capec/1000/152/248/66',\
420
+ tag:'PCI/6.5.2',\
421
+ ver:'OWASP_CRS/4.9.0',\
422
+ severity:'CRITICAL',\
423
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
424
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
425
+
426
+ # Regular expression generated from regex-assembly/942350.ra.
427
+ # To update the regular expression run the following shell script
428
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
429
+ # crs-toolchain regex update 942350
430
+ #
431
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)create[\s\x0b]+function[\s\x0b].+[\s\x0b]returns|;[\s\x0b]*?(?:alter|(?:(?:cre|trunc|upd)at|renam)e|d(?:e(?:lete|sc)|rop)|(?:inser|selec)t|load)\b[\s\x0b]*?[\(\[]?[0-9A-Z_a-z]{2,}" \
432
+ "id:942350,\
433
+ phase:2,\
434
+ block,\
435
+ capture,\
436
+ t:none,t:urlDecodeUni,\
437
+ msg:'Detects MySQL UDF injection and other data/structure manipulation attempts',\
438
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
439
+ tag:'application-multi',\
440
+ tag:'language-multi',\
441
+ tag:'platform-multi',\
442
+ tag:'attack-sqli',\
443
+ tag:'paranoia-level/1',\
444
+ tag:'OWASP_CRS',\
445
+ tag:'capec/1000/152/248/66',\
446
+ tag:'PCI/6.5.2',\
447
+ ver:'OWASP_CRS/4.9.0',\
448
+ severity:'CRITICAL',\
449
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
450
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
451
+
452
+ # This rule has two stricter sibling: 942361 and 942362.
453
+ # The keywords 'alter' and 'union' led to false positives.
454
+ # Therefore they have been moved to PL2 and the keywords have been extended on PL1.
455
+ # The original version also had loose word boundaries and context checksum cause further false positives.
456
+ # Because fixing those introduced bypass, the original variant was moved to PL2 as 942362.
457
+ #
458
+ # Sources for SQL ALTER statements:
459
+ # MySQL: https://dev.mysql.com/doc/refman/5.7/en/sql-syntax-data-definition.html
460
+ # Oracle/PLSQL: https://docs.oracle.com/search/?q=alter&size=60&category=database
461
+ # PostgreQSL: https://www.postgresql.org/search/?u=%2Fdocs&q=alter
462
+ # MSSQL: https://learn.microsoft.com/en-us/sql/t-sql/statements/statements?view=sql-server-ver16
463
+ # DB2: https://www.ibm.com/docs/en/search/alter?scope=SSEPGG_9.5.0
464
+ #
465
+ # Regular expression generated from regex-assembly/942360.ra.
466
+ # To update the regular expression run the following shell script
467
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
468
+ # crs-toolchain regex update 942360
469
+ #
470
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\b(?:(?:alter|(?:(?:cre|trunc|upd)at|renam)e|de(?:lete|sc)|(?:inser|selec)t|load)[\s\x0b]+(?:char|group_concat|load_file)\b[\s\x0b]*\(?|end[\s\x0b]*?\);)|[\s\x0b\(]load_file[\s\x0b]*?\(|[\"'`][\s\x0b]+regexp[^0-9A-Z_a-z]|[\"'0-9A-Z_-z][\s\x0b]+as\b[\s\x0b]*[\"'0-9A-Z_-z]+[\s\x0b]*\bfrom|^[^A-Z_a-z]+[\s\x0b]*?(?:(?:(?:(?:cre|trunc)at|renam)e|d(?:e(?:lete|sc)|rop)|(?:inser|selec)t|load)[\s\x0b]+[0-9A-Z_a-z]+|u(?:pdate[\s\x0b]+[0-9A-Z_a-z]+|nion[\s\x0b]*(?:all|(?:sele|distin)ct)\b)|alter[\s\x0b]*(?:a(?:(?:ggregat|pplication[\s\x0b]*rol)e|s(?:sembl|ymmetric[\s\x0b]*ke)y|u(?:dit|thorization)|vailability[\s\x0b]*group)|b(?:roker[\s\x0b]*priority|ufferpool)|c(?:ertificate|luster|o(?:l(?:latio|um)|nversio)n|r(?:edential|yptographic[\s\x0b]*provider))|d(?:atabase|efault|i(?:mension|skgroup)|omain)|e(?:(?:ndpoi|ve)nt|xte(?:nsion|rnal))|f(?:lashback|oreign|u(?:lltext|nction))|hi(?:erarchy|stogram)|group|in(?:dex(?:type)?|memory|stance)|java|l(?:a(?:ngua|r)ge|ibrary|o(?:ckdown|g(?:file[\s\x0b]*group|in)))|m(?:a(?:s(?:k|ter[\s\x0b]*key)|terialized)|e(?:ssage[\s\x0b]*type|thod)|odule)|(?:nicknam|queu)e|o(?:perator|utline)|p(?:a(?:ckage|rtition)|ermission|ro(?:cedur|fil)e)|r(?:e(?:mot|sourc)e|o(?:l(?:e|lback)|ute))|s(?:chema|e(?:arch|curity|rv(?:er|ice)|quence|ssion)|y(?:mmetric[\s\x0b]*key|nonym)|togroup)|t(?:able(?:space)?|ext|hreshold|r(?:igger|usted)|ype)|us(?:age|er)|view|w(?:ork(?:load)?|rapper)|x(?:ml[\s\x0b]*schema|srobject))\b)" \
471
+ "id:942360,\
472
+ phase:2,\
473
+ block,\
474
+ capture,\
475
+ t:none,t:urlDecodeUni,\
476
+ msg:'Detects concatenated basic SQL injection and SQLLFI attempts',\
477
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
478
+ tag:'application-multi',\
479
+ tag:'language-multi',\
480
+ tag:'platform-multi',\
481
+ tag:'attack-sqli',\
482
+ tag:'paranoia-level/1',\
483
+ tag:'OWASP_CRS',\
484
+ tag:'capec/1000/152/248/66',\
485
+ tag:'PCI/6.5.2',\
486
+ ver:'OWASP_CRS/4.9.0',\
487
+ severity:'CRITICAL',\
488
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
489
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
490
+
491
+ #
492
+ # -=[ Detect MySQL in-line comments ]=-
493
+ #
494
+ # MySQL in-line comments can be used to bypass SQLi detection.
495
+ #
496
+ # Ref: https://dev.mysql.com/doc/refman/8.0/en/comments.html:
497
+ # SELECT /*! STRAIGHT_JOIN */ col1 FROM table1,table2 WHERE ...
498
+ # CREATE TABLE t1(a INT, KEY (a)) /*!50110 KEY_BLOCK_SIZE=1024 */;
499
+ # SELECT /*+ BKA(t1) */ FROM ... ;
500
+ #
501
+ # http://localhost/test.php?id=9999+or+{if+length((/*!5000select+username/*!50000from*/user+where+id=1))>0}
502
+ #
503
+ # The minimal string that triggers this regexp is: /*!*/ or /*+*/.
504
+ # The rule 942500 is related to 942440 which catches both /*! and */ independently.
505
+ #
506
+ # Regular expression generated from regex-assembly/942500.ra.
507
+ # To update the regular expression run the following shell script
508
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
509
+ # crs-toolchain regex update 942500
510
+ #
511
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)/\*[\s\x0b]*?[!\+](?:[\s\x0b\(\)\-0-9=A-Z_a-z]+)?\*/" \
512
+ "id:942500,\
513
+ phase:2,\
514
+ block,\
515
+ capture,\
516
+ t:none,t:urlDecodeUni,\
517
+ msg:'MySQL in-line comment detected',\
518
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
519
+ tag:'application-multi',\
520
+ tag:'language-multi',\
521
+ tag:'platform-multi',\
522
+ tag:'attack-sqli',\
523
+ tag:'paranoia-level/1',\
524
+ tag:'OWASP_CRS',\
525
+ tag:'capec/1000/152/248/66',\
526
+ tag:'PCI/6.5.2',\
527
+ ver:'OWASP_CRS/4.9.0',\
528
+ severity:'CRITICAL',\
529
+ multiMatch,\
530
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
531
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
532
+
533
+
534
+ # This rule catches an authentication bypass via SQL injection that abuses semi-colons to end the SQL query early.
535
+ # Any characters after the semi-colon are ignored by some DBMSes (e.g. SQLite).
536
+ #
537
+ # An example of this would be:
538
+ # email=admin%40juice-sh.op';&password=foo
539
+ #
540
+ # The server then turns this into:
541
+ # SELECT * FROM users WHERE email='admin@juice-sh.op';' AND password='foo'
542
+ #
543
+ # Regular expression generated from regex-assembly/942540.ra.
544
+ # To update the regular expression run the following shell script
545
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
546
+ # crs-toolchain regex update 942540
547
+ #
548
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx ^(?:[^']*'|[^\"]*\"|[^`]*`)[\s\x0b]*;" \
549
+ "id:942540,\
550
+ phase:2,\
551
+ block,\
552
+ capture,\
553
+ t:none,t:urlDecodeUni,t:replaceComments,\
554
+ msg:'SQL Authentication bypass (split query)',\
555
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
556
+ tag:'application-multi',\
557
+ tag:'language-multi',\
558
+ tag:'platform-multi',\
559
+ tag:'attack-sqli',\
560
+ tag:'OWASP_CRS',\
561
+ tag:'paranoia-level/1',\
562
+ tag:'capec/1000/152/248/66',\
563
+ tag:'PCI/6.5.2',\
564
+ ver:'OWASP_CRS/4.9.0',\
565
+ severity:'CRITICAL',\
566
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
567
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
568
+
569
+
570
+ # This rule catches on Scientific Notation bypass payloads in MySQL
571
+ # Reference: https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/MySQL%20Injection.md#scientific-notation
572
+ #
573
+ # Regular expression generated from regex-assembly/942560.ra.
574
+ # To update the regular expression run the following shell script
575
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
576
+ # crs-toolchain regex update 942560
577
+ #
578
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)1\.e[\(\),]" \
579
+ "id:942560,\
580
+ phase:2,\
581
+ block,\
582
+ t:none,t:urlDecodeUni,t:replaceComments,\
583
+ msg:'MySQL Scientific Notation payload detected',\
584
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
585
+ tag:'application-multi',\
586
+ tag:'language-multi',\
587
+ tag:'platform-multi',\
588
+ tag:'attack-sqli',\
589
+ tag:'paranoia-level/1',\
590
+ tag:'OWASP_CRS',\
591
+ tag:'capec/1000/152/248/66',\
592
+ tag:'PCI/6.5.2',\
593
+ ver:'OWASP_CRS/4.9.0',\
594
+ severity:'CRITICAL',\
595
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
596
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
597
+
598
+
599
+ # This rule tries to match JSON SQL syntax that could be used as a bypass technique.
600
+ # Referring to this research: https://claroty.com/team82/research/js-on-security-off-abusing-json-based-sql-to-bypass-waf
601
+ #
602
+ # Regular expression generated from regex-assembly/942550.ra.
603
+ # To update the regular expression run the following shell script
604
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
605
+ # crs-toolchain regex update 942550
606
+ #
607
+ SecRule REQUEST_FILENAME|REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx [\"'`][\[\{].*[\]\}][\"'`].*(::.*jsonb?)?.*(?:(?:@|->?)>|<@|\?[&\|]?|#>>?|[<>]|<-)|(?:(?:@|->?)>|<@|\?[&\|]?|#>>?|[<>]|<-)[\"'`][\[\{].*[\]\}][\"'`]|json_extract.*\(.*\)" \
608
+ "id:942550,\
609
+ phase:2,\
610
+ block,\
611
+ t:none,t:urlDecodeUni,t:lowercase,t:removeWhitespace,\
612
+ msg:'JSON-Based SQL Injection',\
613
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
614
+ tag:'application-multi',\
615
+ tag:'language-multi',\
616
+ tag:'platform-multi',\
617
+ tag:'attack-sqli',\
618
+ tag:'paranoia-level/1',\
619
+ tag:'OWASP_CRS',\
620
+ tag:'capec/1000/152/248/66',\
621
+ tag:'PCI/6.5.2',\
622
+ ver:'OWASP_CRS/4.9.0',\
623
+ severity:'CRITICAL',\
624
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
625
+ setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
626
+
627
+
628
+ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 2" "id:942013,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.9.0',skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
629
+ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 2" "id:942014,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.9.0',skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
630
+ #
631
+ # -= Paranoia Level 2 =- (apply only when tx.detection_paranoia_level is sufficiently high: 2 or higher)
632
+ #
633
+
634
+
635
+ #
636
+ # -=[ SQL Operators ]=-
637
+ #
638
+ # This rule is also triggered by the following exploit(s):
639
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
640
+ #
641
+ # Regular expression generated from regex-assembly/942120.ra.
642
+ # To update the regular expression run the following shell script
643
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
644
+ # crs-toolchain regex update 942120
645
+ #
646
+ SecRule ARGS_NAMES|ARGS|REQUEST_FILENAME|XML:/* "@rx (?i)[!=]=|&&|\|\||->|>[=>]|<(?:[<=]|>(?:[\s\x0b]+binary)?)|\b(?:(?:xor|r(?:egexp|like)|i(?:snull|like)|notnull)\b|collate(?:[^0-9A-Z_a-z]*?(?:U&)?[\"'`]|[^0-9A-Z_a-z]+(?:(?:binary|nocase|rtrim)\b|[0-9A-Z_a-z]*?_))|(?:likel(?:ihood|y)|unlikely)[\s\x0b]*\()|r(?:egexp|like)[\s\x0b]+binary|not[\s\x0b]+between[\s\x0b]+(?:0[\s\x0b]+and|(?:'[^']*'|\"[^\"]*\")[\s\x0b]+and[\s\x0b]+(?:'[^']*'|\"[^\"]*\"))|is[\s\x0b]+null|like[\s\x0b]+(?:null|[0-9A-Z_a-z]+[\s\x0b]+escape\b)|(?:^|[^0-9A-Z_a-z])in[\s\x0b\+]*\([\s\x0b\"0-9]+[^\(\)]*\)|[!<->][\s\x0b]*all\b" \
647
+ "id:942120,\
648
+ phase:2,\
649
+ block,\
650
+ capture,\
651
+ t:none,t:utf8toUnicode,t:urlDecodeUni,\
652
+ msg:'SQL Injection Attack: SQL Operator Detected',\
653
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
654
+ tag:'application-multi',\
655
+ tag:'language-multi',\
656
+ tag:'platform-multi',\
657
+ tag:'attack-sqli',\
658
+ tag:'paranoia-level/2',\
659
+ tag:'OWASP_CRS',\
660
+ tag:'capec/1000/152/248/66',\
661
+ tag:'PCI/6.5.2',\
662
+ ver:'OWASP_CRS/4.9.0',\
663
+ severity:'CRITICAL',\
664
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
665
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
666
+
667
+
668
+ #
669
+ # -=[ SQL Tautologies ]=-
670
+ #
671
+ # Boolean-based SQL injection or tautology attack. Boolean values (True or False) are used to carry out
672
+ # this type of SQL injection. The malicious SQL query forces the web application to return a different result de-
673
+ # pending on whether the query returns a TRUE or FALSE result.
674
+ #
675
+ # The original 942130 was split in two rules:
676
+ # - 942130 targets tautologies using equalities (e.g. 1 = 1)
677
+ # - 942131 targets tautologies using inequalities (e.g. 1 != 2)
678
+ #
679
+ # We use captures to check for (in)equality in the regexp. So TX.1 will capture the left hand side (LHS) of the inequality,
680
+ # and TX.2 will capture the right hand side (RHS) of the logical query.
681
+ #
682
+ # Regular expression generated from regex-assembly/942130.ra.
683
+ # To update the regular expression run the following shell script
684
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
685
+ # crs-toolchain regex update 942130
686
+ #
687
+ SecRule ARGS_NAMES|ARGS|XML:/* "@rx (?i)[\s\x0b\"'-\)`]*?\b([0-9A-Z_a-z]+)\b[\s\x0b\"'-\)`]*?(?:=|<=>|(?:sounds[\s\x0b]+)?like|glob|r(?:like|egexp))[\s\x0b\"'-\)`]*?\b([0-9A-Z_a-z]+)\b" \
688
+ "id:942130,\
689
+ phase:2,\
690
+ block,\
691
+ capture,\
692
+ t:none,t:urlDecodeUni,t:replaceComments,\
693
+ msg:'SQL Injection Attack: SQL Boolean-based attack detected',\
694
+ logdata:'Matched Data: %{TX.0} found within %{TX.942130_MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
695
+ tag:'application-multi',\
696
+ tag:'language-multi',\
697
+ tag:'platform-multi',\
698
+ tag:'attack-sqli',\
699
+ tag:'paranoia-level/2',\
700
+ tag:'OWASP_CRS',\
701
+ tag:'capec/1000/152/248/66',\
702
+ tag:'PCI/6.5.2',\
703
+ ver:'OWASP_CRS/4.9.0',\
704
+ severity:'CRITICAL',\
705
+ setvar:'tx.942130_matched_var_name=%{matched_var_name}',\
706
+ chain"
707
+ SecRule TX:1 "@streq %{TX.2}" \
708
+ "t:none,\
709
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
710
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
711
+
712
+ # Rule Targeting logical inequalities that return TRUE (e.g. 1 != 2)
713
+ #
714
+ #
715
+ # We use captures to check for (in)equality in the regexp. So TX.1 will capture the left hand side (LHS) of the inequality,
716
+ # and TX.2 will capture the right hand side (RHS) of the logical query.
717
+ #
718
+ # Regular expression generated from regex-assembly/942131.ra.
719
+ # To update the regular expression run the following shell script
720
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
721
+ # crs-toolchain regex update 942131
722
+ #
723
+ SecRule ARGS_NAMES|ARGS|XML:/* "@rx (?i)[\s\x0b\"'-\)`]*?\b([0-9A-Z_a-z]+)\b[\s\x0b\"'-\)`]*?(?:![<->]|<[=>]?|>=?|\^|is[\s\x0b]+not|not[\s\x0b]+(?:like|r(?:like|egexp)))[\s\x0b\"'-\)`]*?\b([0-9A-Z_a-z]+)\b" \
724
+ "id:942131,\
725
+ phase:2,\
726
+ block,\
727
+ capture,\
728
+ t:none,t:urlDecodeUni,t:replaceComments,\
729
+ msg:'SQL Injection Attack: SQL Boolean-based attack detected',\
730
+ logdata:'Matched Data: %{TX.0} found within %{TX.942131_MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
731
+ tag:'application-multi',\
732
+ tag:'language-multi',\
733
+ tag:'platform-multi',\
734
+ tag:'attack-sqli',\
735
+ tag:'paranoia-level/2',\
736
+ tag:'OWASP_CRS',\
737
+ tag:'capec/1000/152/248/66',\
738
+ tag:'PCI/6.5.2',\
739
+ ver:'OWASP_CRS/4.9.0',\
740
+ severity:'CRITICAL',\
741
+ multiMatch,\
742
+ setvar:'tx.942131_matched_var_name=%{matched_var_name}',\
743
+ chain"
744
+ SecRule TX:1 "!@streq %{TX.2}" \
745
+ "t:none,\
746
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
747
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
748
+
749
+ #
750
+ # -=[ SQL Function Names ]=-
751
+ #
752
+ # This rule is also triggered by the following exploit(s):
753
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
754
+ #
755
+ # Regular expression generated from regex-assembly/942150.ra.
756
+ # To update the regular expression run the following shell script
757
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
758
+ # crs-toolchain regex update 942150
759
+ #
760
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\b(?:json(?:_[0-9A-Z_a-z]+)?|a(?:bs|(?:cos|sin)h?|tan[2h]?|vg)|c(?:eil(?:ing)?|h(?:a(?:nges|r(?:set)?)|r)|o(?:alesce|sh?|unt)|ast)|d(?:e(?:grees|fault)|a(?:te|y))|exp|f(?:loor(?:avg)?|ormat|ield)|g(?:lob|roup_concat)|h(?:ex|our)|i(?:f(?:null)?|if|n(?:str)?)|l(?:ast(?:_insert_rowid)?|ength|ike(?:l(?:ihood|y))?|n|o(?:ad_extension|g(?:10|2)?|wer(?:pi)?|cal)|trim)|m(?:ax|in(?:ute)?|o(?:d|nth))|n(?:ullif|ow)|p(?:i|ow(?:er)?|rintf|assword)|quote|r(?:a(?:dians|ndom(?:blob)?)|e(?:p(?:lace|eat)|verse)|ound|trim|ight)|s(?:i(?:gn|nh?)|oundex|q(?:lite_(?:compileoption_(?:get|used)|offset|source_id|version)|rt)|u(?:bstr(?:ing)?|m)|econd|leep)|t(?:anh?|otal(?:_changes)?|r(?:im|unc)|ypeof|ime)|u(?:n(?:icode|likely)|(?:pp|s)er)|zeroblob|bin|v(?:alues|ersion)|week|year)[^0-9A-Z_a-z]*\(" \
761
+ "id:942150,\
762
+ phase:2,\
763
+ block,\
764
+ capture,\
765
+ t:none,t:urlDecodeUni,\
766
+ msg:'SQL Injection Attack: SQL function name detected',\
767
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
768
+ tag:'application-multi',\
769
+ tag:'language-multi',\
770
+ tag:'platform-multi',\
771
+ tag:'attack-sqli',\
772
+ tag:'paranoia-level/2',\
773
+ tag:'OWASP_CRS',\
774
+ tag:'capec/1000/152/248/66',\
775
+ tag:'PCI/6.5.2',\
776
+ ver:'OWASP_CRS/4.9.0',\
777
+ severity:'CRITICAL',\
778
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
779
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
780
+
781
+ #
782
+ # -=[ SQL Authentication Bypasses ]=-
783
+ #
784
+ # Authentication bypass occurs when the attacker can log in as another user
785
+ # without knowing the user's password. The example bypass could look like this:
786
+ #
787
+ # x' OR 'x
788
+ #
789
+ # Because of the quantity of different rules they are split into:
790
+ # - 942540 PL1
791
+ # - 942180 PL2
792
+ # - 942260 PL2
793
+ # - 942340 PL2
794
+ # - 942520 PL2
795
+ # - 942521 PL2
796
+ # - 942522 PL2
797
+
798
+ # Regular expression generated from regex-assembly/942180.ra.
799
+ # To update the regular expression run the following shell script
800
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
801
+ # crs-toolchain regex update 942180
802
+ #
803
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)(?:/\*)+[\"'`]+[\s\x0b]?(?:--|[#\{]|/\*)?|[\"'`](?:[\s\x0b]*(?:(?:x?or|and|div|like|between)[\s\x0b\-0-9A-Z_a-z]+[\(\)\+-\-<->][\s\x0b]*[\"'0-9`]|[!=\|](?:[\s\x0b!\+\-0-9=]+.*?[\"'\(`].*?|[\s\x0b!0-9=]+.*?[0-9]+)$|(?:like|print)[^0-9A-Z_a-z]+[\"'\(0-9A-Z_-z]|;)|(?:[<>~]+|[\s\x0b]*[^\s\x0b0-9A-Z_a-z]?=[\s\x0b]*|[^0-9A-Z_a-z]*?[\+=]+[^0-9A-Z_a-z]*?)[\"'`])|[0-9][\"'`][\s\x0b]+[\"'`][\s\x0b]+[0-9]|^admin[\s\x0b]*?[\"'`]|[\s\x0b\"'\(`][\s\x0b]*?glob[^0-9A-Z_a-z]+[\"'\(0-9A-Z_-z]|[\s\x0b]is[\s\x0b]*?0[^0-9A-Z_a-z]|where[\s\x0b][\s\x0b,-\.0-9A-Z_a-z]+[\s\x0b]=" \
804
+ "id:942180,\
805
+ phase:2,\
806
+ block,\
807
+ capture,\
808
+ t:none,t:urlDecodeUni,\
809
+ msg:'Detects basic SQL authentication bypass attempts 1/3',\
810
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
811
+ tag:'application-multi',\
812
+ tag:'language-multi',\
813
+ tag:'platform-multi',\
814
+ tag:'attack-sqli',\
815
+ tag:'paranoia-level/2',\
816
+ tag:'OWASP_CRS',\
817
+ tag:'capec/1000/152/248/66',\
818
+ tag:'PCI/6.5.2',\
819
+ ver:'OWASP_CRS/4.9.0',\
820
+ severity:'CRITICAL',\
821
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
822
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
823
+
824
+ # This rule is also triggered by the following exploit(s):
825
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
826
+ #
827
+ # Regular expression generated from regex-assembly/942200.ra.
828
+ # To update the regular expression run the following shell script
829
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
830
+ # crs-toolchain regex update 942200
831
+ #
832
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|REQUEST_HEADERS:User-Agent|REQUEST_HEADERS:Referer|ARGS_NAMES|ARGS|XML:/* "@rx (?i),.*?[\"'\)0-9`-f][\"'`](?:[\"'`].*?[\"'`]|(?:\r?\n)?\z|[^\"'`]+)|[^0-9A-Z_a-z]select.+[^0-9A-Z_a-z]*?from|(?:alter|(?:(?:cre|trunc|upd)at|renam)e|d(?:e(?:lete|sc)|rop)|(?:inser|selec)t|load)[\s\x0b]*?\([\s\x0b]*?space[\s\x0b]*?\(" \
833
+ "id:942200,\
834
+ phase:2,\
835
+ block,\
836
+ capture,\
837
+ t:none,t:urlDecodeUni,\
838
+ msg:'Detects MySQL comment-/space-obfuscated injections and backtick termination',\
839
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
840
+ tag:'application-multi',\
841
+ tag:'language-multi',\
842
+ tag:'platform-multi',\
843
+ tag:'attack-sqli',\
844
+ tag:'paranoia-level/2',\
845
+ tag:'OWASP_CRS',\
846
+ tag:'capec/1000/152/248/66',\
847
+ tag:'PCI/6.5.2',\
848
+ ver:'OWASP_CRS/4.9.0',\
849
+ severity:'CRITICAL',\
850
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
851
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
852
+
853
+ # This rule is also triggered by the following exploit(s):
854
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
855
+ #
856
+ # Regular expression generated from regex-assembly/942210.ra.
857
+ # To update the regular expression run the following shell script
858
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
859
+ # crs-toolchain regex update 942210
860
+ #
861
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)(?:&&|\|\||and|between|div|like|n(?:and|ot)|(?:xx?)?or)[\s\x0b\(]+[0-9A-Z_a-z]+[\s\x0b\)]*?[!\+=]+[\s\x0b0-9]*?[\"'-\)=`]|[0-9](?:[\s\x0b]*?(?:and|between|div|like|x?or)[\s\x0b]*?[0-9]+[\s\x0b]*?[\+\-]|[\s\x0b]+group[\s\x0b]+by.+\()|/[0-9A-Z_a-z]+;?[\s\x0b]+(?:and|between|div|having|like|x?or|select)[^0-9A-Z_a-z]|(?:[#;]|--)[\s\x0b]*?(?:alter|drop|(?:insert|update)[\s\x0b]*?[0-9A-Z_a-z]{2,})|@.+=[\s\x0b]*?\([\s\x0b]*?select|[^0-9A-Z_a-z]SET[\s\x0b]*?@[0-9A-Z_a-z]+" \
862
+ "id:942210,\
863
+ phase:2,\
864
+ block,\
865
+ capture,\
866
+ t:none,t:urlDecodeUni,\
867
+ msg:'Detects chained SQL injection attempts 1/2',\
868
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
869
+ tag:'application-multi',\
870
+ tag:'language-multi',\
871
+ tag:'platform-multi',\
872
+ tag:'attack-sqli',\
873
+ tag:'paranoia-level/2',\
874
+ tag:'OWASP_CRS',\
875
+ tag:'capec/1000/152/248/66',\
876
+ tag:'PCI/6.5.2',\
877
+ ver:'OWASP_CRS/4.9.0',\
878
+ severity:'CRITICAL',\
879
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
880
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
881
+
882
+ # Regular expression generated from regex-assembly/942260.ra.
883
+ # To update the regular expression run the following shell script
884
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
885
+ # crs-toolchain regex update 942260
886
+ #
887
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)[\"'`][\s\x0b]*?(?:(?:and|n(?:and|ot)|(?:xx?)?or|div|like|between|\|\||&&)[\s\x0b]+[\s\x0b0-9A-Z_a-z]+=[\s\x0b]*?[0-9A-Z_a-z]+[\s\x0b]*?having[\s\x0b]+|like[^0-9A-Z_a-z]*?[\"'0-9`])|[0-9A-Z_a-z][\s\x0b]+like[\s\x0b]+[\"'`]|like[\s\x0b]*?[\"'`]%|select[\s\x0b]+?[\s\x0b\"'-\),-\.0-9A-\[\]_-z]+from[\s\x0b]+" \
888
+ "id:942260,\
889
+ phase:2,\
890
+ block,\
891
+ capture,\
892
+ t:none,t:urlDecodeUni,\
893
+ msg:'Detects basic SQL authentication bypass attempts 2/3',\
894
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
895
+ tag:'application-multi',\
896
+ tag:'language-multi',\
897
+ tag:'platform-multi',\
898
+ tag:'attack-sqli',\
899
+ tag:'paranoia-level/2',\
900
+ tag:'OWASP_CRS',\
901
+ tag:'capec/1000/152/248/66',\
902
+ tag:'PCI/6.5.2',\
903
+ ver:'OWASP_CRS/4.9.0',\
904
+ severity:'CRITICAL',\
905
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
906
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
907
+
908
+ # Regular expression generated from regex-assembly/942300.ra.
909
+ # To update the regular expression run the following shell script
910
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
911
+ # crs-toolchain regex update 942300
912
+ #
913
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\)[\s\x0b]*?when[\s\x0b]*?[0-9]+[\s\x0b]*?then|[\"'`][\s\x0b]*?(?:[#\{]|--)|/\*![\s\x0b]?[0-9]+|\b(?:(?:binary|cha?r)[\s\x0b]*?\([\s\x0b]*?[0-9]|(?:and|n(?:and|ot)|(?:xx?)?or|div|like|between|r(?:egexp|like))[\s\x0b]+[0-9A-Z_a-z]+\()|(?:\|\||&&)[\s\x0b]*?[0-9A-Z_a-z]+\(" \
914
+ "id:942300,\
915
+ phase:2,\
916
+ block,\
917
+ capture,\
918
+ t:none,t:urlDecodeUni,\
919
+ msg:'Detects MySQL comments, conditions and ch(a)r injections',\
920
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
921
+ tag:'application-multi',\
922
+ tag:'language-multi',\
923
+ tag:'platform-multi',\
924
+ tag:'attack-sqli',\
925
+ tag:'paranoia-level/2',\
926
+ tag:'OWASP_CRS',\
927
+ tag:'capec/1000/152/248/66',\
928
+ tag:'PCI/6.5.2',\
929
+ ver:'OWASP_CRS/4.9.0',\
930
+ severity:'CRITICAL',\
931
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
932
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
933
+
934
+ # Regular expression generated from regex-assembly/942310.ra.
935
+ # To update the regular expression run the following shell script
936
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
937
+ # crs-toolchain regex update 942310
938
+ #
939
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)(?:\([\s\x0b]*?select[\s\x0b]*?[0-9A-Z_a-z]+|coalesce|order[\s\x0b]+by[\s\x0b]+if[0-9A-Z_a-z]*?)[\s\x0b]*?\(|\*/from|\+[\s\x0b]*?[0-9]+[\s\x0b]*?\+[\s\x0b]*?@|[0-9A-Z_a-z][\"'`][\s\x0b]*?(?:(?:[\+\-=@\|]+[\s\x0b]+?)+|[\+\-=@\|]+)[\(0-9]|@@[0-9A-Z_a-z]+[\s\x0b]*?[^\s\x0b0-9A-Z_a-z]|[^0-9A-Z_a-z]!+[\"'`][0-9A-Z_a-z]|[\"'`](?:;[\s\x0b]*?(?:if|while|begin)|[\s\x0b0-9]+=[\s\x0b]*?[0-9])|[\s\x0b\(]+case[0-9]*?[^0-9A-Z_a-z].+[tw]hen[\s\x0b\(]" \
940
+ "id:942310,\
941
+ phase:2,\
942
+ block,\
943
+ capture,\
944
+ t:none,t:urlDecodeUni,\
945
+ msg:'Detects chained SQL injection attempts 2/2',\
946
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
947
+ tag:'application-multi',\
948
+ tag:'language-multi',\
949
+ tag:'platform-multi',\
950
+ tag:'attack-sqli',\
951
+ tag:'paranoia-level/2',\
952
+ tag:'OWASP_CRS',\
953
+ tag:'capec/1000/152/248/66',\
954
+ tag:'PCI/6.5.2',\
955
+ ver:'OWASP_CRS/4.9.0',\
956
+ severity:'CRITICAL',\
957
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
958
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
959
+
960
+ #
961
+ # -=[ SQL Injection Probings ]=-
962
+ #
963
+ # This is a group of three similar rules aiming to detect SQL injection probings.
964
+ #
965
+ # 942330 PL 2
966
+ # 942370 PL 2
967
+ # 942490 PL 3
968
+ # Regular expression generated from regex-assembly/942330.ra.
969
+ # To update the regular expression run the following shell script
970
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
971
+ # crs-toolchain regex update 942330
972
+ #
973
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)[\"'`][\s\x0b]*?\b(?:x?or|div|like|between|and)\b[\s\x0b]*?[\"'`]?[0-9]|\x5cx(?:2[37]|3d)|^(?:.?[\"'`]$|[\"'\x5c`]*?(?:[\"'0-9`]+|[^\"'`]+[\"'`])[\s\x0b]*?\b(?:and|n(?:and|ot)|(?:xx?)?or|div|like|between|\|\||&&)\b[\s\x0b]*?[\"'0-9A-Z_-z][!&\(\)\+-\.@])|[^\s\x0b0-9A-Z_a-z][0-9A-Z_a-z]+[\s\x0b]*?[\-\|][\s\x0b]*?[\"'`][\s\x0b]*?[0-9A-Z_a-z]|@(?:[0-9A-Z_a-z]+[\s\x0b]+(?:and|x?or|div|like|between)\b[\s\x0b]*?[\"'0-9`]+|[\-0-9A-Z_a-z]+[\s\x0b](?:and|x?or|div|like|between)\b[\s\x0b]*?[^\s\x0b0-9A-Z_a-z])|[^\s\x0b0-:A-Z_a-z][\s\x0b]*?[0-9][^0-9A-Z_a-z]+[^\s\x0b0-9A-Z_a-z][\s\x0b]*?[\"'`].|[^0-9A-Z_a-z]information_schema|table_name[^0-9A-Z_a-z]" \
974
+ "id:942330,\
975
+ phase:2,\
976
+ block,\
977
+ capture,\
978
+ t:none,t:urlDecodeUni,\
979
+ msg:'Detects classic SQL injection probings 1/3',\
980
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
981
+ tag:'application-multi',\
982
+ tag:'language-multi',\
983
+ tag:'platform-multi',\
984
+ tag:'attack-sqli',\
985
+ tag:'paranoia-level/2',\
986
+ tag:'OWASP_CRS',\
987
+ tag:'capec/1000/152/248/66',\
988
+ tag:'PCI/6.5.2',\
989
+ ver:'OWASP_CRS/4.9.0',\
990
+ severity:'CRITICAL',\
991
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
992
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
993
+
994
+ # Regular expression generated from regex-assembly/942340.ra.
995
+ # To update the regular expression run the following shell script
996
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
997
+ # crs-toolchain regex update 942340
998
+ #
999
+ # Note that part of 942340.data is already optimized, to avoid a
1000
+ # Regexp::Assemble behaviour, where the regex is not optimized very nicely.
1001
+ #
1002
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)in[\s\x0b]*?\(+[\s\x0b]*?select|(?:(?:N?AND|X?X?OR|DIV|LIKE|BETWEEN|NOT)[\s\x0b]+|(?:\|\||&&)[\s\x0b]*)[\s\x0b\+0-9A-Z_a-z]+(?:regexp[\s\x0b]*?\(|sounds[\s\x0b]+like[\s\x0b]*?[\"'`]|[0-9=]+x)|[\"'`](?:[\s\x0b]*?(?:[0-9][\s\x0b]*?(?:--|#)|is[\s\x0b]*?(?:[0-9].+[\"'`]?[0-9A-Z_a-z]|[\.0-9]+[\s\x0b]*?[^0-9A-Z_a-z].*?[\"'`]))|[%&<->\^]+[0-9][\s\x0b]*?(?:=|x?or|div|like|between|and)|(?:[^0-9A-Z_a-z]+[\+\-0-9A-Z_a-z]+[\s\x0b]*?=[\s\x0b]*?[0-9][^0-9A-Z_a-z]+|\|?[\-0-9A-Z_a-z]{3,}[^\s\x0b,\.0-9A-Z_a-z]+)[\"'`]|[\s\x0b]*(?:(?:N?AND|X?X?OR|DIV|LIKE|BETWEEN|NOT)[\s\x0b]+|(?:\|\||&&)[\s\x0b]*)(?:array[\s\x0b]*\[|[0-9A-Z_a-z]+(?:[\s\x0b]*!?~|[\s\x0b]+(?:not[\s\x0b]+)?similar[\s\x0b]+to[\s\x0b]+)|(?:tru|fals)e\b))|\bexcept[\s\x0b]+(?:select\b|values[\s\x0b]*?\()" \
1003
+ "id:942340,\
1004
+ phase:2,\
1005
+ block,\
1006
+ capture,\
1007
+ t:none,t:urlDecodeUni,\
1008
+ msg:'Detects basic SQL authentication bypass attempts 3/3',\
1009
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1010
+ tag:'application-multi',\
1011
+ tag:'language-multi',\
1012
+ tag:'platform-multi',\
1013
+ tag:'attack-sqli',\
1014
+ tag:'paranoia-level/2',\
1015
+ tag:'OWASP_CRS',\
1016
+ tag:'capec/1000/152/248/66',\
1017
+ tag:'PCI/6.5.2',\
1018
+ ver:'OWASP_CRS/4.9.0',\
1019
+ severity:'CRITICAL',\
1020
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1021
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1022
+
1023
+ # This rule is a stricter sibling of 942360.
1024
+ # The keywords 'alter' and 'union' led to false positives.
1025
+ # Therefore they have been moved to PL2 and the keywords have been extended on PL1.
1026
+ #
1027
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i:^[\W\d]+\s*?(?:alter|union)\b)" \
1028
+ "id:942361,\
1029
+ phase:2,\
1030
+ block,\
1031
+ capture,\
1032
+ t:none,t:urlDecodeUni,\
1033
+ msg:'Detects basic SQL injection based on keyword alter or union',\
1034
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1035
+ tag:'application-multi',\
1036
+ tag:'language-multi',\
1037
+ tag:'platform-multi',\
1038
+ tag:'attack-sqli',\
1039
+ tag:'paranoia-level/2',\
1040
+ tag:'OWASP_CRS',\
1041
+ tag:'capec/1000/152/248/66',\
1042
+ tag:'PCI/6.5.2',\
1043
+ ver:'OWASP_CRS/4.9.0',\
1044
+ severity:'CRITICAL',\
1045
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1046
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1047
+
1048
+ # This rule is a stricter sibling of 942360.
1049
+ # The loose word boundaries and light context led to false positives.
1050
+ # Because the stricter variant does miss quite a few legitimate payloads, the loose version was moved to PL2.
1051
+ #
1052
+ # Regular expression generated from regex-assembly/942362.ra.
1053
+ # To update the regular expression run the following shell script
1054
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1055
+ # crs-toolchain regex update 942362
1056
+ #
1057
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)(?:alter|(?:(?:cre|trunc|upd)at|renam)e|de(?:lete|sc)|(?:inser|selec)t|load)[\s\x0b]+(?:char|group_concat|load_file)[\s\x0b]?\(?|end[\s\x0b]*?\);|[\s\x0b\(]load_file[\s\x0b]*?\(|[\"'`][\s\x0b]+regexp[^0-9A-Z_a-z]|[^A-Z_a-z][\s\x0b]+as\b[\s\x0b]*[\"'0-9A-Z_-z]+[\s\x0b]*\bfrom|^[^A-Z_a-z]+[\s\x0b]*?(?:create[\s\x0b]+[0-9A-Z_a-z]+|(?:d(?:e(?:lete|sc)|rop)|(?:inser|selec)t|load|(?:renam|truncat)e|u(?:pdate|nion[\s\x0b]*(?:all|(?:sele|distin)ct))|alter[\s\x0b]*(?:a(?:(?:ggregat|pplication[\s\x0b]*rol)e|s(?:sembl|ymmetric[\s\x0b]*ke)y|u(?:dit|thorization)|vailability[\s\x0b]*group)|b(?:roker[\s\x0b]*priority|ufferpool)|c(?:ertificate|luster|o(?:l(?:latio|um)|nversio)n|r(?:edential|yptographic[\s\x0b]*provider))|d(?:atabase|efault|i(?:mension|skgroup)|omain)|e(?:(?:ndpoi|ve)nt|xte(?:nsion|rnal))|f(?:lashback|oreign|u(?:lltext|nction))|hi(?:erarchy|stogram)|group|in(?:dex(?:type)?|memory|stance)|java|l(?:a(?:ngua|r)ge|ibrary|o(?:ckdown|g(?:file[\s\x0b]*group|in)))|m(?:a(?:s(?:k|ter[\s\x0b]*key)|terialized)|e(?:ssage[\s\x0b]*type|thod)|odule)|(?:nicknam|queu)e|o(?:perator|utline)|p(?:a(?:ckage|rtition)|ermission|ro(?:cedur|fil)e)|r(?:e(?:mot|sourc)e|o(?:l(?:e|lback)|ute))|s(?:chema|e(?:arch|curity|rv(?:er|ice)|quence|ssion)|y(?:mmetric[\s\x0b]*key|nonym)|togroup)|t(?:able(?:space)?|ext|hreshold|r(?:igger|usted)|ype)|us(?:age|er)|view|w(?:ork(?:load)?|rapper)|x(?:ml[\s\x0b]*schema|srobject)))\b)" \
1058
+ "id:942362,\
1059
+ phase:2,\
1060
+ block,\
1061
+ capture,\
1062
+ t:none,t:urlDecodeUni,\
1063
+ msg:'Detects concatenated basic SQL injection and SQLLFI attempts',\
1064
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1065
+ tag:'application-multi',\
1066
+ tag:'language-multi',\
1067
+ tag:'platform-multi',\
1068
+ tag:'attack-sqli',\
1069
+ tag:'paranoia-level/2',\
1070
+ tag:'OWASP_CRS',\
1071
+ tag:'capec/1000/152/248/66',\
1072
+ tag:'PCI/6.5.2',\
1073
+ ver:'OWASP_CRS/4.9.0',\
1074
+ severity:'CRITICAL',\
1075
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1076
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1077
+
1078
+
1079
+ # This rule is a sibling of 942330. See that rule for a description and overview.
1080
+ #
1081
+ # This rule is also triggered by the following exploit(s):
1082
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
1083
+ #
1084
+ # Regular expression generated from regex-assembly/942370.ra.
1085
+ # To update the regular expression run the following shell script
1086
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1087
+ # crs-toolchain regex update 942370
1088
+ #
1089
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|REQUEST_HEADERS:Referer|REQUEST_HEADERS:User-Agent|ARGS_NAMES|ARGS|XML:/* "@rx (?i)[\"'`](?:[\s\x0b]*?(?:(?:\*.+(?:x?or|div|like|between|(?:an|i)d)[^0-9A-Z_a-z]*?[\"'`]|(?:x?or|div|like|between|and)[\s\x0b][^0-9]+[\-0-9A-Z_a-z]+.*?)[0-9]|[^\s\x0b0-9\?A-Z_a-z]+[\s\x0b]*?[^\s\x0b0-9A-Z_a-z]+[\s\x0b]*?[\"'`]|[^\s\x0b0-9A-Z_a-z]+[\s\x0b]*?[^A-Z_a-z].*?(?:#|--))|.*?\*[\s\x0b]*?[0-9])|\^[\"'`]|[%\(-\+\-<>][\-0-9A-Z_a-z]+[^\s\x0b0-9A-Z_a-z]+[\"'`][^,]" \
1090
+ "id:942370,\
1091
+ phase:2,\
1092
+ block,\
1093
+ capture,\
1094
+ t:none,t:urlDecodeUni,\
1095
+ msg:'Detects classic SQL injection probings 2/3',\
1096
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1097
+ tag:'application-multi',\
1098
+ tag:'language-multi',\
1099
+ tag:'platform-multi',\
1100
+ tag:'attack-sqli',\
1101
+ tag:'paranoia-level/2',\
1102
+ tag:'OWASP_CRS',\
1103
+ tag:'capec/1000/152/248/66',\
1104
+ tag:'PCI/6.5.2',\
1105
+ ver:'OWASP_CRS/4.9.0',\
1106
+ severity:'CRITICAL',\
1107
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1108
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1109
+
1110
+ # Regular expression generated from regex-assembly/942380.ra.
1111
+ # To update the regular expression run the following shell script
1112
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1113
+ # crs-toolchain regex update 942380
1114
+ #
1115
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\b(?:having\b(?:[\s\x0b]+(?:[0-9]{1,10}|'[^=]{1,10}')[\s\x0b]*?[<->]| ?(?:[0-9]{1,10} ?[<->]+|[\"'][^=]{1,10}[ \"'<-\?\[]+))|ex(?:ecute(?:\(|[\s\x0b]{1,5}[\$\.0-9A-Z_a-z]{1,5}[\s\x0b]{0,3})|ists[\s\x0b]*?\([\s\x0b]*?select\b)|(?:create[\s\x0b]+?table.{0,20}?|like[^0-9A-Z_a-z]*?char[^0-9A-Z_a-z]*?)\()|select.*?case|from.*?limit|order[\s\x0b]by|exists[\s\x0b](?:[\s\x0b]select|s(?:elect[^\s\x0b](?:if(?:null)?[\s\x0b]\(|top|concat)|ystem[\s\x0b]\()|\bhaving\b[\s\x0b]+[0-9]{1,10}|'[^=]{1,10}')" \
1116
+ "id:942380,\
1117
+ phase:2,\
1118
+ block,\
1119
+ capture,\
1120
+ t:none,t:urlDecodeUni,\
1121
+ msg:'SQL Injection Attack',\
1122
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1123
+ tag:'application-multi',\
1124
+ tag:'language-multi',\
1125
+ tag:'platform-multi',\
1126
+ tag:'attack-sqli',\
1127
+ tag:'paranoia-level/2',\
1128
+ tag:'OWASP_CRS',\
1129
+ tag:'capec/1000/152/248/66',\
1130
+ tag:'PCI/6.5.2',\
1131
+ ver:'OWASP_CRS/4.9.0',\
1132
+ severity:'CRITICAL',\
1133
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1134
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1135
+
1136
+ # Regular expression generated from regex-assembly/942390.ra.
1137
+ # To update the regular expression run the following shell script
1138
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1139
+ # crs-toolchain regex update 942390
1140
+ #
1141
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\b(?:or\b(?:[\s\x0b]?(?:[0-9]{1,10}|[\"'][^=]{1,10}[\"'])[\s\x0b]?[<->]+|[\s\x0b]+(?:[0-9]{1,10}|'[^=]{1,10}')(?:[\s\x0b]*?[<->])?)|xor\b[\s\x0b]+(?:[0-9]{1,10}|'[^=]{1,10}')(?:[\s\x0b]*?[<->])?)|'[\s\x0b]+x?or[\s\x0b]+.{1,20}[!\+\-<->]" \
1142
+ "id:942390,\
1143
+ phase:2,\
1144
+ block,\
1145
+ capture,\
1146
+ t:none,t:urlDecodeUni,\
1147
+ msg:'SQL Injection Attack',\
1148
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1149
+ tag:'application-multi',\
1150
+ tag:'language-multi',\
1151
+ tag:'platform-multi',\
1152
+ tag:'attack-sqli',\
1153
+ tag:'paranoia-level/2',\
1154
+ tag:'OWASP_CRS',\
1155
+ tag:'capec/1000/152/248/66',\
1156
+ tag:'PCI/6.5.2',\
1157
+ ver:'OWASP_CRS/4.9.0',\
1158
+ severity:'CRITICAL',\
1159
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1160
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1161
+
1162
+ # Regular expression generated from regex-assembly/942400.ra.
1163
+ # To update the regular expression run the following shell script
1164
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1165
+ # crs-toolchain regex update 942400
1166
+ #
1167
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\band\b(?:[\s\x0b]+(?:[0-9]{1,10}[\s\x0b]*?[<->]|'[^=]{1,10}')| ?(?:[0-9]{1,10}|[\"'][^=]{1,10}[\"']) ?[<->]+)" \
1168
+ "id:942400,\
1169
+ phase:2,\
1170
+ block,\
1171
+ capture,\
1172
+ t:none,t:urlDecodeUni,\
1173
+ msg:'SQL Injection Attack',\
1174
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1175
+ tag:'application-multi',\
1176
+ tag:'language-multi',\
1177
+ tag:'platform-multi',\
1178
+ tag:'attack-sqli',\
1179
+ tag:'paranoia-level/2',\
1180
+ tag:'OWASP_CRS',\
1181
+ tag:'capec/1000/152/248/66',\
1182
+ tag:'PCI/6.5.2',\
1183
+ ver:'OWASP_CRS/4.9.0',\
1184
+ severity:'CRITICAL',\
1185
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1186
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1187
+
1188
+ # The former rule id 942410 was split into three new rules: 942410, 942470, 942480
1189
+ #
1190
+ # This rule is also triggered by the following exploit(s):
1191
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
1192
+ #
1193
+ # Regular expression generated from regex-assembly/942410.ra.
1194
+ # To update the regular expression run the following shell script
1195
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1196
+ # crs-toolchain regex update 942410
1197
+ #
1198
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\b(?:a(?:(?:b|co)s|dd(?:dat|tim)e|es_(?:de|en)crypt|s(?:in|cii(?:str)?)|tan2?|vg)|b(?:enchmark|i(?:n(?:_to_num)?|t_(?:and|count|length|x?or)))|c(?:ast|h(?:ar(?:(?:acter)?_length|set)?|r)|iel(?:ing)?|o(?:alesce|ercibility|(?:mpres)?s|n(?:cat(?:_ws)?|nection_id|v(?:ert(?:_tz)?)?)|(?:un)?t)|r32|ur(?:(?:dat|tim)e|rent_(?:date|time(?:stamp)?|user)))|d(?:a(?:t(?:abase|e(?:_(?:add|format|sub)|diff)?)|y(?:name|of(?:month|week|year))?)|count|e(?:code|(?:faul|s_(?:de|en)cryp)t|grees)|ump)|e(?:lt|nc(?:ode|rypt)|x(?:p(?:ort_set)?|tract(?:value)?))|f(?:i(?:eld(?:_in_set)?|nd_in_set)|loor|o(?:rmat|und_rows)|rom_(?:base64|days|unixtime))|g(?:et_(?:format|lock)|r(?:eates|oup_conca)t)|h(?:ex(?:toraw)?|our)|i(?:f(?:null)?|n(?:et6?_(?:aton|ntoa)|s(?:ert|tr)|terval)?|s(?:_(?:(?:free|used)_lock|ipv(?:4(?:_(?:compat|mapped))?|6)|n(?:ot(?:_null)?|ull))|null)?)|l(?:ast(?:_(?:day|insert_id))?|case|e(?:(?:as|f)t|ngth)|n|o(?:ad_file|ca(?:l(?:timestamp)?|te)|g(?:10|2)?|wer)|pad|trim)|m(?:a(?:ke(?:date|_set)|ster_pos_wait|x)|d5|i(?:(?:crosecon)?d|n(?:ute)?)|o(?:d|nth(?:name)?))|n(?:ame_const|o(?:t_in|w)|ullif)|o(?:ct(?:et_length)?|(?:ld_passwo)?rd)|p(?:assword|eriod_(?:add|diff)|g_sleep|i|o(?:sition|w(?:er)?)|rocedure_analyse)|qu(?:arter|ote)|r(?:a(?:dians|nd|wto(?:hex|nhex(?:toraw)?))|e(?:lease_lock|p(?:eat|lace)|verse)|ight|o(?:und|w_count)|pad|trim)|s(?:chema|e(?:c(?:ond|_to_time)|ssion_user)|ha[12]?|ig?n|leep|oundex|pace|qrt|t(?:d(?:dev(?:_(?:po|sam)p)?)?|r(?:cmp|_to_date))|u(?:b(?:(?:dat|tim)e|str(?:ing(?:_index)?)?)|m)|ys(?:date|tem_user))|t(?:an|ime(?:diff|_(?:format|to_sec)|stamp(?:add|diff)?)?|o_(?:base64|n?char|(?:day|second)s)|r(?:im|uncate))|u(?:case|n(?:compress(?:ed_length)?|hex|ix_timestamp)|p(?:datexml|per)|ser|tc_(?:date|time(?:stamp)?)|uid(?:_short)?)|v(?:a(?:lues|r(?:iance|_(?:po|sam)p))|ersion)|we(?:ek(?:day|ofyear)?|ight_string)|xmltype|year(?:week)?)[^0-9A-Z_a-z]*?\(" \
1199
+ "id:942410,\
1200
+ phase:2,\
1201
+ block,\
1202
+ capture,\
1203
+ t:none,t:urlDecodeUni,\
1204
+ msg:'SQL Injection Attack',\
1205
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1206
+ tag:'application-multi',\
1207
+ tag:'language-multi',\
1208
+ tag:'platform-multi',\
1209
+ tag:'attack-sqli',\
1210
+ tag:'paranoia-level/2',\
1211
+ tag:'OWASP_CRS',\
1212
+ tag:'capec/1000/152/248/66',\
1213
+ tag:'PCI/6.5.2',\
1214
+ ver:'OWASP_CRS/4.9.0',\
1215
+ severity:'CRITICAL',\
1216
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1217
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1218
+
1219
+
1220
+ # The former rule id 942410 was split into three new rules: 942410, 942470, 942480
1221
+ #
1222
+ # Regular expression generated from regex-assembly/942470.ra.
1223
+ # To update the regular expression run the following shell script
1224
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1225
+ # crs-toolchain regex update 942470
1226
+ #
1227
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)autonomous_transaction|(?:current_use|n?varcha|tbcreato)r|db(?:a_users|ms_java)|open(?:owa_util|query|rowset)|s(?:p_(?:(?:addextendedpro|sqlexe)c|execute(?:sql)?|help|is_srvrolemember|makewebtask|oacreate|p(?:assword|repare)|replwritetovarbin)|ql_(?:longvarchar|variant))|utl_(?:file|http)|xp_(?:availablemedia|(?:cmdshel|servicecontro)l|dirtree|e(?:numdsn|xecresultset)|filelist|loginconfig|makecab|ntsec(?:_enumdomains)?|reg(?:addmultistring|delete(?:key|value)|enum(?:key|value)s|re(?:ad|movemultistring)|write)|terminate(?:_process)?)" \
1228
+ "id:942470,\
1229
+ phase:2,\
1230
+ block,\
1231
+ capture,\
1232
+ t:none,t:urlDecodeUni,\
1233
+ msg:'SQL Injection Attack',\
1234
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1235
+ tag:'application-multi',\
1236
+ tag:'language-multi',\
1237
+ tag:'platform-multi',\
1238
+ tag:'attack-sqli',\
1239
+ tag:'paranoia-level/2',\
1240
+ tag:'OWASP_CRS',\
1241
+ tag:'capec/1000/152/248/66',\
1242
+ tag:'PCI/6.5.2',\
1243
+ ver:'OWASP_CRS/4.9.0',\
1244
+ severity:'CRITICAL',\
1245
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1246
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1247
+
1248
+
1249
+ # The former rule id 942410 was split into three new rules: 942410, 942470, 942480
1250
+ #
1251
+ # Regular expression generated from regex-assembly/942480.ra.
1252
+ # To update the regular expression run the following shell script
1253
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1254
+ # crs-toolchain regex update 942480
1255
+ #
1256
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES|REQUEST_HEADERS|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\b(?:(?:d(?:bms_[0-9A-Z_a-z]+\.|elete\b[^0-9A-Z_a-z]*?\bfrom)|(?:group\b.*?\bby\b.{1,100}?\bhav|overlay\b[^0-9A-Z_a-z]*?\(.*?\b[^0-9A-Z_a-z]*?plac)ing|in(?:ner\b[^0-9A-Z_a-z]*?\bjoin|sert\b[^0-9A-Z_a-z]*?\binto|to\b[^0-9A-Z_a-z]*?\b(?:dump|out)file)|load\b[^0-9A-Z_a-z]*?\bdata\b.*?\binfile|s(?:elect\b.{1,100}?\b(?:(?:.*?\bdump\b.*|(?:count|length)\b.{1,100}?)\bfrom|(?:data_typ|from\b.{1,100}?\bwher)e|instr|to(?:_(?:cha|numbe)r|p\b.{1,100}?\bfrom))|ys_context)|u(?:nion\b.{1,100}?\bselect|tl_inaddr))\b|print\b[^0-9A-Z_a-z]*?@@)|(?:collation[^0-9A-Z_a-z]*?\(a|@@version|;[^0-9A-Z_a-z]*?\b(?:drop|shutdown))\b|'(?:dbo|msdasql|s(?:a|qloledb))'" \
1257
+ "id:942480,\
1258
+ phase:2,\
1259
+ block,\
1260
+ capture,\
1261
+ t:none,t:urlDecodeUni,\
1262
+ msg:'SQL Injection Attack',\
1263
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1264
+ tag:'application-multi',\
1265
+ tag:'language-multi',\
1266
+ tag:'platform-multi',\
1267
+ tag:'attack-sqli',\
1268
+ tag:'paranoia-level/2',\
1269
+ tag:'OWASP_CRS',\
1270
+ tag:'capec/1000/152/248/66',\
1271
+ tag:'PCI/6.5.2',\
1272
+ ver:'OWASP_CRS/4.9.0',\
1273
+ severity:'CRITICAL',\
1274
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1275
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1276
+
1277
+
1278
+ #
1279
+ # [ SQL Injection Character Anomaly Usage ]
1280
+ #
1281
+ # This rule is also triggered by the following exploit(s):
1282
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
1283
+ #
1284
+ # This rules attempts to gauge when there is an excessive use of
1285
+ # meta-characters within a single parameter payload.
1286
+ #
1287
+ # Expect a lot of false positives with this rule.
1288
+ # The most likely false positive instances will be free-form text fields.
1289
+ # This will make it necessary to disable the rule for certain known parameters.
1290
+ # The following directive is an example to switch off the rule globally for
1291
+ # the parameter foo. Place this instruction in your configuration after
1292
+ # the include directive for the Core Rules Set.
1293
+ #
1294
+ # SecRuleUpdateTargetById 942430 "!ARGS:foo"
1295
+ #
1296
+
1297
+ SecRule ARGS_NAMES|ARGS|XML:/* "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){12})" \
1298
+ "id:942430,\
1299
+ phase:2,\
1300
+ block,\
1301
+ capture,\
1302
+ t:none,t:urlDecodeUni,\
1303
+ msg:'Restricted SQL Character Anomaly Detection (args): # of special characters exceeded (12)',\
1304
+ logdata:'Matched Data: %{TX.1} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1305
+ tag:'application-multi',\
1306
+ tag:'language-multi',\
1307
+ tag:'platform-multi',\
1308
+ tag:'attack-sqli',\
1309
+ tag:'paranoia-level/2',\
1310
+ tag:'OWASP_CRS',\
1311
+ tag:'capec/1000/152/248/66',\
1312
+ tag:'PCI/6.5.2',\
1313
+ ver:'OWASP_CRS/4.9.0',\
1314
+ severity:'WARNING',\
1315
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.warning_anomaly_score}',\
1316
+ setvar:'tx.sql_injection_score=+%{tx.warning_anomaly_score}'"
1317
+
1318
+ #
1319
+ # -=[ Exclusion rule for 942440 ]=-
1320
+ #
1321
+ # Prevent FPs against Facebook click identifier
1322
+ #
1323
+ SecRule ARGS_GET:fbclid "@rx [a-zA-Z0-9_-]{61,61}" \
1324
+ "id:942441,\
1325
+ phase:2,\
1326
+ pass,\
1327
+ t:none,\
1328
+ nolog,\
1329
+ tag:'OWASP_CRS',\
1330
+ ctl:ruleRemoveTargetById=942440;ARGS:fbclid,\
1331
+ ver:'OWASP_CRS/4.9.0'"
1332
+
1333
+ #
1334
+ # -=[ Exclusion rule for 942440 ]=-
1335
+ #
1336
+ # Prevent FPs against Google click identifier
1337
+ #
1338
+ SecRule ARGS_GET:gclid "@rx [a-zA-Z0-9_-]{91,91}" \
1339
+ "id:942442,\
1340
+ phase:2,\
1341
+ pass,\
1342
+ t:none,\
1343
+ nolog,\
1344
+ tag:'OWASP_CRS',\
1345
+ ctl:ruleRemoveTargetById=942440;ARGS:gclid,\
1346
+ ver:'OWASP_CRS/4.9.0'"
1347
+
1348
+ #
1349
+ # -=[ Detect SQL Comment Sequences ]=-
1350
+ #
1351
+ # Example Payloads Detected:
1352
+ # -------------------------
1353
+ # OR 1#
1354
+ # DROP sampletable;--
1355
+ # admin'--
1356
+ # DROP/*comment*/sampletable
1357
+ # DR/**/OP/*bypass deny listing*/sampletable
1358
+ # SELECT/*avoid-spaces*/password/**/FROM/**/Members
1359
+ # SELECT /*!32302 1/0, */ 1 FROM tablename
1360
+ # ‘ or 1=1#
1361
+ # ‘ or 1=1-- -
1362
+ # ‘ or 1=1/*
1363
+ # ' or 1=1;\x00
1364
+ # 1='1' or-- -
1365
+ # ' /*!50000or*/1='1
1366
+ # ' /*!or*/1='1
1367
+ # 0/**/union/*!50000select*/table_name`foo`/**/
1368
+ # -------------------------
1369
+ #
1370
+ # The chained rule is designed to prevent false positives by specifically
1371
+ # targeting JWT tokens. Starting with 'ey' targets JWT tokens, where the 'ey'
1372
+ # prefix corresponds to the beginning of the Base64-encoded header section.
1373
+ #
1374
+ # example:
1375
+ # $ echo '{"' | base64
1376
+ # eyIK
1377
+ #
1378
+ # Regular expressions generated from regex-assembly/942440.ra and regex-assembly/942440-chain1.ra.
1379
+ # To update the regular expressions run the following shell scripts
1380
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1381
+ # crs-toolchain regex update 942440
1382
+ # crs-toolchain regex update 942440-chain1
1383
+ #
1384
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx /\*!?|\*/|[';]--|--(?:[\s\x0b]|[^\-]*?-)|[^&\-]#.*?[\s\x0b]|;?\x00" \
1385
+ "id:942440,\
1386
+ phase:2,\
1387
+ block,\
1388
+ capture,\
1389
+ t:none,t:urlDecodeUni,\
1390
+ msg:'SQL Comment Sequence Detected',\
1391
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1392
+ tag:'application-multi',\
1393
+ tag:'language-multi',\
1394
+ tag:'platform-multi',\
1395
+ tag:'attack-sqli',\
1396
+ tag:'paranoia-level/2',\
1397
+ tag:'OWASP_CRS',\
1398
+ tag:'capec/1000/152/248/66',\
1399
+ tag:'PCI/6.5.2',\
1400
+ ver:'OWASP_CRS/4.9.0',\
1401
+ severity:'CRITICAL',\
1402
+ chain"
1403
+ SecRule MATCHED_VARS "!@rx ^ey[\-0-9A-Z_a-z]+\.ey[\-0-9A-Z_a-z]+\.[\-0-9A-Z_a-z]+$" \
1404
+ "t:none,\
1405
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}',\
1406
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}'"
1407
+
1408
+
1409
+ #
1410
+ # -=[ SQL Hex Evasion Methods ]=-
1411
+ #
1412
+ # Hex encoding detection:
1413
+ # (?i:\b0x[a-f\d]{3,}) will match any 3 or more hex bytes after "0x", together forming a hexadecimal payload(e.g 0xf00, 0xf00d and so on)
1414
+ #
1415
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i:\b0x[a-f\d]{3,})" \
1416
+ "id:942450,\
1417
+ phase:2,\
1418
+ block,\
1419
+ capture,\
1420
+ t:none,t:urlDecodeUni,\
1421
+ msg:'SQL Hex Encoding Identified',\
1422
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1423
+ tag:'application-multi',\
1424
+ tag:'language-multi',\
1425
+ tag:'platform-multi',\
1426
+ tag:'attack-sqli',\
1427
+ tag:'paranoia-level/2',\
1428
+ tag:'OWASP_CRS',\
1429
+ tag:'capec/1000/152/248/66',\
1430
+ tag:'PCI/6.5.2',\
1431
+ ver:'OWASP_CRS/4.9.0',\
1432
+ severity:'CRITICAL',\
1433
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1434
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1435
+
1436
+
1437
+ #
1438
+ # -=[ Detect SQLi bypass: backticks ]=-
1439
+ #
1440
+ # Quotes and backticks can be used to bypass SQLi detection.
1441
+ #
1442
+ # Example:
1443
+ # GET http://localhost/test.php?id=9999%20or+{`if`(2=(select+2+from+wp_users+where+user_login='admin'))}
1444
+ #
1445
+ # The minimum text between the ticks or backticks must be 2 (if, for example) and a maximum of 29.
1446
+ # 29 is a compromise: The lower this number (29), the lower the probability of FP and the higher the probability of false negatives.
1447
+ # In tests we got a minimum number of FP with {2,29}.
1448
+ #
1449
+ # Base64 encoding detection:
1450
+ # (?:[A-Za-z0-9+/]{4})+ #match any number of 4-letter blocks of the base64 char set
1451
+ # (?:[A-Za-z0-9+/]{2}== #match 2-letter block of the base64 char set followed by "==", together forming a 4-letter block
1452
+ # | # or
1453
+ # [A-Za-z0-9+/]{3}= #match 3-letter block of the base64 char set followed by "=", together forming a 4-letter block
1454
+ # )?
1455
+ #
1456
+ # The minimal string that triggers this regexp is: `if`
1457
+ #
1458
+ # The rule 942511 is similar to this rule, but triggers on normal quotes
1459
+ # ('if'). That rule runs in paranoia level 3 or higher since it is prone to
1460
+ # false positives in natural text.
1461
+ #
1462
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?:`(?:(?:[\w\s=_\-+{}()<@]){2,29}|(?:[A-Za-z0-9+/]{4})+(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)`)" \
1463
+ "id:942510,\
1464
+ phase:2,\
1465
+ block,\
1466
+ capture,\
1467
+ t:none,t:urlDecodeUni,\
1468
+ msg:'SQLi bypass attempt by ticks or backticks detected',\
1469
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1470
+ tag:'application-multi',\
1471
+ tag:'language-multi',\
1472
+ tag:'platform-multi',\
1473
+ tag:'attack-sqli',\
1474
+ tag:'paranoia-level/2',\
1475
+ tag:'OWASP_CRS',\
1476
+ tag:'capec/1000/152/248/66',\
1477
+ tag:'PCI/6.5.2',\
1478
+ ver:'OWASP_CRS/4.9.0',\
1479
+ severity:'CRITICAL',\
1480
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1481
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1482
+
1483
+
1484
+ # Regular expression generated from regex-assembly/942520.ra.
1485
+ # To update the regular expression run the following shell script
1486
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1487
+ # crs-toolchain regex update 942520
1488
+ #
1489
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)[\"'`][\s\x0b]*?(?:(?:is[\s\x0b]+not|not[\s\x0b]+(?:like|glob|(?:betwee|i)n|null|regexp|match)|mod|div|sounds[\s\x0b]+like)\b|[%&\*\+\-/<->\^\|]{1,3})" \
1490
+ "id:942520,\
1491
+ phase:2,\
1492
+ block,\
1493
+ capture,\
1494
+ t:none,t:urlDecodeUni,\
1495
+ msg:'Detects basic SQL authentication bypass attempts 4.0/4',\
1496
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1497
+ tag:'application-multi',\
1498
+ tag:'language-multi',\
1499
+ tag:'platform-multi',\
1500
+ tag:'attack-sqli',\
1501
+ tag:'paranoia-level/2',\
1502
+ tag:'OWASP_CRS',\
1503
+ tag:'capec/1000/152/248/66',\
1504
+ tag:'PCI/6.5.2',\
1505
+ ver:'OWASP_CRS/4.9.0',\
1506
+ severity:'CRITICAL',\
1507
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1508
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1509
+
1510
+
1511
+ # Complementary rule to PL2 942520 that block and/or-based bypasses.
1512
+ # It blocks data with odd number of quotes and then (and|or).
1513
+ #
1514
+ # The rule uses the expression ^b*a*(b*a*b*a*)* to odd number of a's. It's not
1515
+ # vulnerable to ReDos as it executes linearly many steps compared to input size.
1516
+ #
1517
+ # Regular expression generated from regex-assembly/942521.ra.
1518
+ # To update the regular expression run the following shell script
1519
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1520
+ # crs-toolchain regex update 942521
1521
+ #
1522
+ SecRule REQUEST_HEADERS:User-Agent|REQUEST_HEADERS:Referer|ARGS_NAMES|ARGS|XML:/* "@rx (?i)^(?:[^']*?(?:'[^']*?'[^']*?)*?'|[^\"]*?(?:\"[^\"]*?\"[^\"]*?)*?\"|[^`]*?(?:`[^`]*?`[^`]*?)*?`)[\s\x0b]*([0-9A-Z_a-z]+)\b" \
1523
+ "id:942521,\
1524
+ phase:2,\
1525
+ block,\
1526
+ capture,\
1527
+ t:none,t:urlDecodeUni,\
1528
+ msg:'Detects basic SQL authentication bypass attempts 4.1/4',\
1529
+ logdata:'Matched Data: %{TX.0} found within %{TX.942521_MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1530
+ tag:'application-multi',\
1531
+ tag:'language-multi',\
1532
+ tag:'platform-multi',\
1533
+ tag:'attack-sqli',\
1534
+ tag:'paranoia-level/2',\
1535
+ tag:'OWASP_CRS',\
1536
+ tag:'capec/1000/152/248/66',\
1537
+ tag:'PCI/6.5.2',\
1538
+ ver:'OWASP_CRS/4.9.0',\
1539
+ severity:'CRITICAL',\
1540
+ setvar:'tx.942521_matched_var_name=%{matched_var_name}',\
1541
+ chain"
1542
+ SecRule TX:1 "@rx ^(?:and|or)$" \
1543
+ "t:none,\
1544
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1545
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1546
+
1547
+
1548
+ # Complementary rule to PL2 942521 that block escaped quotes followed by (and|or)
1549
+ #
1550
+ SecRule ARGS_NAMES|ARGS|XML:/* "@rx ^.*?\x5c['\"`](?:.*?['\"`])?\s*(?:and|or)\b" \
1551
+ "id:942522,\
1552
+ phase:2,\
1553
+ block,\
1554
+ capture,\
1555
+ t:none,t:urlDecodeUni,\
1556
+ msg:'Detects basic SQL authentication bypass attempts 4.1/4',\
1557
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1558
+ tag:'application-multi',\
1559
+ tag:'language-multi',\
1560
+ tag:'platform-multi',\
1561
+ tag:'attack-sqli',\
1562
+ tag:'paranoia-level/2',\
1563
+ tag:'OWASP_CRS',\
1564
+ tag:'capec/1000/152/248/66',\
1565
+ tag:'PCI/6.5.2',\
1566
+ ver:'OWASP_CRS/4.9.0',\
1567
+ severity:'CRITICAL',\
1568
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1569
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1570
+
1571
+
1572
+ #
1573
+ # This is a sibling of rule 942100 that adds checking of the path.
1574
+ #
1575
+ # REQUEST_BASENAME provides the last url segment (slash excluded).
1576
+ # This segment is the most likely to be used for injections. Stripping out
1577
+ # the slash permits libinjection to do not consider it as a payload starting
1578
+ # with not unary arithmetical operators (not a valid SQL command, e.g.
1579
+ # '/9 union all'). The latter would lead to do not detect malicious payloads.
1580
+ #
1581
+ # REQUEST_FILENAME matches SQLi payloads inside (or across) other segments
1582
+ # of the path. Here, libinjection will detect a true positive only if
1583
+ # the url leading slash is considered as part of a comment block or part
1584
+ # of a string (with a quote or double quote after it). In these circumstances,
1585
+ # previous slashes do not affect libinjection result, making it able to detect
1586
+ # some SQLi inside the path.
1587
+ #
1588
+ SecRule REQUEST_BASENAME|REQUEST_FILENAME "@detectSQLi" \
1589
+ "id:942101,\
1590
+ phase:1,\
1591
+ block,\
1592
+ capture,\
1593
+ t:none,t:utf8toUnicode,t:urlDecodeUni,t:removeNulls,\
1594
+ msg:'SQL Injection Attack Detected via libinjection',\
1595
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1596
+ tag:'application-multi',\
1597
+ tag:'language-multi',\
1598
+ tag:'platform-multi',\
1599
+ tag:'attack-sqli',\
1600
+ tag:'paranoia-level/2',\
1601
+ tag:'OWASP_CRS',\
1602
+ tag:'capec/1000/152/248/66',\
1603
+ tag:'PCI/6.5.2',\
1604
+ ver:'OWASP_CRS/4.9.0',\
1605
+ severity:'CRITICAL',\
1606
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1607
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1608
+
1609
+ #
1610
+ # -=[ SQL Function Names ]=-
1611
+ #
1612
+ # This rule is a stricter sibling of 942151.
1613
+ # This rule 942152 checks for the same regex in request headers referer and user-agent.
1614
+ #
1615
+ # Regular expression generated from regex-assembly/942152.ra.
1616
+ # To update the regular expression run the following shell script
1617
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1618
+ # crs-toolchain regex update 942152
1619
+ #
1620
+ SecRule REQUEST_HEADERS:Referer|REQUEST_HEADERS:User-Agent "@rx (?i)\b(?:a(?:dd(?:dat|tim)e|es_(?:de|en)crypt|s(?:cii(?:str)?|in)|tan2?)|b(?:enchmark|i(?:n_to_num|t_(?:and|count|length|x?or)))|c(?:har(?:acter)?_length|iel(?:ing)?|o(?:alesce|ercibility|llation|(?:mpres)?s|n(?:cat(?:_ws)?|nection_id|v(?:ert(?:_tz)?)?)|t)|r32|ur(?:(?:dat|tim)e|rent_(?:date|setting|time(?:stamp)?|user)))|d(?:a(?:t(?:abase(?:_to_xml)?|e(?:_(?:add|format|sub)|diff))|y(?:name|of(?:month|week|year)))|count|e(?:code|grees|s_(?:de|en)crypt)|ump)|e(?:lt|n(?:c(?:ode|rypt)|ds_?with)|x(?:p(?:ort_set)?|tract(?:value)?))|f(?:i(?:el|n)d_in_set|ound_rows|rom_(?:base64|days|unixtime))|g(?:e(?:ometrycollection|t(?:_(?:format|lock)|pgusername))|(?:r(?:eates|oup_conca)|tid_subse)t)|hex(?:toraw)?|i(?:fnull|n(?:et6?_(?:aton|ntoa)|s(?:ert|tr)|terval)|s(?:_(?:(?:free|used)_lock|ipv(?:4(?:_(?:compat|mapped))?|6)|n(?:ot(?:_null)?|ull)|superuser)|null))|json(?:_(?:a(?:gg|rray(?:_(?:elements(?:_text)?|length))?)|build_(?:array|object)|e(?:ac|xtract_pat)h(?:_text)?|object(?:_(?:agg|keys))?|populate_record(?:set)?|strip_nulls|t(?:o_record(?:set)?|ypeof))|b(?:_(?:array(?:_(?:elements(?:_text)?|length))?|build_(?:array|object)|object(?:_(?:agg|keys))?|e(?:ac|xtract_pat)h(?:_text)?|insert|p(?:ath_(?:(?:exists|match)(?:_tz)?|query(?:_(?:(?:array|first)(?:_tz)?|tz))?)|opulate_record(?:set)?|retty)|s(?:et(?:_lax)?|trip_nulls)|t(?:o_record(?:set)?|ypeof)))?|path)?|l(?:ast_(?:day|inser_id)|case|e(?:as|f)t|i(?:kel(?:ihood|y)|nestring)|o(?:_(?:from_bytea|put)|ad_file|ca(?:ltimestamp|te)|g(?:10|2)|wer)|pad|trim)|m(?:a(?:ke(?:_set|date)|ster_pos_wait)|d5|i(?:crosecon)?d|onthname|ulti(?:linestring|po(?:int|lygon)))|n(?:ame_const|ot_in|ullif)|o(?:ct(?:et_length)?|(?:ld_passwo)?rd)|p(?:eriod_(?:add|diff)|g_(?:client_encoding|(?:databas|read_fil)e|l(?:argeobject|s_dir)|sleep|user)|o(?:(?:lyg|siti)on|w)|rocedure_analyse)|qu(?:arter|ery_to_xml|ote)|r(?:a(?:dians|nd|wtohex)|elease_lock|ow_(?:count|to_json)|pad|trim)|s(?:chema|e(?:c_to_time|ssion_user)|ha[12]?|in|oundex|pace|q(?:lite_(?:compileoption_(?:get|used)|source_id)|rt)|t(?:arts_?with|d(?:dev_(?:po|sam)p)?|r(?:_to_date|cmp))|ub(?:(?:dat|tim)e|str(?:ing(?:_index)?)?)|ys(?:date|tem_user))|t(?:ime(?:_(?:format|to_sec)|diff|stamp(?:add|diff)?)|o(?:_(?:base64|jsonb?)|n?char|(?:day|second)s)|r(?:im|uncate))|u(?:case|n(?:compress(?:ed_length)?|hex|i(?:str|x_timestamp)|likely)|(?:pdatexm|se_json_nul)l|tc_(?:date|time(?:stamp)?)|uid(?:_short)?)|var(?:_(?:po|sam)p|iance)|we(?:ek(?:day|ofyear)|ight_string)|xmltype|yearweek)[^0-9A-Z_a-z]*\(" \
1621
+ "id:942152,\
1622
+ phase:1,\
1623
+ block,\
1624
+ capture,\
1625
+ t:none,t:urlDecodeUni,\
1626
+ msg:'SQL Injection Attack: SQL function name detected',\
1627
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1628
+ tag:'application-multi',\
1629
+ tag:'language-multi',\
1630
+ tag:'platform-multi',\
1631
+ tag:'attack-sqli',\
1632
+ tag:'paranoia-level/2',\
1633
+ tag:'OWASP_CRS',\
1634
+ tag:'capec/1000/152/248/66',\
1635
+ tag:'PCI/6.5.2',\
1636
+ ver:'OWASP_CRS/4.9.0',\
1637
+ severity:'CRITICAL',\
1638
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1639
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1640
+
1641
+ #
1642
+ # This rule is a stricter sibling of 942320.
1643
+ # It checks for the same regex in request headers referer and user-agent.
1644
+ #
1645
+ # Regular expression generated from regex-assembly/942321.ra.
1646
+ # To update the regular expression run the following shell script
1647
+ # (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
1648
+ # crs-toolchain regex update 942321
1649
+ #
1650
+ SecRule REQUEST_HEADERS:Referer|REQUEST_HEADERS:User-Agent "@rx (?i)create[\s\x0b]+(?:function|procedure)[\s\x0b]*?[0-9A-Z_a-z]+[\s\x0b]*?\([\s\x0b]*?\)[\s\x0b]*?-|d(?:eclare[^0-9A-Z_a-z]+[#@][\s\x0b]*?[0-9A-Z_a-z]+|iv[\s\x0b]*?\([\+\-]*[\s\x0b\.0-9]+,[\+\-]*[\s\x0b\.0-9]+\))|exec[\s\x0b]*?\([\s\x0b]*?@|(?:lo_(?:impor|ge)t|procedure[\s\x0b]+analyse)[\s\x0b]*?\(|;[\s\x0b]*?(?:declare|open)[\s\x0b]+[\-0-9A-Z_a-z]+|::(?:b(?:igint|ool)|double[\s\x0b]+precision|int(?:eger)?|numeric|oid|real|(?:tex|smallin)t)" \
1651
+ "id:942321,\
1652
+ phase:1,\
1653
+ block,\
1654
+ capture,\
1655
+ t:none,t:urlDecodeUni,\
1656
+ msg:'Detects MySQL and PostgreSQL stored procedure/function injections',\
1657
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1658
+ tag:'application-multi',\
1659
+ tag:'language-multi',\
1660
+ tag:'platform-multi',\
1661
+ tag:'attack-sqli',\
1662
+ tag:'paranoia-level/2',\
1663
+ tag:'OWASP_CRS',\
1664
+ tag:'capec/1000/152/248/66',\
1665
+ tag:'PCI/6.5.2',\
1666
+ ver:'OWASP_CRS/4.9.0',\
1667
+ severity:'CRITICAL',\
1668
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1669
+ setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
1670
+
1671
+
1672
+
1673
+ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 3" "id:942015,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.9.0',skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
1674
+ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 3" "id:942016,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.9.0',skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
1675
+ #
1676
+ # -= Paranoia Level 3 =- (apply only when tx.detection_paranoia_level is sufficiently high: 3 or higher)
1677
+ #
1678
+
1679
+
1680
+ #
1681
+ # [ SQL HAVING queries ]
1682
+ #
1683
+ # This pattern was split off from rule 942250 due to frequent
1684
+ # false positives in English text. Testing showed that SQL
1685
+ # injections with HAVING should be detected by libinjection
1686
+ # (rule 942100).
1687
+ #
1688
+ # This is a stricter sibling of rule 942250.
1689
+ #
1690
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?i)\W+\d*?\s*?\bhaving\b\s*?[^\s\-]" \
1691
+ "id:942251,\
1692
+ phase:2,\
1693
+ block,\
1694
+ capture,\
1695
+ t:none,t:urlDecodeUni,\
1696
+ msg:'Detects HAVING injections',\
1697
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1698
+ tag:'application-multi',\
1699
+ tag:'language-multi',\
1700
+ tag:'platform-multi',\
1701
+ tag:'attack-sqli',\
1702
+ tag:'paranoia-level/3',\
1703
+ tag:'OWASP_CRS',\
1704
+ tag:'capec/1000/152/248/66',\
1705
+ tag:'PCI/6.5.2',\
1706
+ ver:'OWASP_CRS/4.9.0',\
1707
+ severity:'CRITICAL',\
1708
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1709
+ setvar:'tx.inbound_anomaly_score_pl3=+%{tx.critical_anomaly_score}'"
1710
+
1711
+ # This rule is a stricter sibling of 942330. See that rule for a
1712
+ # description and overview.
1713
+ #
1714
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx [\"'`][\s\d]*?[^\w\s]\W*?\d\W*?.*?[\"'`\d]" \
1715
+ "id:942490,\
1716
+ phase:2,\
1717
+ block,\
1718
+ capture,\
1719
+ t:none,t:urlDecodeUni,\
1720
+ msg:'Detects classic SQL injection probings 3/3',\
1721
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1722
+ tag:'application-multi',\
1723
+ tag:'language-multi',\
1724
+ tag:'platform-multi',\
1725
+ tag:'attack-sqli',\
1726
+ tag:'paranoia-level/3',\
1727
+ tag:'OWASP_CRS',\
1728
+ tag:'capec/1000/152/248/66',\
1729
+ tag:'PCI/6.5.2',\
1730
+ ver:'OWASP_CRS/4.9.0',\
1731
+ severity:'CRITICAL',\
1732
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1733
+ setvar:'tx.inbound_anomaly_score_pl3=+%{tx.critical_anomaly_score}'"
1734
+
1735
+ #
1736
+ # [ SQL Injection Character Anomaly Usage ]
1737
+ #
1738
+ # This rule attempts to gauge when there is an excessive use of
1739
+ # meta-characters within a single parameter payload.
1740
+ #
1741
+ # It is similar to 942430, but focuses on Cookies instead of
1742
+ # GET/POST parameters.
1743
+ #
1744
+ # Expect a lot of false positives with this rule.
1745
+ # The most likely false positive instances will be complex session ids.
1746
+ # This will make it necessary to disable the rule for certain known cookies.
1747
+ # The following directive is an example to switch off the rule globally for
1748
+ # the cookie foo_id. Place this instruction in your configuration after
1749
+ # the include directive for the Core Rules Set.
1750
+ #
1751
+ # SecRuleUpdateTargetById 942420 "!REQUEST_COOKIES:foo_id"
1752
+ #
1753
+
1754
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){8})" \
1755
+ "id:942420,\
1756
+ phase:1,\
1757
+ block,\
1758
+ capture,\
1759
+ t:none,t:urlDecodeUni,\
1760
+ msg:'Restricted SQL Character Anomaly Detection (cookies): # of special characters exceeded (8)',\
1761
+ logdata:'Matched Data: %{TX.1} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1762
+ tag:'application-multi',\
1763
+ tag:'language-multi',\
1764
+ tag:'platform-multi',\
1765
+ tag:'attack-sqli',\
1766
+ tag:'paranoia-level/3',\
1767
+ tag:'OWASP_CRS',\
1768
+ tag:'capec/1000/152/248/66',\
1769
+ tag:'PCI/6.5.2',\
1770
+ ver:'OWASP_CRS/4.9.0',\
1771
+ severity:'WARNING',\
1772
+ setvar:'tx.inbound_anomaly_score_pl3=+%{tx.warning_anomaly_score}',\
1773
+ setvar:'tx.sql_injection_score=+%{tx.warning_anomaly_score}'"
1774
+
1775
+
1776
+ #
1777
+ # This is a stricter sibling of rule 942430.
1778
+ #
1779
+ # This rule is also triggered by the following exploit(s):
1780
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
1781
+ #
1782
+
1783
+ SecRule ARGS_NAMES|ARGS|XML:/* "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){6})" \
1784
+ "id:942431,\
1785
+ phase:2,\
1786
+ block,\
1787
+ capture,\
1788
+ t:none,t:urlDecodeUni,\
1789
+ msg:'Restricted SQL Character Anomaly Detection (args): # of special characters exceeded (6)',\
1790
+ logdata:'Matched Data: %{TX.1} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1791
+ tag:'application-multi',\
1792
+ tag:'language-multi',\
1793
+ tag:'platform-multi',\
1794
+ tag:'attack-sqli',\
1795
+ tag:'paranoia-level/3',\
1796
+ tag:'OWASP_CRS',\
1797
+ tag:'capec/1000/152/248/66',\
1798
+ tag:'PCI/6.5.2',\
1799
+ ver:'OWASP_CRS/4.9.0',\
1800
+ severity:'WARNING',\
1801
+ setvar:'tx.inbound_anomaly_score_pl3=+%{tx.warning_anomaly_score}',\
1802
+ setvar:'tx.sql_injection_score=+%{tx.warning_anomaly_score}'"
1803
+
1804
+
1805
+ #
1806
+ # [ Repetitive Non-Word Characters ]
1807
+ #
1808
+ # This rule attempts to identify when multiple (4 or more) non-word characters
1809
+ # are repeated in sequence.
1810
+ #
1811
+ # The pattern may occur in some normal texts, e.g. "foo...." will match.
1812
+ #
1813
+ SecRule ARGS "@rx \W{4}" \
1814
+ "id:942460,\
1815
+ phase:2,\
1816
+ block,\
1817
+ capture,\
1818
+ t:none,\
1819
+ msg:'Meta-Character Anomaly Detection Alert - Repetitive Non-Word Characters',\
1820
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1821
+ tag:'application-multi',\
1822
+ tag:'language-multi',\
1823
+ tag:'platform-multi',\
1824
+ tag:'attack-sqli',\
1825
+ tag:'paranoia-level/3',\
1826
+ tag:'OWASP_CRS',\
1827
+ tag:'capec/1000/152/248/66',\
1828
+ tag:'PCI/6.5.2',\
1829
+ ver:'OWASP_CRS/4.9.0',\
1830
+ severity:'WARNING',\
1831
+ setvar:'tx.sql_injection_score=+%{tx.warning_anomaly_score}',\
1832
+ setvar:'tx.inbound_anomaly_score_pl3=+%{tx.warning_anomaly_score}'"
1833
+
1834
+
1835
+ #
1836
+ # -=[ Detect SQLi bypass: quotes ]=-
1837
+ #
1838
+ # Quotes and backticks can be used to bypass SQLi detection.
1839
+ #
1840
+ # Example:
1841
+ # GET http://localhost/test.php?id=9999%20or+{`if`(2=(select+2+from+wp_users+where+user_login='admin'))}
1842
+ #
1843
+ # The minimum text between the ticks or backticks must be 2 (if, for example) and a maximum of 29.
1844
+ # 29 is a compromise: The lower this number (29), the lower the probability of FP and the higher the probability of false negatives.
1845
+ # In tests we got a minimum number of FP with {2,29}.
1846
+ #
1847
+ # Base64 encoding detection:
1848
+ # (?:[A-Za-z0-9+/]{4})+ #match any number of 4-letter blocks of the base64 char set
1849
+ # (?:[A-Za-z0-9+/]{2}== #match 2-letter block of the base64 char set followed by "==", together forming a 4-letter block
1850
+ # | # or
1851
+ # [A-Za-z0-9+/]{3}= #match 3-letter block of the base64 char set followed by "=", together forming a 4-letter block
1852
+ # )?
1853
+ #
1854
+ # The minimal string that triggers this regexp is: 'if'
1855
+ #
1856
+ # The rule 942510 is similar to this rule, but triggers on backticks
1857
+ # (`if`). That rule runs in paranoia level 2 or higher since the risk of
1858
+ # false positives in natural text is still present but lower than this
1859
+ # rule.
1860
+ #
1861
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?:'(?:(?:[\w\s=_\-+{}()<@]){2,29}|(?:[A-Za-z0-9+/]{4})+(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)')" \
1862
+ "id:942511,\
1863
+ phase:2,\
1864
+ block,\
1865
+ capture,\
1866
+ t:none,t:urlDecodeUni,\
1867
+ msg:'SQLi bypass attempt by ticks detected',\
1868
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1869
+ tag:'application-multi',\
1870
+ tag:'language-multi',\
1871
+ tag:'platform-multi',\
1872
+ tag:'attack-sqli',\
1873
+ tag:'paranoia-level/3',\
1874
+ tag:'OWASP_CRS',\
1875
+ tag:'capec/1000/152/248/66',\
1876
+ tag:'PCI/6.5.2',\
1877
+ ver:'OWASP_CRS/4.9.0',\
1878
+ severity:'CRITICAL',\
1879
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1880
+ setvar:'tx.inbound_anomaly_score_pl3=+%{tx.critical_anomaly_score}'"
1881
+
1882
+ # Detects ';
1883
+ # ' Single quote. Used to delineate a query with an unmatched quote.
1884
+ # ; Terminate a query. A prematurely terminated query creates an error.
1885
+ # Explanation source:
1886
+ # https://hwang.cisdept.cpp.edu/swanew/Text/SQL-Injection.htm
1887
+ #
1888
+ # Bug Bounty example: email=admin@juice-sh.op';&password=foo
1889
+ #
1890
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx ';" \
1891
+ "id:942530,\
1892
+ phase:2,\
1893
+ block,\
1894
+ capture,\
1895
+ t:none,t:urlDecodeUni,\
1896
+ msg:'SQLi query termination detected',\
1897
+ logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1898
+ tag:'application-multi',\
1899
+ tag:'language-multi',\
1900
+ tag:'platform-multi',\
1901
+ tag:'attack-sqli',\
1902
+ tag:'paranoia-level/3',\
1903
+ tag:'OWASP_CRS',\
1904
+ tag:'capec/1000/152/248/66',\
1905
+ tag:'PCI/6.5.2',\
1906
+ ver:'OWASP_CRS/4.9.0',\
1907
+ severity:'CRITICAL',\
1908
+ setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1909
+ setvar:'tx.inbound_anomaly_score_pl3=+%{tx.critical_anomaly_score}'"
1910
+
1911
+
1912
+ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 4" "id:942017,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.9.0',skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
1913
+ SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 4" "id:942018,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.9.0',skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
1914
+ #
1915
+ # -= Paranoia Level 4 =- (apply only when tx.detection_paranoia_level is sufficiently high: 4 or higher)
1916
+ #
1917
+
1918
+ #
1919
+ # [ SQL Injection Character Anomaly Usage ]
1920
+ #
1921
+ # This is a stricter sibling of rule 942420.
1922
+ #
1923
+
1924
+ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQUEST_COOKIES_NAMES "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){3})" \
1925
+ "id:942421,\
1926
+ phase:1,\
1927
+ block,\
1928
+ capture,\
1929
+ t:none,t:urlDecodeUni,\
1930
+ msg:'Restricted SQL Character Anomaly Detection (cookies): # of special characters exceeded (3)',\
1931
+ logdata:'Matched Data: %{TX.1} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1932
+ tag:'application-multi',\
1933
+ tag:'language-multi',\
1934
+ tag:'platform-multi',\
1935
+ tag:'attack-sqli',\
1936
+ tag:'paranoia-level/4',\
1937
+ tag:'OWASP_CRS',\
1938
+ tag:'capec/1000/152/248/66',\
1939
+ tag:'PCI/6.5.2',\
1940
+ ver:'OWASP_CRS/4.9.0',\
1941
+ severity:'WARNING',\
1942
+ setvar:'tx.inbound_anomaly_score_pl4=+%{tx.warning_anomaly_score}',\
1943
+ setvar:'tx.sql_injection_score=+%{tx.warning_anomaly_score}'"
1944
+
1945
+
1946
+ #
1947
+ # This is a stricter sibling of rule 942430.
1948
+ #
1949
+ # This rule is also triggered by the following exploit(s):
1950
+ # [ SAP CRM Java vulnerability CVE-2018-2380 - Exploit tested: https://www.exploit-db.com/exploits/44292 ]
1951
+ #
1952
+
1953
+ SecRule ARGS_NAMES|ARGS|XML:/* "@rx ((?:[~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>][^~!@#\$%\^&\*\(\)\-\+=\{\}\[\]\|:;\"'´’‘`<>]*?){2})" \
1954
+ "id:942432,\
1955
+ phase:2,\
1956
+ block,\
1957
+ capture,\
1958
+ t:none,t:urlDecodeUni,\
1959
+ msg:'Restricted SQL Character Anomaly Detection (args): # of special characters exceeded (2)',\
1960
+ logdata:'Matched Data: %{TX.1} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1961
+ tag:'application-multi',\
1962
+ tag:'language-multi',\
1963
+ tag:'platform-multi',\
1964
+ tag:'attack-sqli',\
1965
+ tag:'paranoia-level/4',\
1966
+ tag:'OWASP_CRS',\
1967
+ tag:'capec/1000/152/248/66',\
1968
+ tag:'PCI/6.5.2',\
1969
+ ver:'OWASP_CRS/4.9.0',\
1970
+ severity:'WARNING',\
1971
+ setvar:'tx.inbound_anomaly_score_pl4=+%{tx.warning_anomaly_score}',\
1972
+ setvar:'tx.sql_injection_score=+%{tx.warning_anomaly_score}'"
1973
+
1974
+
1975
+ #
1976
+ # -= Paranoia Levels Finished =-
1977
+ #
1978
+ SecMarker "END-REQUEST-942-APPLICATION-ATTACK-SQLI"