Skip to content

Commit 7def498

Browse files
airweenFelipe Zimmerle
authored andcommitted
Added some documentation for multipart boundary check
1 parent a3980bb commit 7def498

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

modsecurity.conf-recommended

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,49 @@ FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
7676

7777
# Did we see anything that might be a boundary?
7878
#
79+
# Here is a short description about the ModSecurity Multipart parser: the
80+
# parser returns with value 0, if all "boundary-like" line matches with
81+
# the boundary string which given in MIME header. In any other cases it returns
82+
# with different value, eg. 1 or 2.
83+
#
84+
# The RFC 1341 descript the multipart content-type and its syntax must contains
85+
# only three mandatory lines (above the content):
86+
# * Content-Type: multipart/mixed; boundary=BOUNDARY_STRING
87+
# * --BOUNDARY_STRING
88+
# * --BOUNDARY_STRING--
89+
#
90+
# First line indicates, that this is a multipart content, second shows that
91+
# here starts a part of the multipart content, third shows the end of content.
92+
#
93+
# If there are any other lines, which starts with "--", then it should be
94+
# another boundary id - or not.
95+
#
96+
# After 3.0.3, there are two kinds of types of boundary errors: strict and permissive.
97+
#
98+
# If multipart content contains the three necessary lines with correct order, but
99+
# there are one or more lines with "--", then parser returns with value 2 (non-zero).
100+
#
101+
# If some of the necessary lines (usually the start or end) misses, or the order
102+
# is wrong, then parser returns with value 1 (also a non-zero).
103+
#
104+
# You can choose, which one is what you need. The example below contains the
105+
# 'strict' mode, which means if there are any lines with start of "--", then
106+
# ModSecurity blocked the content. But the next, commented example contains
107+
# the 'permissive' mode, then you check only if the necessary lines exists in
108+
# correct order. Whit this, you can enable to upload PEM files (eg "----BEGIN.."),
109+
# or other text files, which contains eg. HTTP headers.
110+
#
111+
# The difference is only the operator - in strict mode (first) the content blocked
112+
# in case of any non-zero value. In permissive mode (second, commented) the
113+
# content blocked only if the value is explicit 1. If it 0 or 2, the content will
114+
# allowed.
115+
#
116+
79117
SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
80118
"id:'200004',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
119+
#SecRule MULTIPART_UNMATCHED_BOUNDARY "@eq 1" \
120+
#"id:'200004',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
121+
81122

82123
# PCRE Tuning
83124
# We want to avoid a potential RegEx DoS condition

0 commit comments

Comments
 (0)