Skip to content

Modsec can OOM nginx in a container with large response bodies #115

Closed
@jimbobhickville

Description

@jimbobhickville

I have the latest version of nginx, modsecurity, and modsecurity-nginx built in a containerized environment. It seems that modsecurity is buffering responses in memory even when looking at responses is disabled (i.e. SecResponseBodyAccess Off), causing the nginx container to be killed by the OS (Memory cgroup out of memory: Kill process 2553 (nginx) score 1990 or sacrifice child).

If I reconfigure nginx with modsecurity off I'm able to download the large file without running out of memory, so it's not nginx itself that's the culprit here.

Steps to reproduce:

  1. Run nginx+modsec dynamic module with a cgroup memory limit.
  2. Download a file through nginx that is larger than that memory limit.
  3. When the amount downloaded exceeds the memory limit, the worker process is killed by the OS.

I should note that I was hitting a similar issue with the statically-compiled version of nginx+modsec, but it would OOM before the download even started. I had hoped that this dynamic module would behave better. It does, in some sense, in that it will start to download, but it still OOMs after the amount downloaded exceeds the memory limit.

I'm happy to help debug this issue further as it's breaking websites that we host, but I'm not much of a C programmer, so I could use some pointers on how to go about helping.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions