easyapache, mod_sec 2.7 and MULTIPART_STRICT_ERROR

sebby

Well-Known Member
Jun 15, 2004
70
0
156
Canada
cPanel Access Level
Root Administrator
Hello everyone,

EasyApache recently started injecting the following patch to ModSecurity 2.7:

Code:
SecRule MULTIPART_STRICT_ERROR "[email protected] 0" "phase:2,t:none,log,deny,status:44,msg:'Multipart request body failed strict validation: PE %{REQBODY_PROCESSOR_ERROR}, BQ %{MULTIPART_BOUNDARY_QUOTED}, BW %{MULTIPART_BOUNDARY_WHITESPACE}, DB %{MULTIPART_DATA_BEFORE}, DA %{MULTIPART_DATA_AFTER}, HF %{MULTIPART_HEADER_FOLDING}, LF %{MULTIPART_LF_LINE}, SM %{MULTIPART_MISSING_SEMICOLON}, IQ %{MULTIPART_INVALID_QUOTING}, IP %{MULTIPART_INVALID_PART}, IH %{MULTIPART_INVALID_HEADER_FOLDING}, FL %{MULTIPART_FILE_LIMIT_EXCEEDED}',id:1234123456"
When this rule was implemented, many clients complained about false positives triggered by the IQ segment (MULTIPART_INVALID_QUOTING).

I would like to avoid whitelisting the whole rule and would prefer skipping only the IQ test.

I have two questions:
  1. How to edit this rule to skip the IQ part.
  2. How should I override this rule (not in modsec2.conf obviously because it will be overwritten by easyapache on next run).

I thank you in advance for your assistance.

Kind Regards,

Seb

Also on this topic:
- http://forums.cpanel.net/f185/modsecurity-2-7-3-issues-352881.html
 

quizknows

Well-Known Member
Oct 20, 2009
1,008
87
78
cPanel Access Level
DataCenter Provider
I would honestly try just removing the "IQ %{MULTIPART_INVALID_QUOTING}," part from modsec2.conf, then run an EA and see if it reverts it. If it does revert, you could make a custom hook to "Fix" the file after EA runs. Otherwise, the easiest way to whitelist would be by script file name in modsec2.user.conf or other includes file. Say it's tripping on someones site "submit.php" file, then add this:

<LocationMatch "submit.php">
SecRuleRemoveById 1234123456
</LocationMatch>

That would whitelist all checks from the multipart rule on that particular filename, but it's better than whitelisting it completely for the server or domain.
 

sebby

Well-Known Member
Jun 15, 2004
70
0
156
Canada
cPanel Access Level
Root Administrator
Hi,

I already tried removing the "IQ %{MULTIPART_INVALID_QUOTING}," part from modsec2.conf but it doesn't work. The legitimate scripts were still blocked. I think that this particular string is there only for verbose mod_sec reporting/logs (i.e. explain why the rule was triggered).

I am already using ConfigServer ModSecurity Control and used it to whitelist the complete rule server wide while I find a solution.

So again may question is: Is there a way to skip the IQ test?

Kind Regards,

Seb