Mitigate DoS vulnerability by limiting number of extracted arguments #2060
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A relatively small json payload (<1MB) can generate up to a hundred thousands keys and values, which can then take ages (>30 minutes) to process with OWASP's CRS 3 for example. The parser is not the issue, no particular rule is the issue, it's just the pure quantity of values.
Obviously, with the nginx connector, this completely locks the worker for the whole duration, so it is a DoS vulnerability.
This is the underlying issue behind #2019 and I guess, owasp-modsecurity/ModSecurity-nginx#89 too.
That's why I implemented a
SecArgumentsLimit
value, disabled by default, allowing to set a limit to the number of extracted arguments. When the limit is reached, subsequent values are ignored. A limit of 1000 arguments should be enough for most applications, and reduces the maximum processing time to well under a second. Requests with more than 1000 arguments can be matched and rejected if wanted with a rule likeSecRule &ARGS "@gt 1000"
.In addition, I made the JSON processor cancel the parsing when the limit is reached.