-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support configurable limit on number of arguments processed #2234
Conversation
Making reference to #2060 |
@jleproust @martinhsv - Since the configuration directive is just arbitrating on the number of JSON parameters, it would be fair to call it SecJSONArgumentsLimit or maybe other name that references the fact that such configuration is related to the JSON implementation? |
The code in the pull request will limit the number of Arguments (within m_variableArgs) no matter how the elements are created. E.g. if you set the configurable value to '5', and send a request like this:
... then the argument 'aaa' will get omitted/skipped. So, SecArgumentsLimit, is the right choice to go with the rest of the code. (The JSON-specific portion of the pull request is a minor extra bit of functionality to stop json-parsing if the argument limit has been reached.) |
@martinhsv Thanks a lot for adding the test! It would be really great if we could merge this. |
Thank you guys @martinhsv @jleproust |
Minor update, added: bad5892. secargumentslimit.json is now part of Makefile.am. Otherwise it won't run on make check. The new version is on the build bots. |
merged! |
Yay thanks! |
Hi, I thought this change made it to v3.0.4 like the changelog in
Except that it didn't :-o I tried to set Then I checked in the code :
Am I missing something ? Regards, |
Hi @rdegez , You are correct, that code is not in v3.0.4, and the CHANGES file is incorrect. Thanks for raising that. I will correct it. |
Correct CHANGES file entry for #2234
The CHANGES file has been corrected. |
I'm fairly certain this issue is only partially fixed with this patch. I'm happy to reopen an issue or file a new one.. Confirmation the patch works when content-type == json:
Switch the feature on:
But if you change the Content-Type to something other than json such as "application/x-www-form-urlencoded", the DDoS condition still exists and an nginx thread is consumed. |
Hi @mlosapio , This configurable limit accomplishes two things:
The main performance issue being addressed here is the very large number of key-value pairs that might be processed by a large number of regular expressions in any sort of generic rule set (whether OWASP CRS or other). Change 1 accomplishes that even for non-json content. See the code changes in transaction.cc. The second change, that applies only to json content, is a more minor benefit. I'm fairly sure that Change 1 works correctly for a large set of application/x-www-form-urlencoded args. And I do recall trying that while reviewing the change back in February. Nevertheless, if you think the number of arguments added to ARGS (etc.) is not being limited for non-json content, feel free to submit a pull request, or otherwise outline what you think is going wrong. |
This is basically the same as pull request 2060, but adds automated tests.