Skip to content

ProcessPartial can truncate request bodies in combination with mod_proxy_ajp and mod_wl #2091

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

Closed
rainerjung opened this issue May 14, 2019 · 1 comment
Assignees
Labels
2.x Related to ModSecurity version 2.x enhancement
Milestone

Comments

@rainerjung
Copy link

Version: 2.9.3

Symptom: when uploading files to a backend using mod_proxy_ajp or mod_wl, the request body (file contents) can get truncated. The problem is reproducible when using

SecRuleEngine DetectionOnly
SecRequestBodyAccess On
SecRequestBodyLimitAction ProcessPartial

and setting SecRequestBodyNoFilesLimit, SecRequestBodyLimit and SecRequestBodyInMemoryLimit to a value smaller than the file size. In addition I could only easily reproduce the problem when not including any CRS rules. I can provide a full config plus simple test app if needed.

The problem happens when the rquest body limit is reached and partial body processing is active. If bytes are overflowing to disk, then the last read attempt from the mod_security input filter will return 0 bytes and remove the input filter from the filter chain. Following retrievals from the filter chain will correctly return the remaining bytes.

But mod_wl and mod_prox_ajp react on a 0 byte return from the request body read by ending the request body transfer to the backend. For mod_wl the reason is not clear (closed source), but the result is a "503 Service Unavailable" error. For mod_proxy_ajp the reason is, that a zero byte AJP request body packet indicates the end of the body in the AJP protocol, so the backend doesn't pull the remaining parts of the body and instead starts sending the response.

I will create a simple PR. The patch tracks, whether the mod_security input filter actually returns data or not. In case it does not return data and removes itself from the chain, it will delegate to the remaing filter chain instead of just returning APR_SUCCESS.

Regards,

Rainer

@victorhora victorhora self-assigned this May 16, 2019
@victorhora victorhora added the 2.x Related to ModSecurity version 2.x label May 16, 2019
@victorhora victorhora added this to the v2.9.4 milestone May 16, 2019
zimmerle pushed a commit that referenced this issue May 27, 2019
… the last read and if not, delegate to the remaining filter chain.

Without that, ProcessPartial for the request body breaks forwarding
of uploaded files using mod_proxy_ajp and mod_wl.

See issue #2091.
@zimmerle
Copy link
Contributor

Fixed at #2092.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to ModSecurity version 2.x enhancement
Projects
None yet
Development

No branches or pull requests

3 participants