@@ -28,32 +28,32 @@ SecRule REQUEST_HEADERS:Content-Type "^(?:application(?:/soap\+|/)|text/)xml" \
2828SecRule REQUEST_HEADERS:Content-Type "^application/json" \
2929 "id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
3030
31- # Sample rule to enable JSON request body parser for more subtypes.
32- # Uncomment or adapt this rule if you want to engage the JSON
33- # Processor for "+json" subtypes
31+ # Enable JSON request body parser for more subtypes.
32+ # Adapt this rule if you want to engage the JSON Processor for "+json" subtypes
3433#
35- # SecRule REQUEST_HEADERS:Content-Type "^application/[a-z0-9.-]+[+]json" \
36- # "id:'200006',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
34+ SecRule REQUEST_HEADERS:Content-Type "^application/[a-z0-9.-]+[+]json" \
35+ "id:'200006',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
3736
3837# Maximum request body size we will accept for buffering. If you support
39- # file uploads then the value given on the first line has to be as large
40- # as the largest file you are willing to accept. The second value refers
41- # to the size of data, with files excluded. You want to keep that value as
42- # low as practical.
43- #
44- # Running as a Wasm plugin, we expect Limit equal to MemoryLimit: it would be prevented buffering request body to files anyways.
45-
38+ # file uploads, this value must has to be as large as the largest file
39+ # you are willing to accept.
4640SecRequestBodyLimit 131072
4741
42+ # Maximum request body size that Coraza will store in memory. If the body
43+ # size exceeds this value, it will be saved to a temporary file on disk.
4844SecRequestBodyInMemoryLimit 131072
4945
50- # SecRequestBodyNoFilesLimit is currently not supported by Coraza
46+ # Maximum request body size we will accept for buffering, with files excluded.
47+ # You want to keep that value as low as practical.
48+ # Note: SecRequestBodyNoFilesLimit is currently NOT supported by Coraza
5149# SecRequestBodyNoFilesLimit 131072
5250
5351# What to do if the request body size is above our configured limit.
5452# Keep in mind that this setting will automatically be set to ProcessPartial
5553# when SecRuleEngine is set to DetectionOnly mode in order to minimize
5654# disruptions when initially deploying Coraza.
55+ # Warning: Setting this directive to ProcessPartial introduces a potential bypass
56+ # risk, as attackers could prepend junk data equal to or greater than the inspected body size.
5757#
5858SecRequestBodyLimitAction ProcessPartial
5959
@@ -67,87 +67,18 @@ SecRule REQBODY_ERROR "!@eq 0" \
6767
6868# By default be strict with what we accept in the multipart/form-data
6969# request body. If the rule below proves to be too strict for your
70- # environment consider changing it to detection-only. You are encouraged
71- # _not_ to remove it altogether .
70+ # environment consider changing it to detection-only.
71+ # Do NOT remove it, as it will catch many evasion attempts .
7272#
7373SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
74- "id:'200003',phase:2,t:none,log,deny,status:400, \
75- msg:'Multipart request body failed strict validation: \
76- PE %{REQBODY_PROCESSOR_ERROR}, \
77- BQ %{MULTIPART_BOUNDARY_QUOTED}, \
78- BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
79- DB %{MULTIPART_DATA_BEFORE}, \
80- DA %{MULTIPART_DATA_AFTER}, \
81- HF %{MULTIPART_HEADER_FOLDING}, \
82- LF %{MULTIPART_LF_LINE}, \
83- SM %{MULTIPART_MISSING_SEMICOLON}, \
84- IQ %{MULTIPART_INVALID_QUOTING}, \
85- IP %{MULTIPART_INVALID_PART}, \
86- IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
87- FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
88-
89- # Did we see anything that might be a boundary?
90- #
91- # Here is a short description about the Coraza Multipart parser: the
92- # parser returns with value 0, if all "boundary-like" line matches with
93- # the boundary string which given in MIME header. In any other cases it returns
94- # with different value, eg. 1 or 2.
95- #
96- # The RFC 1341 descript the multipart content-type and its syntax must contains
97- # only three mandatory lines (above the content):
98- # * Content-Type: multipart/mixed; boundary=BOUNDARY_STRING
99- # * --BOUNDARY_STRING
100- # * --BOUNDARY_STRING--
101- #
102- # First line indicates, that this is a multipart content, second shows that
103- # here starts a part of the multipart content, third shows the end of content.
104- #
105- # If there are any other lines, which starts with "--", then it should be
106- # another boundary id - or not.
107- #
108- # After 3.0.3, there are two kinds of types of boundary errors: strict and permissive.
109- #
110- # If multipart content contains the three necessary lines with correct order, but
111- # there are one or more lines with "--", then parser returns with value 2 (non-zero).
112- #
113- # If some of the necessary lines (usually the start or end) misses, or the order
114- # is wrong, then parser returns with value 1 (also a non-zero).
115- #
116- # You can choose, which one is what you need. The example below contains the
117- # 'strict' mode, which means if there are any lines with start of "--", then
118- # Coraza blocked the content. But the next, commented example contains
119- # the 'permissive' mode, then you check only if the necessary lines exists in
120- # correct order. Whit this, you can enable to upload PEM files (eg "----BEGIN.."),
121- # or other text files, which contains eg. HTTP headers.
122- #
123- # The difference is only the operator - in strict mode (first) the content blocked
124- # in case of any non-zero value. In permissive mode (second, commented) the
125- # content blocked only if the value is explicit 1. If it 0 or 2, the content will
126- # allowed.
127- #
128-
129- #
130- # See #1747 and #1924 for further information on the possible values for
131- # MULTIPART_UNMATCHED_BOUNDARY.
132- #
133- SecRule MULTIPART_UNMATCHED_BOUNDARY "@eq 1" \
134- "id:'200004',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
135-
136- # Some internal errors will set flags in TX and we will need to look for these.
137- # All of these are prefixed with "MSC_". The following flags currently exist:
138- #
139- # COR_PCRE_LIMITS_EXCEEDED: PCRE match limits were exceeded.
140- #
141- SecRule TX:/^COR_/ "!@streq 0" \
142- "id:'200005',phase:2,t:none,deny,msg:'Coraza internal error flagged: %{MATCHED_VAR_NAME}'"
143-
74+ "id:'200003',phase:2,t:none,log,deny,status:400, msg:'Multipart request body failed strict validation.'"
14475
14576# -- Response body handling --------------------------------------------------
14677
147- # Allow Coraza to access response bodies.
78+ # Allow Coraza to access response bodies.
14879# You should have this directive enabled in order to identify errors
14980# and data leakage issues.
150- #
81+ #
15182# Do keep in mind that enabling this directive does increases both
15283# memory consumption and response latency.
15384#
@@ -171,7 +102,7 @@ SecResponseBodyLimitAction ProcessPartial
171102
172103# -- Filesystem configuration ------------------------------------------------
173104
174- # The location where Coraza will keep its persistent data. This default setting
105+ # The location where Coraza will keep its persistent data. This default setting
175106# is chosen due to all systems have /tmp available however, it
176107# too should be updated to a place that other users can't access.
177108#
@@ -186,15 +117,16 @@ SecResponseBodyLimitAction ProcessPartial
186117#
187118#SecUploadDir /opt/coraza/var/upload/
188119
189- # By default, only keep the files that were determined to be unusual
190- # in some way (by an external inspection script). For this to work you
191- # will also need at least one file inspection rule.
120+ # If On, the WAF will store the uploaded files in the SecUploadDir
121+ # directory.
122+ # Note: SecUploadKeepFiles is currently NOT supported by Coraza
192123#
193- #SecUploadKeepFiles RelevantOnly
124+ #SecUploadKeepFiles Off
194125
195126# Uploaded files are by default created with permissions that do not allow
196127# any other user to access them. You may need to relax that if you want to
197128# interface Coraza to an external program (e.g., an anti-virus).
129+ # Note: SecUploadFileMode is currently NOT supported by Coraza
198130#
199131#SecUploadFileMode 0600
200132
@@ -209,22 +141,21 @@ SecResponseBodyLimitAction ProcessPartial
209141# 3: Info
210142# 4-8: Debug
211143# 9: Trace (most verbose)
212- # Most logging has not been implemented because it will be replaced with
213- # advanced rule profiling options
144+ #
214145#SecDebugLog /opt/coraza/var/log/debug.log
215146SecDebugLogLevel 3
216147
217148
218149# -- Audit log configuration -------------------------------------------------
219150
220151# Log the transactions that are marked by a rule, as well as those that
221- # trigger a server error (determined by a 5xx or 4xx, excluding 404,
152+ # trigger a server error (determined by a 5xx or 4xx, excluding 404,
222153# level response status codes).
223154#
224155SecAuditEngine RelevantOnly
225156SecAuditLogRelevantStatus "^(?:(5|4)(0|1)[0-9])$"
226157
227- # Log everything we know about a transaction.
158+ # Define which parts of the transaction are going to be recorded in the audit log
228159SecAuditLogParts ABIJDEFHZ
229160
230161# Use a single file for logging. This is much easier to look at, but
@@ -234,18 +165,15 @@ SecAuditLogParts ABIJDEFHZ
234165# which end up in the proxy logs.
235166SecAuditLogType Serial
236167SecAuditLog /dev/stdout
237- SecAuditLogFormat JSON
238-
239- # -- Miscellaneous -----------------------------------------------------------
240168
241- # Use the most commonly used application/x-www-form-urlencoded parameter
242- # separator. There's probably only one application somewhere that uses
243- # something else so don't expect to change this value.
244- #
245- SecArgumentSeparator &
169+ # The format used to write the audit log.
170+ # Can be one of JSON|JsonLegacy|Native|OCSF
171+ SecAuditLogFormat JSON
246172
247- # Settle on version 0 (zero) cookies, as that is what most applications
248- # use. Using an incorrect cookie version may open your installation to
249- # evasion attacks (against the rules that examine named cookies).
250- #
251- SecCookieFormat 0
173+ # The following settings are not supported by Coraza
174+ # SecCookieFormat 0
175+ # SecArgumentSeparator &
176+ # SecRule MULTIPART_UNMATCHED_BOUNDARY "@eq 1" \
177+ # "id:'200004',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
178+ # SecRule TX:/^COR_/ "!@streq 0" \
179+ # "id:'200005',phase:2,t:none,deny,msg:'Coraza internal error flagged: %{MATCHED_VAR_NAME}'"
0 commit comments