@abtnode/router-provider 1.16.38-beta-20250116-083413-dbd33222 → 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,857 @@
1
+ /* eslint-disable */
2
+ module.exports = ({
3
+ inboundAnomalyScoreThreshold,
4
+ outboundAnomalyScoreThreshold,
5
+ }) => `# ------------------------------------------------------------------------
6
+ # OWASP CRS ver.4.9.0
7
+ # Copyright (c) 2006-2020 Trustwave and contributors. All rights reserved.
8
+ # Copyright (c) 2021-2024 CRS project. All rights reserved.
9
+ #
10
+ # The OWASP CRS is distributed under
11
+ # Apache Software License (ASL) version 2
12
+ # Please see the enclosed LICENSE file for full details.
13
+ # ------------------------------------------------------------------------
14
+
15
+
16
+ #
17
+ # -- [[ Introduction ]] --------------------------------------------------------
18
+ #
19
+ # The OWASP CRS is a set of generic attack
20
+ # detection rules that provide a base level of protection for any web
21
+ # application. They are written for the open source, cross-platform
22
+ # ModSecurity Web Application Firewall.
23
+ #
24
+ # See also:
25
+ # https://coreruleset.org/
26
+ # https://github.com/coreruleset/coreruleset
27
+ # https://owasp.org/www-project-modsecurity-core-rule-set/
28
+ #
29
+
30
+
31
+ #
32
+ # -- [[ System Requirements ]] -------------------------------------------------
33
+ #
34
+ # CRS requires ModSecurity version 2.8.0 or above.
35
+ # We recommend to always use the newest ModSecurity version.
36
+ #
37
+ # The configuration directives/settings in this file are used to control
38
+ # the OWASP ModSecurity CRS. These settings do **NOT** configure the main
39
+ # ModSecurity settings (modsecurity.conf) such as SecRuleEngine,
40
+ # SecRequestBodyAccess, SecAuditEngine, SecDebugLog, and XML processing.
41
+ #
42
+ # The CRS assumes that modsecurity.conf has been loaded. It is bundled with
43
+ # ModSecurity. If you don't have it, you can get it from:
44
+ # 2.x: https://raw.githubusercontent.com/SpiderLabs/ModSecurity/v2/master/modsecurity.conf-recommended
45
+ # 3.x: https://raw.githubusercontent.com/SpiderLabs/ModSecurity/v3/master/modsecurity.conf-recommended
46
+ #
47
+ # The order of file inclusion in your webserver configuration should always be:
48
+ # 1. modsecurity.conf
49
+ # 2. crs-setup.conf (this file)
50
+ # 3. rules/*.conf (the CRS rule files)
51
+ #
52
+ # Please refer to the INSTALL file for detailed installation instructions.
53
+ #
54
+
55
+
56
+ #
57
+ # -- [[ Mode of Operation: Anomaly Scoring vs. Self-Contained ]] ---------------
58
+ #
59
+ # The CRS can run in two modes:
60
+ #
61
+ # -- [[ Anomaly Scoring Mode (default) ]] --
62
+ # In CRS3, anomaly mode is the default and recommended mode, since it gives the
63
+ # most accurate log information and offers the most flexibility in setting your
64
+ # blocking policies. It is also called "collaborative detection mode".
65
+ # In this mode, each matching rule increases an 'anomaly score'.
66
+ # At the conclusion of the inbound rules, and again at the conclusion of the
67
+ # outbound rules, the anomaly score is checked, and the blocking evaluation
68
+ # rules apply a disruptive action, by default returning an error 403.
69
+ #
70
+ # -- [[ Self-Contained Mode ]] --
71
+ # In this mode, rules apply an action instantly. This was the CRS2 default.
72
+ # It can lower resource usage, at the cost of less flexibility in blocking policy
73
+ # and less informative audit logs (only the first detected threat is logged).
74
+ # Rules inherit the disruptive action that you specify (i.e. deny, drop, etc).
75
+ # The first rule that matches will execute this action. In most cases this will
76
+ # cause evaluation to stop after the first rule has matched, similar to how many
77
+ # IDSs function.
78
+ #
79
+ # -- [[ Alert Logging Control ]] --
80
+ # In the mode configuration, you must also adjust the desired logging options.
81
+ # There are three common options for dealing with logging. By default CRS enables
82
+ # logging to the webserver error log (or Event viewer) plus detailed logging to
83
+ # the ModSecurity audit log (configured under SecAuditLog in modsecurity.conf).
84
+ #
85
+ # - To log to both error log and ModSecurity audit log file, use: "log,auditlog"
86
+ # - To log *only* to the ModSecurity audit log file, use: "nolog,auditlog"
87
+ # - To log *only* to the error log file, use: "log,noauditlog"
88
+ #
89
+ # Examples for the various modes follow.
90
+ # You must leave one of the following options enabled.
91
+ # Note that you must specify the same line for phase:1 and phase:2.
92
+ #
93
+
94
+ # Default: Anomaly Scoring mode, log to error log, log to ModSecurity audit log
95
+ # - By default, offending requests are blocked with an error 403 response.
96
+ # - To change the disruptive action, see RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example
97
+ # and review section 'Changing the Disruptive Action for Anomaly Mode'.
98
+ # - In Apache, you can use ErrorDocument to show a friendly error page or
99
+ # perform a redirect: https://httpd.apache.org/docs/2.4/custom-error.html
100
+ #
101
+ SecDefaultAction "phase:1,log,auditlog,pass"
102
+ SecDefaultAction "phase:2,log,auditlog,pass"
103
+
104
+ # Example: Anomaly Scoring mode, log only to ModSecurity audit log
105
+ # - By default, offending requests are blocked with an error 403 response.
106
+ # - To change the disruptive action, see RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example
107
+ # and review section 'Changing the Disruptive Action for Anomaly Mode'.
108
+ # - In Apache, you can use ErrorDocument to show a friendly error page or
109
+ # perform a redirect: https://httpd.apache.org/docs/2.4/custom-error.html
110
+ #
111
+ # SecDefaultAction "phase:1,nolog,auditlog,pass"
112
+ # SecDefaultAction "phase:2,nolog,auditlog,pass"
113
+
114
+ # Example: Self-contained mode, return error 403 on blocking
115
+ # - In this configuration the default disruptive action becomes 'deny'. After a
116
+ # rule triggers, it will stop processing the request and return an error 403.
117
+ # - You can also use a different error status, such as 404, 406, et cetera.
118
+ # - In Apache, you can use ErrorDocument to show a friendly error page or
119
+ # perform a redirect: https://httpd.apache.org/docs/2.4/custom-error.html
120
+ #
121
+ # SecDefaultAction "phase:1,log,auditlog,deny,status:403"
122
+ # SecDefaultAction "phase:2,log,auditlog,deny,status:403"
123
+
124
+ # Example: Self-contained mode, redirect back to homepage on blocking
125
+ # - In this configuration the 'tag' action includes the Host header data in the
126
+ # log. This helps to identify which virtual host triggered the rule (if any).
127
+ # - Note that this might cause redirect loops in some situations; for example
128
+ # if a Cookie or User-Agent header is blocked, it will also be blocked when
129
+ # the client subsequently tries to access the homepage. You can also redirect
130
+ # to another custom URL.
131
+ # SecDefaultAction "phase:1,log,auditlog,redirect:'http://%{request_headers.host}/',tag:'Host: %{request_headers.host}'"
132
+ # SecDefaultAction "phase:2,log,auditlog,redirect:'http://%{request_headers.host}/',tag:'Host: %{request_headers.host}'"
133
+
134
+
135
+ #
136
+ # -- [[ Paranoia Level Initialization ]] ---------------------------------------
137
+ #
138
+ # The Paranoia Level (PL) setting allows you to choose the desired level
139
+ # of rule checks that will add to your anomaly scores.
140
+ #
141
+ # With each paranoia level increase, the CRS enables additional rules
142
+ # giving you a higher level of security. However, higher paranoia levels
143
+ # also increase the possibility of blocking some legitimate traffic due to
144
+ # false alarms (also named false positives or FPs). If you use higher
145
+ # paranoia levels, it is likely that you will need to add some exclusion
146
+ # rules for certain requests and applications receiving complex input.
147
+ #
148
+ # - A paranoia level of 1 is default. In this level, most core rules
149
+ # are enabled. PL1 is advised for beginners, installations
150
+ # covering many different sites and applications, and for setups
151
+ # with standard security requirements.
152
+ # At PL1 you should face FPs rarely. If you encounter FPs, please
153
+ # open an issue on the CRS GitHub site and don't forget to attach your
154
+ # complete Audit Log record for the request with the issue.
155
+ # - Paranoia level 2 includes many extra rules, for instance enabling
156
+ # many regexp-based SQL and XSS injection protections, and adding
157
+ # extra keywords checked for code injections. PL2 is advised
158
+ # for moderate to experienced users desiring more complete coverage
159
+ # and for installations with elevated security requirements.
160
+ # PL2 comes with some FPs which you need to handle.
161
+ # - Paranoia level 3 enables more rules and keyword lists, and tweaks
162
+ # limits on special characters used. PL3 is aimed at users experienced
163
+ # at the handling of FPs and at installations with a high security
164
+ # requirement.
165
+ # - Paranoia level 4 further restricts special characters.
166
+ # The highest level is advised for experienced users protecting
167
+ # installations with very high security requirements. Running PL4 will
168
+ # likely produce a very high number of FPs which have to be
169
+ # treated before the site can go productive.
170
+ #
171
+ # All rules will log their PL to the audit log;
172
+ # example: [tag "paranoia-level/2"]. This allows you to deduct from the
173
+ # audit log how the WAF behavior is affected by paranoia level.
174
+ #
175
+ # It is important to also look into the variable
176
+ # tx.enforce_bodyproc_urlencoded (Enforce Body Processor URLENCODED)
177
+ # defined below. Enabling it closes a possible bypass of CRS.
178
+ #
179
+ # Uncomment this rule to change the default:
180
+ #
181
+ #SecAction \
182
+ # "id:900000,\
183
+ # phase:1,\
184
+ # pass,\
185
+ # t:none,\
186
+ # nolog,\
187
+ # tag:'OWASP_CRS',\
188
+ # ver:'OWASP_CRS/4.9.0',\
189
+ # setvar:tx.blocking_paranoia_level=1"
190
+
191
+
192
+ # It is possible to execute rules from a higher paranoia level but not include
193
+ # them in the anomaly scoring. This allows you to take a well-tuned system on
194
+ # paranoia level 1 and add rules from paranoia level 2 without having to fear
195
+ # the new rules would lead to false positives that raise your score above the
196
+ # threshold.
197
+ # This optional feature is enabled by uncommenting the following rule and
198
+ # setting the tx.detection_paranoia_level.
199
+ # Technically, rules up to the level defined in tx.detection_paranoia_level
200
+ # will be executed, but only the rules up to tx.blocking_paranoia_level affect the
201
+ # anomaly scores.
202
+ # By default, tx.detection_paranoia_level is set to tx.blocking_paranoia_level.
203
+ # tx.detection_paranoia_level must not be lower than tx.blocking_paranoia_level.
204
+ #
205
+ # Please notice that setting tx.detection_paranoia_level to a higher paranoia
206
+ # level results in a performance impact that is equally high as setting
207
+ # tx.blocking_paranoia_level to said level.
208
+ #
209
+ #SecAction \
210
+ # "id:900001,\
211
+ # phase:1,\
212
+ # pass,\
213
+ # t:none,\
214
+ # nolog,\
215
+ # tag:'OWASP_CRS',\
216
+ # ver:'OWASP_CRS/4.9.0',\
217
+ # setvar:tx.detection_paranoia_level=1"
218
+
219
+
220
+ #
221
+ # -- [[ Enforce Body Processor URLENCODED ]] -----------------------------------
222
+ #
223
+ # ModSecurity selects the body processor based on the Content-Type request
224
+ # header. But clients are not always setting the Content-Type header for their
225
+ # request body payloads. This will leave ModSecurity with limited vision into
226
+ # the payload. The variable tx.enforce_bodyproc_urlencoded lets you force the
227
+ # URLENCODED body processor in these situations. This is off by default, as it
228
+ # implies a change of the behaviour of ModSecurity beyond CRS (the body
229
+ # processor applies to all rules, not only CRS) and because it may lead to
230
+ # false positives already on paranoia level 1. However, enabling this variable
231
+ # closes a possible bypass of CRS so it should be considered.
232
+ #
233
+ # Uncomment this rule to change the default:
234
+ #
235
+ #SecAction \
236
+ # "id:900010,\
237
+ # phase:1,\
238
+ # pass,\
239
+ # t:none,\
240
+ # nolog,\
241
+ # tag:'OWASP_CRS',\
242
+ # ver:'OWASP_CRS/4.9.0',\
243
+ # setvar:tx.enforce_bodyproc_urlencoded=1"
244
+
245
+
246
+ #
247
+ # -- [[ Anomaly Scoring Mode Severity Levels ]] --------------------------------
248
+ #
249
+ # Each rule in the CRS has an associated severity level.
250
+ # These are the default scoring points for each severity level.
251
+ # These settings will be used to increment the anomaly score if a rule matches.
252
+ # You may adjust these points to your liking, but this is usually not needed.
253
+ #
254
+ # - CRITICAL severity: Anomaly Score of 5.
255
+ # Mostly generated by the application attack rules (93x and 94x files).
256
+ # - ERROR severity: Anomaly Score of 4.
257
+ # Generated mostly from outbound leakage rules (95x files).
258
+ # - WARNING severity: Anomaly Score of 3.
259
+ # Generated mostly by malicious client rules (91x files).
260
+ # - NOTICE severity: Anomaly Score of 2.
261
+ # Generated mostly by the protocol rules (92x files).
262
+ #
263
+ # In anomaly mode, these scores are cumulative.
264
+ # So it's possible for a request to hit multiple rules.
265
+ #
266
+ # (Note: In this file, we use 'phase:1' to set CRS configuration variables.
267
+ # In general, 'phase:request' is used. However, we want to make absolutely sure
268
+ # that all configuration variables are set before the CRS rules are processed.)
269
+ #
270
+ #SecAction \
271
+ # "id:900100,\
272
+ # phase:1,\
273
+ # pass,\
274
+ # t:none,\
275
+ # nolog,\
276
+ # tag:'OWASP_CRS',\
277
+ # ver:'OWASP_CRS/4.9.0',\
278
+ # setvar:tx.critical_anomaly_score=5,\
279
+ # setvar:tx.error_anomaly_score=4,\
280
+ # setvar:tx.warning_anomaly_score=3,\
281
+ # setvar:tx.notice_anomaly_score=2"
282
+
283
+
284
+ #
285
+ # -- [[ Anomaly Scoring Mode Blocking Threshold Levels ]] ----------------------
286
+ #
287
+ # Here, you can specify at which cumulative anomaly score an inbound request,
288
+ # or outbound response, gets blocked.
289
+ #
290
+ # Most detected inbound threats will give a critical score of 5.
291
+ # Smaller violations, like violations of protocol/standards, carry lower scores.
292
+ #
293
+ # [ At default value ]
294
+ # If you keep the blocking thresholds at the defaults, the CRS will work
295
+ # similarly to previous CRS versions: a single critical rule match will cause
296
+ # the request to be blocked and logged.
297
+ #
298
+ # [ Using higher values ]
299
+ # If you want to make the CRS less sensitive, you can increase the blocking
300
+ # thresholds, for instance to 7 (which would require multiple rule matches
301
+ # before blocking) or 10 (which would require at least two critical alerts - or
302
+ # a combination of many lesser alerts), or even higher. However, increasing the
303
+ # thresholds might cause some attacks to bypass the CRS rules or your policies.
304
+ #
305
+ # [ New deployment strategy: Starting high and decreasing ]
306
+ # It is a common practice to start a fresh CRS installation with elevated
307
+ # anomaly scoring thresholds (>100) and then lower the limits as your
308
+ # confidence in the setup grows. You may also look into the Sampling
309
+ # Percentage section below for a different strategy to ease into a new
310
+ # CRS installation.
311
+ #
312
+ # [ Anomaly Threshold / Paranoia Level Quadrant ]
313
+ #
314
+ # High Anomaly Limit | High Anomaly Limit
315
+ # Low Paranoia Level | High Paranoia Level
316
+ # -> Fresh Site | -> Experimental Site
317
+ # ------------------------------------------------------
318
+ # Low Anomaly Limit | Low Anomaly Limit
319
+ # Low Paranoia Level | High Paranoia Level
320
+ # -> Standard Site | -> High Security Site
321
+ #
322
+ # Uncomment this rule to change the defaults:
323
+ #
324
+ SecAction \
325
+ "id:900110,\
326
+ phase:1,\
327
+ pass,\
328
+ t:none,\
329
+ nolog,\
330
+ tag:'OWASP_CRS',\
331
+ ver:'OWASP_CRS/4.9.0',\
332
+ setvar:tx.inbound_anomaly_score_threshold=${inboundAnomalyScoreThreshold},\
333
+ setvar:tx.outbound_anomaly_score_threshold=${outboundAnomalyScoreThreshold}"
334
+
335
+
336
+ #
337
+ # -- [[ Application Specific Rule Exclusions ]] --------------------------------
338
+ #
339
+ # CRS 3.x contained exclusion packages to tweak the CRS for use with common
340
+ # web applications, lowering the number of false positives.
341
+ #
342
+ # In CRS 4, these are no longer part of the CRS itself, but they are available
343
+ # as "CRS plugins". Some plugins improve support for web applications, and others
344
+ # may bring new functionality. Plugins are not installed by default, but can be
345
+ # downloaded from the plugin registry:
346
+ # https://github.com/coreruleset/plugin-registry
347
+ #
348
+ # For detailed information about using and installing plugins, please see:
349
+ # https://coreruleset.org/docs/concepts/plugins/
350
+
351
+
352
+ #
353
+ # -- [[ Anomaly Score Reporting Level ]] ---------------------------------------
354
+ #
355
+ # When a request is blocked due to the anomaly score meeting or exceeding the
356
+ # anomaly threshold then the blocking rule will also report the anomaly score.
357
+ # This applies to the separate inbound and outbound anomaly scores.
358
+ #
359
+ # In phase 5, there are additional rules that can perform additional reporting
360
+ # of anomaly scores with a verbosity that depends on the reporting level defined
361
+ # below.
362
+ #
363
+ # By setting the reporting level you control whether you want additional
364
+ # reporting beyond the blocking rule or not and, if yes, which requests should
365
+ # be covered. The higher the reporting level, the more verbose the reporting is.
366
+ #
367
+ # There are 6 reporting levels:
368
+ #
369
+ # 0 - Reporting disabled
370
+ # 1 - Reporting for requests with a blocking anomaly score >= a threshold
371
+ # 2 - Reporting for requests with a detection anomaly score >= a threshold
372
+ # 3 - Reporting for requests with a blocking anomaly score greater than 0
373
+ # 4 - Reporting for requests with a detection anomaly score greater than 0
374
+ # 5 - Reporting for all requests
375
+ #
376
+ # Note: Reporting levels 1 and 2 make it possible to differentiate between
377
+ # requests that are blocked and requests that are *not* blocked but would have
378
+ # been blocked if the blocking PL was equal to detection PL. This may be useful
379
+ # for certain FP tuning methodologies, for example moving to a higher PL.
380
+ #
381
+ # A value of 5 can be useful on platforms where you are interested in logging
382
+ # non-scoring requests, yet it is not possible to report this information in
383
+ # the request/access log. This applies to Nginx, for example.
384
+ #
385
+ #SecAction \
386
+ # "id:900115,\
387
+ # phase:1,\
388
+ # pass,\
389
+ # t:none,\
390
+ # nolog,\
391
+ # tag:'OWASP_CRS',\
392
+ # ver:'OWASP_CRS/4.9.0',\
393
+ # setvar:tx.reporting_level=4"
394
+
395
+
396
+ #
397
+ # -- [[ Early Anomaly Scoring Mode Blocking ]] ------------------------------
398
+ #
399
+ # The anomaly scores for the request and the responses are generally summed up
400
+ # and evaluated at the end of phase:2 and at the end of phase:4 respectively.
401
+ # However, it is possible to enable an early evaluation of these anomaly scores
402
+ # at the end of phase:1 and at the end of phase:3.
403
+ #
404
+ # If a request (or a response) hits the anomaly threshold in this early
405
+ # evaluation, then blocking happens immediately (if blocking is enabled) and
406
+ # the phase 2 (and phase 4 respectively) will no longer be executed.
407
+ #
408
+ # Enable the rule 900120 that sets the variable tx.early_blocking to 1 in order
409
+ # to enable early blocking. The variable tx.early_blocking is set to 0 by
410
+ # default. Early blocking is thus disabled by default.
411
+ #
412
+ # Please note that early blocking will hide potential alerts from you. This
413
+ # means that a payload that would appear in an alert in phase 2 (or phase 4)
414
+ # does not get evaluated if the request is being blocked early. So when you
415
+ # disabled early blocking again at some point in the future, then new alerts
416
+ # from phase 2 might pop up.
417
+ #SecAction \
418
+ # "id:900120,\
419
+ # phase:1,\
420
+ # pass,\
421
+ # t:none,\
422
+ # nolog,\
423
+ # tag:'OWASP_CRS',\
424
+ # ver:'OWASP_CRS/4.9.0',\
425
+ # setvar:tx.early_blocking=1"
426
+
427
+
428
+ #
429
+ # -- [[ Initialize Default Collections ]] -----------------------------------
430
+ #
431
+ # CRS provides a centralized option to initialize and populate collections
432
+ # meant to be used by plugins (E.g.DoS protection plugin).
433
+ # By default, Global and IP collections (see rule 901320),
434
+ # being not used by core rules, are not initialized.
435
+ #
436
+ # Uncomment this rule to change the default:
437
+ #
438
+ #SecAction \
439
+ # "id:900130,\
440
+ # phase:1,\
441
+ # pass,\
442
+ # t:none,\
443
+ # nolog,\
444
+ # tag:'OWASP_CRS',\
445
+ # ver:'OWASP_CRS/4.9.0',\
446
+ # setvar:tx.enable_default_collections=1"
447
+
448
+
449
+ #
450
+ # -- [[ HTTP Policy Settings ]] ------------------------------------------------
451
+ #
452
+ # This section defines your policies for the HTTP protocol, such as:
453
+ # - allowed HTTP versions, HTTP methods, allowed request Content-Types
454
+ # - forbidden file extensions (e.g. .bak, .sql) and request headers (e.g. Proxy)
455
+ #
456
+ # These variables are used in the following rule files:
457
+ # - REQUEST-911-METHOD-ENFORCEMENT.conf
458
+ # - REQUEST-920-PROTOCOL-ENFORCEMENT.conf
459
+
460
+ # HTTP methods that a client is allowed to use.
461
+ # Default: GET HEAD POST OPTIONS
462
+ # Example: for RESTful APIs, add the following methods: PUT PATCH DELETE
463
+ # Example: for WebDAV, add the following methods: CHECKOUT COPY DELETE LOCK
464
+ # MERGE MKACTIVITY MKCOL MOVE PROPFIND PROPPATCH PUT UNLOCK
465
+ # Uncomment this rule to change the default.
466
+ #
467
+ # GET, HEAD, POST and OPTIONS are seen as the minimal set of HTTP methods
468
+ # from a security perspective. For static sites, removing the POST is
469
+ # recommended. Add other HTTP methods as see fit (see above).
470
+ #
471
+ SecAction \
472
+ "id:900200,\
473
+ phase:1,\
474
+ pass,\
475
+ t:none,\
476
+ nolog,\
477
+ tag:'OWASP_CRS',\
478
+ ver:'OWASP_CRS/4.9.0',\
479
+ setvar:'tx.allowed_methods=GET HEAD POST OPTIONS PUT PATCH DELETE'"
480
+
481
+ # Content-Types that a client is allowed to send in a request.
482
+ # Default: |application/x-www-form-urlencoded| |multipart/form-data| |text/xml|
483
+ # |application/xml| |application/soap+xml| |application/json|
484
+ #
485
+ # Please note, that the rule where CRS uses this variable (920420) evaluates it with operator
486
+ # @within, which is case sensitive, but uses t:lowercase. You must add your whole custom
487
+ # Content-Type with lowercase.
488
+ #
489
+ # Bypass Warning: some applications may not rely on the content-type request header in order
490
+ # to parse the request body. This could make an attacker able to send malicious URLENCODED/JSON/XML
491
+ # payloads without being detected by the WAF. Allowing request content-type that doesn't activate any
492
+ # body processor (for example: "text/plain", "application/x-amf", "application/octet-stream", etc..)
493
+ # could lead to a WAF bypass. For example, a malicious JSON payload submitted with a "text/plain"
494
+ # content type may still be interpreted as JSON by a backend application but would not trigger the
495
+ # JSON body parser at the WAF, leading to a bypass.
496
+ #
497
+ # When additional JSON content types are legitimately used in a deployment,
498
+ # e.g. application/cloudevents+json, it is extremely important to ensure that a
499
+ # rule exists to enable the engine's JSON body processor for these additional
500
+ # JSON content types. Failure to do so can lead to a request body bypass. The
501
+ # default JSON rule in modsecurity.conf-recommended (200001) will only activate
502
+ # the JSON body processor for the specific content type application/json. The
503
+ # optional modsecurity.conf-recommended rule 200006 can be used to enable the
504
+ # JSON body processor for a wide variety of JSON content types.
505
+ #
506
+ # To prevent blocking request with not allowed content-type by default, you can create an exclusion
507
+ # rule that removes rule 920420. For example:
508
+ #SecRule REQUEST_HEADERS:Content-Type "@rx ^text/plain" \
509
+ # "id:1234,\
510
+ # phase:1,\
511
+ # pass,\
512
+ # t:none,\
513
+ # nolog,\
514
+ # tag:'OWASP_CRS',\
515
+ # ctl:ruleRemoveById=920420,\
516
+ # ver:'OWASP_CRS/4.9.0',\
517
+ # chain"
518
+ # SecRule REQUEST_URI "@rx ^/foo/bar" \
519
+ # "t:none"
520
+ #
521
+ # Uncomment this rule to change the default.
522
+ #
523
+ #SecAction \
524
+ # "id:900220,\
525
+ # phase:1,\
526
+ # pass,\
527
+ # t:none,\
528
+ # nolog,\
529
+ # tag:'OWASP_CRS',\
530
+ # ver:'OWASP_CRS/4.9.0',\
531
+ # setvar:'tx.allowed_request_content_type=|application/x-www-form-urlencoded| |multipart/form-data| |text/xml| |application/xml| |application/soap+xml| |application/json|'"
532
+
533
+ # Allowed HTTP versions.
534
+ # Default: HTTP/1.0 HTTP/1.1 HTTP/2 HTTP/2.0 HTTP/3 HTTP/3.0
535
+ # Example for legacy clients: HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP/2 HTTP/2.0 HTTP/3 HTTP/3.0
536
+ # Note that some web server versions use 'HTTP/2', some 'HTTP/2.0', so
537
+ # we include both version strings by default.
538
+ # Uncomment this rule to change the default.
539
+ #SecAction \
540
+ # "id:900230,\
541
+ # phase:1,\
542
+ # pass,\
543
+ # t:none,\
544
+ # nolog,\
545
+ # tag:'OWASP_CRS',\
546
+ # ver:'OWASP_CRS/4.9.0',\
547
+ # setvar:'tx.allowed_http_versions=HTTP/1.0 HTTP/1.1 HTTP/2 HTTP/2.0 HTTP/3 HTTP/3.0'"
548
+
549
+ # Forbidden file extensions.
550
+ # Guards against unintended exposure of development/configuration files.
551
+ # Default: .asa/ .asax/ .ascx/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pem/ .pol/ .printer/ .pwd/ .rdb/ .resources/ .resx/ .sql/ .swp/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/
552
+ # Example: .bak/ .config/ .conf/ .db/ .ini/ .log/ .old/ .pass/ .pdb/ .rdb/ .sql/
553
+ # Note that .axd was removed due to false positives (see PR 1925).
554
+ #
555
+ # To additionally guard against configuration/install archive files from being
556
+ # accidentally exposed, common archive file extensions can be added to the
557
+ # restricted extensions list. An example list of common archive file extensions
558
+ # is presented below:
559
+ # .7z/ .br/ .bz/ .bz2/ .cab/ .cpio/ .gz/ .img/ .iso/ .jar/ .rar/ .tar/ .tbz2/ .tgz/ .txz/ .xz/ .zip/ .zst/
560
+ # (Source: https://en.wikipedia.org/wiki/List_of_archive_formats)
561
+ #
562
+ # Uncomment this rule to change the default.
563
+ #SecAction \
564
+ # "id:900240,\
565
+ # phase:1,\
566
+ # pass,\
567
+ # t:none,\
568
+ # nolog,\
569
+ # tag:'OWASP_CRS',\
570
+ # ver:'OWASP_CRS/4.9.0',\
571
+ # setvar:'tx.restricted_extensions=.asa/ .asax/ .ascx/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pem/ .pol/ .printer/ .pwd/ .rdb/ .resources/ .resx/ .sql/ .swp/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/'"
572
+
573
+ # Restricted request headers.
574
+ # The HTTP request headers that CRS restricts are split into two categories:
575
+ # basic (always forbidden) and extended (may be forbidden). All header names
576
+ # should be lowercase and enclosed by /slashes/ as delimiters.
577
+ #
578
+ # [ Basic ]
579
+ # Includes deprecated headers and headers with known security risks. Always
580
+ # forbidden.
581
+ # Default: /content-encoding/ /proxy/ /lock-token/ /content-range/ /if/ /x-http-method-override/ /x-http-method/ /x-method-override/
582
+ #
583
+ # /content-encoding/
584
+ # Used to list any encodings that have been applied to the original payload.
585
+ # Only used for compression, which isn't supported by CRS by default since CRS
586
+ # blocks newlines and null bytes inside the request body. Most compression
587
+ # algorithms require at least null bytes per RFC. Blocking Content-Encoding
588
+ # shouldn't break anything and increases security since WAF engines, including
589
+ # ModSecurity, are typically incapable of properly scanning compressed request
590
+ # bodies.
591
+ #
592
+ # /proxy/
593
+ # Blocking this prevents the 'httpoxy' vulnerability: https://httpoxy.org
594
+ #
595
+ # /lock-token/
596
+ #
597
+ # /content-range/
598
+ #
599
+ # /if/
600
+ #
601
+ # /x-http-method-override/
602
+ # /x-http-method/
603
+ # /x-method-override/
604
+ # Blocking these headers prevents method override attacks, as described here:
605
+ # https://www.sidechannel.blog/en/http-method-override-what-it-is-and-how-a-pentester-can-use-it
606
+ #
607
+ # Uncomment this rule to change the default.
608
+ #SecAction \
609
+ # "id:900250,\
610
+ # phase:1,\
611
+ # pass,\
612
+ # t:none,\
613
+ # nolog,\
614
+ # tag:'OWASP_CRS',\
615
+ # ver:'OWASP_CRS/4.9.0',\
616
+ # setvar:'tx.restricted_headers_basic=/content-encoding/ /proxy/ /lock-token/ /content-range/ /if/ /x-http-method-override/ /x-http-method/ /x-method-override/'"
617
+ #
618
+ # [ Extended ]
619
+ # Includes deprecated headers that are still in use (so false positives are
620
+ # possible) and headers with possible security risks. Forbidden at a higher
621
+ # paranoia level.
622
+ # Default: /accept-charset/
623
+ #
624
+ # /accept-charset/
625
+ # Deprecated header that should not be used by clients and should be ignored
626
+ # by servers. Can be used for a response WAF bypass by asking for a charset
627
+ # that the WAF cannot decode. Considered to be a good indicator of suspicious
628
+ # behavior but produces too many false positives to be forbidden by default.
629
+ # References:
630
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Charset
631
+ # https://github.com/coreruleset/coreruleset/issues/3140
632
+ #
633
+ # Uncomment this rule to change the default.
634
+ #SecAction \
635
+ # "id:900255,\
636
+ # phase:1,\
637
+ # pass,\
638
+ # t:none,\
639
+ # nolog,\
640
+ # tag:'OWASP_CRS',\
641
+ # ver:'OWASP_CRS/4.9.0',\
642
+ # setvar:'tx.restricted_headers_extended=/accept-charset/'"
643
+
644
+ # Content-Types charsets that a client is allowed to send in a request.
645
+ # The content-types are enclosed by |pipes| as delimiters to guarantee exact matches.
646
+ # Default: |utf-8| |iso-8859-1| |iso-8859-15| |windows-1252|
647
+ # Uncomment this rule to change the default.
648
+ #SecAction \
649
+ # "id:900280,\
650
+ # phase:1,\
651
+ # pass,\
652
+ # t:none,\
653
+ # nolog,\
654
+ # tag:'OWASP_CRS',\
655
+ # ver:'OWASP_CRS/4.9.0',\
656
+ # setvar:'tx.allowed_request_content_type_charset=|utf-8| |iso-8859-1| |iso-8859-15| |windows-1252|'"
657
+
658
+ #
659
+ # -- [[ HTTP Argument/Upload Limits ]] -----------------------------------------
660
+ #
661
+ # Here you can define optional limits on HTTP get/post parameters and uploads.
662
+ # This can help to prevent application specific DoS attacks.
663
+ #
664
+ # These values are checked in REQUEST-920-PROTOCOL-ENFORCEMENT.conf.
665
+ # Beware of blocking legitimate traffic when enabling these limits.
666
+ #
667
+
668
+ # Block request if number of arguments is too high
669
+ # Default: unlimited
670
+ # Example: 255
671
+ # Note that a hard limit by the engine may also apply here (SecArgumentsLimit).
672
+ # This would override this soft limit.
673
+ # Uncomment this rule to set a limit.
674
+ SecAction \
675
+ "id:900300,\
676
+ phase:1,\
677
+ pass,\
678
+ t:none,\
679
+ nolog,\
680
+ tag:'OWASP_CRS',\
681
+ ver:'OWASP_CRS/4.9.0',\
682
+ setvar:tx.max_num_args=512"
683
+
684
+ # Block request if the length of any argument name is too high
685
+ # Default: unlimited
686
+ # Example: 100
687
+ # Uncomment this rule to set a limit.
688
+ SecAction \
689
+ "id:900310,\
690
+ phase:1,\
691
+ pass,\
692
+ t:none,\
693
+ nolog,\
694
+ tag:'OWASP_CRS',\
695
+ ver:'OWASP_CRS/4.9.0',\
696
+ setvar:tx.arg_name_length=128"
697
+
698
+ # Block request if the length of any argument value is too high
699
+ # Default: unlimited
700
+ # Example: 400
701
+ # Uncomment this rule to set a limit.
702
+ #SecAction \
703
+ # "id:900320,\
704
+ # phase:1,\
705
+ # pass,\
706
+ # t:none,\
707
+ # nolog,\
708
+ # tag:'OWASP_CRS',\
709
+ # ver:'OWASP_CRS/4.9.0',\
710
+ # setvar:tx.arg_length=400"
711
+
712
+ # Block request if the total length of all combined arguments is too high
713
+ # Default: unlimited
714
+ # Example: 64000
715
+ # Uncomment this rule to set a limit.
716
+ #SecAction \
717
+ # "id:900330,\
718
+ # phase:1,\
719
+ # pass,\
720
+ # t:none,\
721
+ # nolog,\
722
+ # tag:'OWASP_CRS',\
723
+ # ver:'OWASP_CRS/4.9.0',\
724
+ # setvar:tx.total_arg_length=64000"
725
+
726
+ # Block request if the file size of any individual uploaded file is too high
727
+ # Default: unlimited
728
+ # Example: 1048576
729
+ # Uncomment this rule to set a limit.
730
+ #SecAction \
731
+ # "id:900340,\
732
+ # phase:1,\
733
+ # pass,\
734
+ # t:none,\
735
+ # nolog,\
736
+ # tag:'OWASP_CRS',\
737
+ # ver:'OWASP_CRS/4.9.0',\
738
+ # setvar:tx.max_file_size=1048576"
739
+
740
+ # Block request if the total size of all combined uploaded files is too high
741
+ # Default: unlimited
742
+ # Example: 1048576
743
+ # Uncomment this rule to set a limit.
744
+ #SecAction \
745
+ # "id:900350,\
746
+ # phase:1,\
747
+ # pass,\
748
+ # t:none,\
749
+ # nolog,\
750
+ # tag:'OWASP_CRS',\
751
+ # ver:'OWASP_CRS/4.9.0',\
752
+ # setvar:tx.combined_file_sizes=1048576"
753
+
754
+
755
+ #
756
+ # -- [[ Easing In / Sampling Percentage ]] -------------------------------------
757
+ #
758
+ # Adding the CRS to an existing productive site can lead to false
759
+ # positives, unexpected performance issues and other undesired side effects.
760
+ #
761
+ # It can be beneficial to test the water first by enabling the CRS for a
762
+ # limited number of requests only and then, when you have solved the issues (if
763
+ # any) and you have confidence in the setup, to raise the ratio of requests
764
+ # being sent into the ruleset.
765
+ #
766
+ # Adjust the percentage of requests that are funnelled into the Core Rules by
767
+ # setting TX.sampling_percentage below. The default is 100, meaning that every
768
+ # request gets checked by the CRS. The selection of requests, which are going
769
+ # to be checked, is based on a pseudo random number generated by ModSecurity.
770
+ #
771
+ # If a request is allowed to pass without being checked by the CRS, there is no
772
+ # entry in the audit log (for performance reasons), but an error log entry is
773
+ # written. If you want to disable the error log entry, then issue the
774
+ # following directive somewhere after the inclusion of the CRS
775
+ # (E.g., RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf).
776
+ #
777
+ #SecRuleUpdateActionById 901450 "nolog"
778
+ #
779
+ # ATTENTION: If this TX.sampling_percentage is below 100, then some of the
780
+ # requests will bypass the Core Rules completely and you lose the ability to
781
+ # protect your service with ModSecurity.
782
+ #
783
+ # Uncomment this rule to enable this feature:
784
+ #
785
+ #SecAction \
786
+ # "id:900400,\
787
+ # phase:1,\
788
+ # pass,\
789
+ # nolog,\
790
+ # tag:'OWASP_CRS',\
791
+ # ver:'OWASP_CRS/4.9.0',\
792
+ # setvar:tx.sampling_percentage=100"
793
+
794
+
795
+
796
+ #
797
+ # -- [[ Check UTF-8 encoding ]] ------------------------------------------------
798
+ #
799
+ # The CRS can optionally check request contents for invalid UTF-8 encoding.
800
+ # We only want to apply this check if UTF-8 encoding is actually used by the
801
+ # site; otherwise it will result in false positives.
802
+ #
803
+ # Uncomment this rule to use this feature:
804
+ #
805
+ #SecAction \
806
+ # "id:900950,\
807
+ # phase:1,\
808
+ # pass,\
809
+ # t:none,\
810
+ # nolog,\
811
+ # tag:'OWASP_CRS',\
812
+ # ver:'OWASP_CRS/4.9.0',\
813
+ # setvar:tx.crs_validate_utf8_encoding=1"
814
+
815
+ # -- [[ Skip Checking Responses ]] ------------------------------------------------
816
+ #
817
+ # CRS will perform analysis of the response contents if this is enabled and you have
818
+ # the directive SecResponseBodyAccess On.
819
+ #
820
+ # Warning: this feature is _enabled_ by default, but depending on your applications
821
+ # you might be targeted in a Request Filter Denial of Service (RFDoS) attack.
822
+ #
823
+ # References: https://blog.sicuranext.com/response-filter-denial-of-service-a-new-way-to-shutdown-a-website/
824
+ #
825
+ # Uncomment this rule to _skip checking responses_.
826
+ #
827
+ SecAction \
828
+ "id:900500,\
829
+ phase:1,\
830
+ pass,\
831
+ t:none,\
832
+ nolog,\
833
+ tag:'OWASP_CRS',\
834
+ ver:'OWASP_CRS/4.9.0',\
835
+ setvar:tx.crs_skip_response_analysis=1"
836
+
837
+ #
838
+ # -- [[ End of setup ]] --------------------------------------------------------
839
+ #
840
+ # The CRS checks the tx.crs_setup_version variable to ensure that the setup
841
+ # has been loaded. If you are not planning to use this setup template,
842
+ # you must manually set the tx.crs_setup_version variable before including
843
+ # the CRS rules/* files.
844
+ #
845
+ # The variable is a numerical representation of the CRS version number.
846
+ # E.g., v3.0.0 is represented as 300.
847
+ #
848
+ SecAction \
849
+ "id:900990,\
850
+ phase:1,\
851
+ pass,\
852
+ t:none,\
853
+ nolog,\
854
+ tag:'OWASP_CRS',\
855
+ ver:'OWASP_CRS/4.9.0',\
856
+ setvar:tx.crs_setup_version=490"
857
+ `;