@@ -22,6 +22,12 @@ SecRequestBodyAccess On
2222SecRule REQUEST_HEADERS:Content-Type "text/xml" \
2323 "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
2424
25+ # Enable JSON request body parser.
26+ # Initiate JSON Processor in case of JSON content-type; change accordingly
27+ # if your application does not use 'application/json'
28+ #
29+ SecRule REQUEST_HEADERS:Content-Type "application/json" \
30+ "id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
2531
2632# Maximum request body size we will accept for buffering. If you support
2733# file uploads then the value given on the first line has to be as large
@@ -51,15 +57,15 @@ SecRequestBodyLimitAction Reject
5157# or log a high-severity alert (when deployed in detection-only mode).
5258#
5359SecRule REQBODY_ERROR "!@eq 0" \
54- "id:'200001 ', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
60+ "id:'200002 ', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
5561
5662# By default be strict with what we accept in the multipart/form-data
5763# request body. If the rule below proves to be too strict for your
5864# environment consider changing it to detection-only. You are encouraged
5965# _not_ to remove it altogether.
6066#
6167SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
62- "id:'200002 ',phase:2,t:none,log,deny,status:400, \
68+ "id:'200003 ',phase:2,t:none,log,deny,status:400, \
6369msg:'Multipart request body failed strict validation: \
6470PE %{REQBODY_PROCESSOR_ERROR}, \
6571BQ %{MULTIPART_BOUNDARY_QUOTED}, \
@@ -77,7 +83,7 @@ FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
7783# Did we see anything that might be a boundary?
7884#
7985SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
80- "id:'200003 ',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
86+ "id:'200004 ',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
8187
8288# PCRE Tuning
8389# We want to avoid a potential RegEx DoS condition
@@ -91,7 +97,7 @@ SecPcreMatchLimitRecursion 1000
9197# MSC_PCRE_LIMITS_EXCEEDED: PCRE match limits were exceeded.
9298#
9399SecRule TX:/^MSC_/ "!@streq 0" \
94- "id:'200004 ',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
100+ "id:'200005 ',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
95101
96102
97103# -- Response body handling --------------------------------------------------