Skip to content

Modsecurity V3 causes nginx to core dump on a system with limited ram when uploading a large file #1517

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
AndrewFromMelbourne opened this issue Jul 31, 2017 · 1 comment
Assignees

Comments

@AndrewFromMelbourne
Copy link

AndrewFromMelbourne commented Jul 31, 2017

We are using Modsecurity V3 and nginx on a system with limited ram/swap space. We accepted a file upload that has a reasonable size.

nginx log

2017/07/30 22:07:05 [alert] 11633#11633: worker process 11634 exited on signal 6 (core dumped)
2017/07/30 22:07:05 [warn] 11636#11636: *46 a client request body is buffered to a temporary file /var/lib/nginx/body/0029830514, client: 192.168.0.4, server: localhost, request: “POST /upload.html HTTP/1.1”, host: “192.168.0.5", referrer: “http://192.168.0.5/upgrade.html”
terminate called after throwing an instance of ‘std::bad_alloc’
 what():  std::bad_alloc

The function Transaction::requestBodyFromFile() uses std::string::reserve() to allocate a buffer the same size as the file being read. On systems that have limited memory, this results in the std::bad_alloc exception being thrown, which causes (in our system) nginx to core dump.

@zimmerle zimmerle self-assigned this Jul 31, 2017
@zimmerle
Copy link
Contributor

zimmerle commented Jul 31, 2017

Hi @AndrewFromMelbourne,

Now we have a graceful error if there is no memory. Should not segfault anymore. Thanks ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants