-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
Text/plain or custom Content-Type bypasses body evaluation. #438
Comments
Hey! Evaluation of content-types for urlencoded is only enforced if content-type is x-www-form-urlencoded or the CTL variable |
Hi @jptosso!
I debugged a bit and seems that if no processing is done on the body, the latter is not added to the transaction. With #439 it is now working. Could it make sense to have a generic Thanks for the help and feedbacks |
There is a design reason for that. There are many cases where we just want to avoid processing the body, mostly because of resources and DDOS. Specific pages, specific mimes, specific lengths. We cannot accept all bodies by default, it must be custom tailored by the user according to his needs. For that exact reason ForceRequestBodyVariable exists, if you want to force the request body you may use it. |
I see, and I understand the reasoning behind the necessity of defining boundaries between analyzing it or not.
Why should a user expect that a legit content type like |
You can also force the body processor by ctl: requestBodyProcessor=JSON, for example. If you would like to expand this discussion, we could check it on tomorrow's meeting #388 |
Just for context. What is modsec default behaviour?
…On Tue, 27 Sept 2022, 19:38 Juan Pablo Tosso, ***@***.***> wrote:
You can also force the body processor by ctl: requestBodyProcessor=JSON,
for example.
If you would like to expand this discussion, we could check it on
tomorrow's meeting #388 <#388>
—
Reply to this email directly, view it on GitHub
<#438 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXOYARJEUVAQMVH2ACCIN3WAMWHXANCNFSM6AAAAAAQW36QN4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Writing down a recap about when the request body is evaluated:
Speaking about running the CRS:
To the best of my knowledge, ModSecurity:
If we are on the same page about the described behaviour I would close this issue and propose to just merging @jcchavezs's PR #441. |
This issue is stale because it has been open for 30 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
Is this still an issue @M4tteoP? |
I think that we somewhat agreed that the behaviour described in the previous comment) is the intended one. So, unless new considerations are made, we can keep this issue closed |
Description
POST requests with an explicit Content-Type header equal to
text/plain
or even just an empty space lead to not analyzing the body and directly sending it to the server.I'm running a Coraza instance with a simple rule that checks the request body against a string (
maliciouspayload
):Curl requests like the followings, with explicit Content-Type different than
application/x-www-form-urlencoded
are leading to not checking the body:curl -i -X POST -H 'Content-Type: text/plain' 'http://localhost:8090' --data "maliciouspayload"
curl -i -X POST -H 'Content-Type: ' 'http://localhost:8090' --data "maliciouspayload"
Logs:
"@rx maliciouspayload" against "": NO MATCH
particularly caught my eye, meaning that the evaluation is performed, but against an empty string.While, with
application/x-www-form-urlencoded
, the body is evaluated and the request is denied:curl -i -X POST -H 'Content-Type: application/x-www-form-urlencoded' 'http://localhost:8090' --data "maliciouspayload"
Logs:
Steps to reproduce
Curl commands above against this branch (http-server example).
Is this an intended behaviour evaluating only super specific Content-Types? If so, shouldn't this behaviour be handled by the CRS rule 900220 that checks allowed Content-Types?
Thanks!
The text was updated successfully, but these errors were encountered: