Skip to content
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

Conflicts with ModSecurity #1

Open
sharmashivanand opened this issue Aug 20, 2019 · 4 comments
Open

Conflicts with ModSecurity #1

sharmashivanand opened this issue Aug 20, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@sharmashivanand
Copy link

Just here to chime in and say that if you are using ModSecurity-nginx / ModSecurity (v3), there is a conflict and you'd see errors like this in nginx error log. The module itself doesn't cause this, but I had the directive security_headers on; which caused this. Haven't tested with other directives. Hope this helps anyone coming across this one. Difficult to find.

2019/08/20 19:56:31 [alert] 2957#2957: worker process 2980 exited on signal 6
terminate called after throwing an instance of 'std::bad_alloc'

@dvershinin
Copy link
Contributor

Does this happen for any requests? Or need to craft specific request in order to reproduce? Thanks

@sharmashivanand
Copy link
Author

sharmashivanand commented Aug 21, 2019 via email

@dvershinin dvershinin added the bug Something isn't working label Aug 21, 2019
@dvershinin dvershinin self-assigned this Aug 21, 2019
@dvershinin
Copy link
Contributor

@sharmashivanand the error itself hinted that it's coming from some C++ code,
I assumed it is an issue with libmodsecurity itself.

It seems that libmodsecurity is "sensitive" to the Server header being removed by ngx_security_headers. So I only took an action of defaulting to not removing server headers by default, e.g. security_headers on; alone should no longer cause issues with modsecurity.

If you also put hide_server_tokens off;, which is the new directive responsible for the server headers hiding (e.g. Server, X-Powered), it may expose the libmodsecurity failure.

All that said though, it's been a while and I've just tried with:

    modsecurity on;
    security_headers on;
    hide_server_tokens on;

... and I can't get it to error.

My own setup is basically all latest stable releases:

  • libmodsecurity 3.0.4
  • nginx modsecurity connector module1.0.1
  • ngx_security_headers 0.0.8
  • owasp crs 3.2.0
  • NGINX 1.16.1
  • RHEL 8

If you can confirm (or anyone else) that this works without issues, we can safely assume that libmodsecurity fixed whatever problem they had; and revert to the old behavior (default to hiding server tokens).

@Zoey2936
Copy link

I can confirm, the error is gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants