-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File upload finishes with MULTIPART_UNMATCHED_BOUNDARY error #244
Comments
Hi @airween , I have seen the 'UNMATCHED_BOUNDARY' in unexpected cases (i.e. where the final boundary is indeed present). Typically this is because the request body stopped being processed before the final boundary was reached (hence the parser does not signal that the final boundary was found). For example:
I tried your example in my test setup and did not get that error. Suggestions to proceed:
|
Hi @martinhsv, thanks for quick feedback.
as you can see in my modsecurity.conf, I have an explicit value for that:
So I'm sure the problem is not this (the size of sent file is 10 bytes). Also you can see the whole config in @defanator's repository - the value is 256M.
this is the relevant output of tcpdump it runs during the request:
There are both
Can you share your setup? Or can you try with the mentioned Vagrant config?
you mean about this?
error.log:
debug.log
Same result. |
Thanks for the extra information. I'll try to have a closer look on Monday. |
I think I found the root cause of the problem - check this rule: +SecRule MULTIPART_UNMATCHED_BOUNDARY "@gt 1" \
+ "id:'200004',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'" I have no idea where did I got this rule, but this is definitely wrong. According to recommended modsecurity.conf, the correct operator and its argument are So that was my faul - thanks for your time and sorry for the noise. |
Hi @airween , Given your update, I didn't wind up debugging this. However, I strongly suspect that this is an unintended effect of the way the PEM solution was implemented (#1747 and #1924) . In my 'B' comments at owasp-modsecurity/ModSecurity#2417 (comment) , note the use case when the PEM-like content is in the final part of the multipart body. Just from code inspection, I suspect what you've recently seen is a similarly impacted case. I.e. that in your case, the flag=2 result is being triggered because there is only one part within the whole multipart body. I think this lends weight that we this PEM-inspired modification should really be properly revisited. |
Hi @martinhsv, thanks for your time.
yes, I think this is true - but the problem was in my config, namely the operator and its argument was wrong in that rule. I have no idea where did I get, but luckily I found the root case.
yes, absolutely - as I see the sent PR is nearly half year old. Do you plan to approve it only to 3.1? Thanks again. |
I always run into a MULTIPART_UNMATCHED_BOUNDARY error when I upload any kind of file.
The test environment is @defanator's Vagrant image.
Components:
This is what I modified:
Short summary of modifications:
modsecurity.conf
- few things were modifedHere is the PHP file what I used:
The file what I try to upload:
curl commands:
in the error.log:
Note: this request has sent to
/upload/
which was already configured.Another curl command:
in the error log I got:
When I run tcpdump, I see that there IS the final boundary in the request. I also tried it from browser, final boundary also at there.
Am I spoiling something? Or is this a really unexpected behavior?
The text was updated successfully, but these errors were encountered: