Skip to content

Commit de3a9b5

Browse files
authored
Merge pull request #2796 from martinhsv/v3/master
Adjust parser activation rules in modsecurity.conf-recommended
2 parents d6c1088 + 622eb9e commit de3a9b5

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

CHANGES

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.x.y - YYYY-MMM-DD (to be released)
22
-------------------------------------
33

4+
- Adjust parser activation rules in modsecurity.conf-recommended
5+
[Issue #2796 - @terjanq, @martinhsv]
46
- Multipart parsing fixes and new MULTIPART_PART_HEADERS collection
57
[Issue #2795 - @terjanq, @martinhsv]
68
- Prevent LMDB related segfault

modsecurity.conf-recommended

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ SecRequestBodyAccess On
1919
# Enable XML request body parser.
2020
# Initiate XML Processor in case of xml content-type
2121
#
22-
SecRule REQUEST_HEADERS:Content-Type "(?:application(?:/soap\+|/)|text/)xml" \
22+
SecRule REQUEST_HEADERS:Content-Type "^(?:application(?:/soap\+|/)|text/)xml" \
2323
"id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
2424

2525
# Enable JSON request body parser.
2626
# Initiate JSON Processor in case of JSON content-type; change accordingly
2727
# if your application does not use 'application/json'
2828
#
29-
SecRule REQUEST_HEADERS:Content-Type "application/json" \
29+
SecRule REQUEST_HEADERS:Content-Type "^application/json" \
3030
"id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
3131

3232
# Sample rule to enable JSON request body parser for more subtypes.
3333
# Uncomment or adapt this rule if you want to engage the JSON
3434
# Processor for "+json" subtypes
3535
#
36-
#SecRule REQUEST_HEADERS:Content-Type "^application/.+[+]json$" \
36+
#SecRule REQUEST_HEADERS:Content-Type "^application/[a-z0-9.-]+[+]json" \
3737
# "id:'200006',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
3838

3939
# Maximum request body size we will accept for buffering. If you support

test/test-cases/regression/secargumentslimit.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"rules":[
3737
"SecRuleEngine On",
3838
"SecArgumentsLimit 6",
39-
"SecRule REQUEST_HEADERS:Content-Type \"application/json\" \"id:'200001',phase:1,t:none,pass,nolog,ctl:requestBodyProcessor=JSON\"",
39+
"SecRule REQUEST_HEADERS:Content-Type \"^application/json\" \"id:'200001',phase:1,t:none,pass,nolog,ctl:requestBodyProcessor=JSON\"",
4040
"SecRule REQBODY_ERROR \"!@eq 0\" \"id:'200002', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}'\"",
4141
"SecRule ARGS:/k5/ \"@rx v5\" \"id:'1234',phase:2,deny,status:403,t:none,log,auditlog\""
4242
]
@@ -78,7 +78,7 @@
7878
"rules":[
7979
"SecRuleEngine On",
8080
"SecArgumentsLimit 5",
81-
"SecRule REQUEST_HEADERS:Content-Type \"application/json\" \"id:'200001',phase:1,t:none,pass,nolog,ctl:requestBodyProcessor=JSON\"",
81+
"SecRule REQUEST_HEADERS:Content-Type \"^application/json\" \"id:'200001',phase:1,t:none,pass,nolog,ctl:requestBodyProcessor=JSON\"",
8282
"SecRule REQBODY_ERROR \"!@eq 0\" \"id:'200002', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}'\"",
8383
"SecRule ARGS:/k5/ \"@rx v5\" \"id:'1234',phase:2,deny,status:403,t:none,log,auditlog\""
8484
]

test/test-cases/regression/variable-REQBODY_PROCESSOR.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
},
7474
"rules":[
7575
"SecRuleEngine On",
76-
"SecRule REQUEST_HEADERS:Content-Type \"^text/xml$\" \"id:500005,phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML\"",
76+
"SecRule REQUEST_HEADERS:Content-Type \"^(?:application(?:/soap\+|/)|text/)xml\" \"id:500005,phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML\"",
7777
"SecRule REQBODY_PROCESSOR \"@contains test\" \"id:1,pass,phase:2,t:trim\""
7878
]
7979
},

0 commit comments

Comments
 (0)