Adds support to variable MULTIPART_UNMATCHED_BOUNDARY

This commit is contained in:
Felipe Zimmerle 2015-07-21 19:30:14 -03:00
parent a9147b76ad
commit 8e59b1822c
2 changed files with 67 additions and 1 deletions

View File

@ -450,7 +450,10 @@ int Assay::processRequestBody() {
if (m.containsDataAfter) {
debug(9, "Multipart: There is data after the boundary, " \
"setting MULTIPART_STRICT_ERROR to 1");
update_variable_first("MULTIPART_STRICT_ERROR", "1");
update_variable_first("MULTIPART_STRICT_ERROR", "1");
store_variable("MULTIPART_UNMATCHED_BOUNDARY", "1");
} else {
store_variable("MULTIPART_UNMATCHED_BOUNDARY", "0");
}
if (m.containsDataBefore) {
debug(9, "Multipart: There is data before the boundary, " \

View File

@ -0,0 +1,63 @@
[
{
"enabled":1,
"version_min":300000,
"title":"Testing Variables :: MULTIPART_UNMATCHED_BOUNDARY",
"client":{
"ip":"200.249.12.31",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*",
"Content-Length":"330",
"Content-Type":"multipart/form-data; boundary=--------------------------756b6d74fa1a8ee2",
"Expect":"100-continue"
},
"uri":"/",
"protocol":"POST",
"body":[
"--------------------------756b6d74fa1a8ee2",
"Content-Disposition: form-data; name=\"name\"",
"",
"test",
"--------------------------756b6d74fa1a8ee2",
"Content-Disposition: form-data; name=\"filedata\"; filename=\"small_text_file.txt\"",
"Content-Type: text/plain",
"",
"This is a very small test file..",
"--------------------------756b6d74fa1a8ee2",
"Content-Disposition: form-data; name=\"filedata\"; filename=\"small_text_file.txt\"",
"Content-Type: text/plain",
"",
"This is another very small test file..",
""
]
},
"response":{
"headers":{
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"1\" \\(Variable: MULTIPART_UNMATCHED_BOUNDARY\\)"
},
"rules":[
"SecRuleEngine On",
"SecDebugLog \/tmp\/modsec_debug.log",
"SecDebugLogLevel 9",
"SecRule MULTIPART_UNMATCHED_BOUNDARY \"@contains small_text_file.txt\" \"phase:3,pass,t:trim\""
]
}
]