Rafa_F
January 10, 2016, 2:39pm
1
Dear all
Fascinated by nginx, I attempted to integrate it with modsecurity.
Unfortunately, ever when modsecurity is enabled, nginx reports a
sefault in sysmessages.
Searching the web did not reveal any solution, i.e. I switched off
SecAudit* and even started modsecurity without rules – it continued
crashing.
Thank you for any hint on solving this issue.
Please find next information related to my setup including some logs.
wbr, Lukas
==
My current setup:
Platform: Linux/4.3.3 running on Debian/wheezy
nginx: self-compiled from sources according to
https://blog.stickleback.dk/nginx-modsec-on-ubuntu-14-04-lts/
modsecurity: installed and configured according to
Relevant Logs:
$ /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.9
built by gcc 4.7.2 (Debian 4.7.2-5)
built with OpenSSL 1.0.1e 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=www-data --group=www-data --with-pcre-jit
–with-ipv6 --with-http_ssl_module
–add-module=…/modsecurity-2.9.0/nginx/modsecurity
–conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid
–error-log-path=/var/log/nginx/error.log
–http-log-path=/var/log/nginx/access.log
$ tail error.log
2016/01/10 13:13:34 [notice] 10256#0: ModSecurity: LIBXML compiled
version=“2.8.0”
2016/01/10 13:13:34 [notice] 10256#0: ModSecurity: Status engine is
currently disabled, enable it by set SecStatusEngine to On.
2016/01/10 13:13:35 [notice] 10260#0: ModSecurity for nginx
(STABLE)/2.9.0 (http://www.modsecurity.org/ ) configured.
2016/01/10 13:13:35 [notice] 10260#0: ModSecurity: APR compiled
version=“1.4.6”; loaded version=“1.4.6”
2016/01/10 13:13:35 [notice] 10260#0: ModSecurity: PCRE compiled
version="8.30 "; loaded version=“8.30 2012-02-04”
2016/01/10 13:13:35 [notice] 10260#0: ModSecurity: LIBXML compiled
version=“2.8.0”
2016/01/10 13:13:35 [notice] 10260#0: ModSecurity: Status engine is
currently disabled, enable it by set SecStatusEngine to On.
2016/01/10 13:13:38 [alert] 10261#0: worker process 10267 exited on
signal 11
2016/01/10 13:13:38 [alert] 10261#0: worker process 10264 exited on
signal 11
2016/01/10 13:13:38 [alert] 10261#0: worker process 10265 exited on
signal 11
$ dmesg
[605432.202671] nginx[10267]: segfault at 70 ip 08093ba1 sp bfc9a7c0
error 4 in nginx[8048000+123000]
[605432.385414] nginx[10264]: segfault at 70 ip 08093ba1 sp bfc9a7c0
error 4 in nginx[8048000+123000]
[605432.409089] nginx[10265]: segfault at 70 ip 08093ba1 sp bfc9a7c0
error 4 in nginx[8048000+123000]
–
Lukas Ruf http://www.lpr.ch | Ad Personam
Consecom http://www.consecom.com | Ad Laborem
lukas
January 10, 2016, 2:46pm
2
SecAudit* and even started modsecurity without rules – it continued
crashing.
Thank you for any hint on solving this issue.
Please find next information related to my setup including some logs.
By chance, I tried to get this to work just yesterday and also got only
SIGSEGV from it.
(nginx 1.8, FreeBSD 10.1-amd64, ap22-mod_security-2.9.0, all from my own
repository)
I found this:
opened 11:35AM - 15 Feb 15 UTC
closed 09:02PM - 09 May 17 UTC
TBF by libmodsec
```
2015/02/15 12:25:19 [notice] 4868#0: ModSecurity: Status engine is currently… disabled, enable it by set SecStatusEngine to On.
2015/02/15 12:25:21 [notice] 4878#0: ModSecurity for nginx (STABLE)/2.9.0 (http://www.modsecurity.org/) configured.
2015/02/15 12:25:21 [notice] 4878#0: ModSecurity: APR compiled version="1.5.1-dev"; loaded version="1.5.1-dev"
2015/02/15 12:25:21 [notice] 4878#0: ModSecurity: PCRE compiled version="8.31 "; loaded version="8.31 2012-07-06"
2015/02/15 12:25:21 [notice] 4878#0: ModSecurity: LUA compiled version="Lua 5.1"
2015/02/15 12:25:21 [notice] 4878#0: ModSecurity: LIBXML compiled version="2.9.1"
2015/02/15 12:25:21 [notice] 4878#0: ModSecurity: Original server signature: ModSecurity Standalone
2015/02/15 12:25:21 [notice] 4878#0: ModSecurity: Status engine is currently disabled, enable it by set SecStatusEngine to On.
2015/02/15 12:25:21 [debug] 4880#0: epoll add event: fd:6 op:1 ev:00002001
2015/02/15 12:25:21 [debug] 4880#0: epoll add event: fd:7 op:1 ev:00002001
2015/02/15 12:25:35 [debug] 4880#0: post event 000000000172A5A0
2015/02/15 12:25:35 [debug] 4880#0: delete posted event 000000000172A5A0
2015/02/15 12:25:35 [debug] 4880#0: accept on 0.0.0.0:9090, ready: 0
2015/02/15 12:25:35 [debug] 4880#0: posix_memalign: 00000000016FFC70:256 @16
2015/02/15 12:25:35 [debug] 4880#0: *53 accept: 196.41.235.198 fd:4
2015/02/15 12:25:35 [debug] 4880#0: posix_memalign: 00000000016FFD80:256 @16
2015/02/15 12:25:35 [debug] 4880#0: *53 event timer add: 4: 60000:1423999595042
2015/02/15 12:25:35 [debug] 4880#0: *53 reusable connection: 1
2015/02/15 12:25:35 [debug] 4880#0: *53 epoll add event: fd:4 op:1 ev:80002001
2015/02/15 12:25:35 [debug] 4880#0: *53 post event 000000000172A6D8
2015/02/15 12:25:35 [debug] 4880#0: *53 delete posted event 000000000172A6D8
2015/02/15 12:25:35 [debug] 4880#0: *53 http wait request handler
2015/02/15 12:25:35 [debug] 4880#0: *53 malloc: 00000000016FFE90:1024
2015/02/15 12:25:35 [debug] 4880#0: *53 recv: fd:4 590 of 1024
2015/02/15 12:25:35 [debug] 4880#0: *53 reusable connection: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 posix_memalign: 00000000017002A0:4096 @16
2015/02/15 12:25:35 [debug] 4880#0: *53 http process request line
2015/02/15 12:25:35 [debug] 4880#0: *53 http request line: "GET /index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display HTTP/1.1"
2015/02/15 12:25:35 [debug] 4880#0: *53 http uri: "/index.php"
2015/02/15 12:25:35 [debug] 4880#0: *53 http args: "q=&q=&l=&m=&option=com_finder&task=jobs.display"
2015/02/15 12:25:35 [debug] 4880#0: *53 http exten: "php"
2015/02/15 12:25:35 [debug] 4880#0: *53 http process request header line
2015/02/15 12:25:35 [debug] 4880#0: *53 http header: "Host: www.localhost.com:9090"
2015/02/15 12:25:35 [debug] 4880#0: *53 http header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"
2015/02/15 12:25:35 [debug] 4880#0: *53 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2015/02/15 12:25:35 [debug] 4880#0: *53 http header: "Accept-Language: en-US,en;q=0.5"
2015/02/15 12:25:35 [debug] 4880#0: *53 http header: "Accept-Encoding: gzip, deflate"
2015/02/15 12:25:35 [debug] 4880#0: *53 http header: "Cookie: 670e2aeda114e17c2a9366bc0985c190=9lv67bfhkadnuur9ttm4ctgbr2; _ga=GA1.2.27578087.1423928221; cd717b2c44775918f48c367a6a32f30c=sVpfI2bDKibfa4s9.grxd9DIIvm78ogZysG1i; 9317d58b08847e9f711d4f7c96794057=cnd2fq3ndb9tkur0f8ial5uao0; _gat=1"
2015/02/15 12:25:35 [debug] 4880#0: *53 http header: "Connection: keep-alive"
2015/02/15 12:25:35 [debug] 4880#0: *53 http header done
2015/02/15 12:25:35 [debug] 4880#0: *53 event timer del: 4: 1423999595042
2015/02/15 12:25:35 [debug] 4880#0: *53 rewrite phase: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 test location: "/"
2015/02/15 12:25:35 [debug] 4880#0: *53 using configuration "/"
2015/02/15 12:25:35 [debug] 4880#0: *53 http cl:-1 max:1048576
2015/02/15 12:25:35 [debug] 4880#0: *53 rewrite phase: 2
2015/02/15 12:25:35 [debug] 4880#0: *53 post rewrite phase: 3
2015/02/15 12:25:35 [debug] 4880#0: *53 generic phase: 4
2015/02/15 12:25:35 [debug] 4880#0: *53 modSecurity: handler
2015/02/15 12:25:35 [debug] 4880#0: *53 add cleanup: 00000000017011F0
2015/02/15 12:25:35 [debug] 4880#0: *53 posix_memalign: 00000000017012B0:4096 @16
2015/02/15 12:25:35 [debug] 4880#0: *53 add cleanup: 0000000001701240
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Host: www.localhost.com:9090"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Accept-Language: en-US,en;q=0.5"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Accept-Encoding: gzip, deflate"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Cookie: 670e2aeda114e17c2a9366bc0985c190=9lv67bfhkadnuur9ttm4ctgbr2; _ga=GA1.2.27578087.1423928221; cd717b2c44775918f48c367a6a32f30c=sVpfI2bDKibfa4s9.grxd9DIIvm78ogZysG1i; 9317d58b08847e9f711d4f7c96794057=cnd2fq3ndb9tkur0f8ial5uao0; _gat=1"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Connection: keep-alive"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in done
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: status -1
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: status -1
2015/02/15 12:25:35 [debug] 4880#0: *53 generic phase: 5
2015/02/15 12:25:35 [debug] 4880#0: *53 generic phase: 6
2015/02/15 12:25:35 [debug] 4880#0: *53 access phase: 7
2015/02/15 12:25:35 [debug] 4880#0: *53 access: C6EB29C4 FFFFFFFF C6EB29C4
2015/02/15 12:25:35 [debug] 4880#0: *53 access phase: 8
2015/02/15 12:25:35 [debug] 4880#0: *53 post access phase: 9
2015/02/15 12:25:35 [debug] 4880#0: *53 http init upstream, client timer: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 epoll add event: fd:4 op:3 ev:80002005
2015/02/15 12:25:35 [debug] 4880#0: *53 http script copy: "Host: "
2015/02/15 12:25:35 [debug] 4880#0: *53 http script var: "www.localhost.com"
2015/02/15 12:25:35 [debug] 4880#0: *53 http script copy: "
"
2015/02/15 12:25:35 [debug] 4880#0: *53 http script copy: "X-Real-IP: "
2015/02/15 12:25:35 [debug] 4880#0: *53 http script var: "196.41.235.198"
2015/02/15 12:25:35 [debug] 4880#0: *53 http script copy: "
"
2015/02/15 12:25:35 [debug] 4880#0: *53 http script copy: "Connection: close
"
2015/02/15 12:25:35 [debug] 4880#0: *53 http script copy: ""
2015/02/15 12:25:35 [debug] 4880#0: *53 http script copy: ""
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Accept-Language: en-US,en;q=0.5"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Accept-Encoding: gzip, deflate"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Cookie: 670e2aeda114e17c2a9366bc0985c190=9lv67bfhkadnuur9ttm4ctgbr2; _ga=GA1.2.27578087.1423928221; cd717b2c44775918f48c367a6a32f30c=sVpfI2bDKibfa4s9.grxd9DIIvm78ogZysG1i; 9317d58b08847e9f711d4f7c96794057=cnd2fq3ndb9tkur0f8ial5uao0; _gat=1"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header:
"GET /index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display HTTP/1.0
Host: www.localhost.com
X-Real-IP: 196.41.235.198
Connection: close
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: 670e2aeda114e17c2a9366bc0985c190=9lv67bfhkadnuur9ttm4ctgbr2; _ga=GA1.2.27578087.1423928221; cd717b2c44775918f48c367a6a32f30c=sVpfI2bDKibfa4s9.grxd9DIIvm78ogZysG1i; 9317d58b08847e9f711d4f7c96794057=cnd2fq3ndb9tkur0f8ial5uao0; _gat=1
"
2015/02/15 12:25:35 [debug] 4880#0: *53 http cleanup add: 0000000001701D38
2015/02/15 12:25:35 [debug] 4880#0: *53 get rr peer, try: 1
2015/02/15 12:25:35 [debug] 4880#0: *53 socket 9
2015/02/15 12:25:35 [debug] 4880#0: *53 epoll add connection: fd:9 ev:80002005
2015/02/15 12:25:35 [debug] 4880#0: *53 connect to 10.0.3.10:80, fd:9 #54
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream connect: -2
2015/02/15 12:25:35 [debug] 4880#0: *53 posix_memalign: 0000000001702390:128 @16
2015/02/15 12:25:35 [debug] 4880#0: *53 event timer add: 9: 60000:1423999595042
2015/02/15 12:25:35 [debug] 4880#0: *53 http finalize request: -4, "/index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display" a:1, c:2
2015/02/15 12:25:35 [debug] 4880#0: *53 http request count:2 blk:0
2015/02/15 12:25:35 [debug] 4880#0: *53 post event 000000000173DEE8
2015/02/15 12:25:35 [debug] 4880#0: *53 post event 000000000173DF50
2015/02/15 12:25:35 [debug] 4880#0: *53 delete posted event 000000000173DF50
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream request: "/index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display"
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream send request handler
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream send request
2015/02/15 12:25:35 [debug] 4880#0: *53 chain writer buf fl:1 s:607
2015/02/15 12:25:35 [debug] 4880#0: *53 chain writer in: 0000000001701D70
2015/02/15 12:25:35 [debug] 4880#0: *53 writev: 607
2015/02/15 12:25:35 [debug] 4880#0: *53 chain writer out: 0000000000000000
2015/02/15 12:25:35 [debug] 4880#0: *53 event timer del: 9: 1423999595042
2015/02/15 12:25:35 [debug] 4880#0: *53 event timer add: 9: 60000:1423999595044
2015/02/15 12:25:35 [debug] 4880#0: *53 delete posted event 000000000173DEE8
2015/02/15 12:25:35 [debug] 4880#0: *53 http run request: "/index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display"
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream check client, write event:1, "/index.php"
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream recv(): -1 (11: Resource temporarily unavailable)
2015/02/15 12:25:35 [debug] 4880#0: *53 post event 000000000172A740
2015/02/15 12:25:35 [debug] 4880#0: *53 post event 000000000173DF50
2015/02/15 12:25:35 [debug] 4880#0: *53 delete posted event 000000000173DF50
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream request: "/index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display"
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream dummy handler
2015/02/15 12:25:35 [debug] 4880#0: *53 delete posted event 000000000172A740
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream request: "/index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display"
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream process header
2015/02/15 12:25:35 [debug] 4880#0: *53 malloc: 0000000001705BB0:4096
2015/02/15 12:25:35 [debug] 4880#0: *53 recv: fd:9 165 of 4096
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy status 303 "303 See other"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Server: nginx"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Date: Sun, 15 Feb 2015 11:25:35 GMT"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Content-Type: text/html; charset=utf-8"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Connection: close"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header: "Location: /offres-d-emploi"
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy header done
2015/02/15 12:25:35 [debug] 4880#0: *53 modSecurity: header filter
2015/02/15 12:25:35 [debug] 4880#0: *53 http cacheable: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 http proxy filter init s:303 h:0 c:0 l:-1
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream process upstream
2015/02/15 12:25:35 [debug] 4880#0: *53 pipe read upstream: 1
2015/02/15 12:25:35 [debug] 4880#0: *53 pipe preread: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 readv: 1:3931
2015/02/15 12:25:35 [debug] 4880#0: *53 pipe recv chain: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 pipe buf free s:0 t:1 f:0 0000000001705BB0, pos 0000000001705C55, size: 0 file: 0, size: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 pipe length: -1
2015/02/15 12:25:35 [debug] 4880#0: *53 pipe write downstream: 1
2015/02/15 12:25:35 [debug] 4880#0: *53 pipe write downstream done
2015/02/15 12:25:35 [debug] 4880#0: *53 event timer: 9, old: 1423999595044, new: 1423999595166
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream exit: 0000000000000000
2015/02/15 12:25:35 [debug] 4880#0: *53 finalize http upstream request: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 finalize http proxy request
2015/02/15 12:25:35 [debug] 4880#0: *53 free rr peer 1 0
2015/02/15 12:25:35 [debug] 4880#0: *53 close http upstream connection: 9
2015/02/15 12:25:35 [debug] 4880#0: *53 free: 0000000001702390, unused: 48
2015/02/15 12:25:35 [debug] 4880#0: *53 event timer del: 9: 1423999595044
2015/02/15 12:25:35 [debug] 4880#0: *53 reusable connection: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 http upstream temp fd: -1
2015/02/15 12:25:35 [debug] 4880#0: *53 http output filter "/index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display"
2015/02/15 12:25:35 [debug] 4880#0: *53 http copy filter: "/index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display"
2015/02/15 12:25:35 [debug] 4880#0: *53 modSecurity: body filter
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Host: www.localhost.com:9090"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Accept-Language: en-US,en;q=0.5"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Accept-Encoding: gzip, deflate"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Cookie: 670e2aeda114e17c2a9366bc0985c190=9lv67bfhkadnuur9ttm4ctgbr2; _ga=GA1.2.27578087.1423928221; cd717b2c44775918f48c367a6a32f30c=sVpfI2bDKibfa4s9.grxd9DIIvm78ogZysG1i; 9317d58b08847e9f711d4f7c96794057=cnd2fq3ndb9tkur0f8ial5uao0; _gat=1"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in: "Connection: keep-alive"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers in done
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers out: "Location: /offres-d-emploi"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers out: "Content-Type: text/html; charset=utf-8"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers out: "Location: /offres-d-emploi"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers out: "Connection: keep-alive"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: load headers out done
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: status 0
2015/02/15 12:25:35 [debug] 4880#0: *53 posix_memalign: 0000000001706BC0:4096 @16
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers in: "Host: www.localhost.com:9090"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers in: "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers in: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers in: "Accept-Language: en-US,en;q=0.5"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers in: "Accept-Encoding: gzip, deflate"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers in: "Cookie: 670e2aeda114e17c2a9366bc0985c190=9lv67bfhkadnuur9ttm4ctgbr2; _ga=GA1.2.27578087.1423928221; cd717b2c44775918f48c367a6a32f30c=sVpfI2bDKibfa4s9.grxd9DIIvm78ogZysG1i; 9317d58b08847e9f711d4f7c96794057=cnd2fq3ndb9tkur0f8ial5uao0; _gat=1"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers in: "Connection: keep-alive"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers in done
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers out: "Location: /offres-d-emploi"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers out: "Content-Type: text/html; charset=utf-8"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers out: "Connection: keep-alive"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers out: "Server: EWS"
2015/02/15 12:25:35 [debug] 4880#0: *53 ModSecurity: save headers out done
2015/02/15 12:25:35 [debug] 4880#0: *53 HTTP/1.1 303 See other
Date: Sun, 15 Feb 2015 11:25:35 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /offres-d-emploi
Server: EWS
2015/02/15 12:25:35 [debug] 4880#0: *53 write new buf t:1 f:0 00000000017070B8, pos 00000000017070B8, size: 196 file: 0, size: 0
2015/02/15 12:25:35 [debug] 4880#0: *53 http write filter: l:0 f:0 s:196
2015/02/15 12:25:35 [debug] 4880#0: *53 http postpone filter "/index.php?q=&q=&l=&m=&option=com_finder&task=jobs.display" 0000000001702280
2015/02/15 12:25:35 [debug] 4880#0: *53 http chunk: 0
2015/02/15 12:25:35 [debug] 4881#0: epoll add event: fd:6 op:1 ev:00002001
2015/02/15 12:25:35 [debug] 4881#0: epoll add event: fd:7 op:1 ev:00002001
2015/02/15 12:25:35 [alert] 1266#0: worker process 4880 exited on signal 11 (core dumped)
```
So, you need to set
proxy_force_ranges on;
in the location you want to protect with mod_security.
It didn’t segfault any more after this - but I haven’t had time to check
how well it actually works.
Rainer
lukas
January 10, 2016, 2:49pm
3
Hi Lukas,
You may want to use the ModSecurity’s nginx_refactoring branch instead
of
the master branch. Here is the link to the branch:
Br.,
Felipe Z.
Lead dev for ModSecurity
lukas
January 10, 2016, 3:03pm
4
crashing.
So, you need to set
proxy_force_ranges on;
in the location you want to protect with mod_security.
It didn???t segfault any more after this - but I haven???t had time to check how
well it actually works.
Thanks for your hint, Rainer. Now it has not crahed anymore…
wbr
Lukas
lukas
January 10, 2016, 3:05pm
5
Hi Felipe
Felipe Z. [email protected] [2016-01-10 14:49]:
You may want to use the ModSecurity’s nginx_refactoring branch instead of
the master branch. Here is the link to the branch:
GitHub - SpiderLabs/ModSecurity at nginx_refactoring
Thanks for your hint.
I found that recommendation. Since I also read that it would not be
fully compatible with OWASP/CRS I have not given it a try.
What is the situation regrading OWASP/CRS?
wbr
Lukas
lukas
January 11, 2016, 5:12pm
6
Hi Lukas,
On Sun, Jan 10, 2016 at 11:05 AM Lukas [email protected] wrote:
I found that recommendation. Since I also read that it would not be
fully compatible with OWASP/CRS I have not given it a try.
What is the situation regrading OWASP/CRS?
Currently there are three different versions of ModSecurity for nginx:
Version 2.9.0: That is the last released version, I think that is the
one
that you are using.
nginx_refactoring: That version contains some fixes on the top of
v2.9.0,
but those fixes may lead to instabilities depending on your
configuration.
ModSecurity-connector: That is something that still under development
and
we have some work to do, to be exactly:
Only use the ModSecurity-connector if you understands well the
ModSecurity
rules and the consequences of the missing pieces.
Further information about libModSecurity can be found here:
or:
libModSecurity is a major rewrite of ModSecurity. It preserves the rich syntax and feature set of ModSecurity while delivering improved performance, stability, and a new experience in easy integration on different. libModSecurity - Motivations While...
Br.,
Felipe.
lukas
January 20, 2016, 12:11am
7
Hi Felipe
Currently there are three different versions of ModSecurity for nginx:
Thanks for pointing this out.
What worries me a “little bit” is that nginx started crashing with an
Out-of-Memory Exception when ModSecurity 2.9.0 with OWASP/CRS was
activated.
Have others experienced similar problems?
Isn’t there at least a run-time control in nginx that kills
subprocesses like ModSecurity as soon as they start overconsuming
resources/execution time?
Thanks.
wbr
Lukas
lukas
January 20, 2016, 12:27am
8
Hi Robert
Robert P. [email protected] [2016-01-20 00:14]:
ModSecurity isn’t a sub-process, it’s compiled into the nginx binary and
runs as part of the worker process(es). Nginx doesn’t have a concept of
spawning children in the manner you’re referencing, so there’s nothing to
be monitored wrt. resource consumption. Any resource monitoring would be
done by the kernel, and the target would be nginx itself.
Thanks for clarifying.
If you’re running into an OOM condition with the nginx worker process, it
sounds like a leak within one of the modules (possible, but not definitely,
ModSecurity, if it only happens when you load the OWASP CRS).
I have not had the time to test different variants yet. The
proxy-setup, however, works perfectly fine with “ModSecurityEnabled
off;” but crashes otherwise.
My current config:
server {
listen 443 ssl;
listen [::]:443 ssl;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name foobar;
ssl on;
ssl_certificate crt.stack.pem;
ssl_certificate_key key.pem;
ssl_session_timeout 5m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers
HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location / {
ModSecurityEnabled off;
ModSecurityConfig modsecurity/modsecurity_crs_10_setup.conf;
proxy_force_ranges on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://ip.ad.dr.ess:80;
proxy_redirect http://ip.ad.dr.ess:80 https://$host$request_uri;
client_max_body_size 10m;
client_body_buffer_size 128k;
client_body_temp_path /var/cache/nginx/client_body_temp;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_temp_path /var/cache/nginx/proxy_temp;
}
location ~ /\.ht {
deny all;
}
access_log /var/log/nginx/access.log upstreamlog;
error_log /var/log/nginx/error.log debug;
}
Thanks.
wbr.
Lukas
lukas
January 20, 2016, 12:14am
9
ModSecurity isn’t a sub-process, it’s compiled into the nginx binary and
runs as part of the worker process(es). Nginx doesn’t have a concept of
spawning children in the manner you’re referencing, so there’s nothing
to
be monitored wrt. resource consumption. Any resource monitoring would be
done by the kernel, and the target would be nginx itself.
If you’re running into an OOM condition with the nginx worker process,
it
sounds like a leak within one of the modules (possible, but not
definitely,
ModSecurity, if it only happens when you load the OWASP CRS).
lukas
January 23, 2016, 1:45am
10
Dear all
Lukas [email protected] [2016-01-10 14:39]:
Fascinated by nginx, I attempted to integrate it with modsecurity.
Unfortunately, ever when modsecurity is enabled, nginx reports a
sefault in sysmessages.
I tried debugging the issue a bit further (from a user perspective)
with common web-page and CalDAV with the following results:
nginx with modsecurity switched off works perfectly as a proxy nginx
nginx with modsecurity switched on with one owasp rule-set
(modsecurity_crs_20_protocol_violations.conf) works for common
web-pages with multi-media content (quick test without any errors
reported)
nginx with modsecurity switched on with one owasp rule-set
(modsecurity_crs_20_protocol_violations.conf) does not work for
CalDAV.
error.log: 2016/01/23 01:19:07 [emerg] 4844#0: *7 posix_memalign(16,
4096) failed (12: Cannot allocate memory) while logging request
nginx with modsecurity switched on without any ruleset
does not work for CalDAV – same error
nginx with modsecurity switched off without any ruleset
does work for CalDAV perfectly.
With modsecurity switched on, an Out-of-Memory exception took place
always reporting:
[876715.533926] nginx invoked oom-killer: gfp_mask=0x280da, order=0,
oom_score_adj=0
[876715.533930] nginx cpuset=/ mems_allowed=0
[876715.533936] CPU: 0 PID: 4844 Comm: nginx Not tainted
4.3.3-consecom-ag #1
[876715.533937] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS debian/1.7.5-1-0-g506b58d-dirty-20140812_231322-gandalf 04/01/2014
[876715.533939] f5a53ed0 d52542a6 f5a6b7c0 d5110792 d55a6db0 f5a6bab4
000280da 00000000
[876715.533943] 00000000 ffffffff 0d3f1361 00031d5e f4929cb8 00200282
f4929cb8 f4929cb0
[876715.533946] d50babb7 00200206 d525956e 00000002 00000002 f5020840
f5020bc4 d55a5702
[876715.533949] Call Trace:
[876715.533955] [] ? dump_stack+0x3e/0x58
[876715.533959] [] ? dump_header.isra.8+0x65/0x1be
[876715.533963] [] ? delayacct_end+0x47/0xa0
[876715.533967] [] ? ___ratelimit+0x7e/0xe0
[876715.533970] [] ? oom_kill_process+0x1d9/0x380
[876715.533973] [] ? security_capable_noaudit+0x3a/0x60
[876715.533977] [] ? has_ns_capability_noaudit+0xb/0x20
[876715.533979] [] ? oom_badness+0x96/0x100
[876715.533981] [] ? out_of_memory+0x252/0x320
[876715.533984] [] ? __alloc_pages_nodemask+0x77e/0x7a0
[876715.533989] [] ? handle_mm_fault+0xd54/0xf50
[876715.533990] [] ? vma_merge+0x1bf/0x280
[876715.533992] [] ? do_brk+0x1ca/0x2b0
[876715.533995] [] ? __do_page_fault+0x137/0x3a0
[876715.533998] [] ? vmalloc_sync_all+0x130/0x130
[876715.534001] [] ? error_code+0x5a/0x60
[876715.534003] [] ? vmalloc_sync_all+0x130/0x130
[876715.534004] Mem-Info:
[876715.534008] active_anon:543864 inactive_anon:208884 isolated_anon:0
[876715.534008] active_file:54 inactive_file:77 isolated_file:0
[876715.534008] unevictable:0 dirty:1 writeback:0 unstable:0
[876715.534008] slab_reclaimable:326 slab_unreclaimable:997
[876715.534008] mapped:88 shmem:4 pagetables:957 bounce:0
[876715.534008] free:21502 free_pcp:289 free_cma:0
[876715.534014] DMA free:12152kB min:64kB low:80kB high:96kB
active_anon:1676kB inactive_anon:1928kB active_file:8kB
inactive_file:4kB unevictable:0kB isolated(anon):0kB isolated(file):0kB
present:15992kB managed:15916kB mlocked:0kB dirty:0kB writeback:0kB
mapped:8kB shmem:0kB slab_reclaimable:16kB slab_unreclaimable:76kB
kernel_stack:8kB pagetables:20kB unstable:0kB bounce:0kB free_pcp:0kB
local_pcp:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:120
all_unreclaimable? yes
[876715.534016] lowmem_reserve[]: 0 839 3023 3023
[876715.534021] Normal free:73380kB min:3528kB low:4408kB high:5292kB
active_anon:386788kB inactive_anon:386844kB active_file:208kB
inactive_file:276kB unevictable:0kB isolated(anon):0kB
isolated(file):0kB present:892920kB managed:859928kB mlocked:0kB
dirty:4kB writeback:0kB mapped:324kB shmem:0kB slab_reclaimable:1288kB
slab_unreclaimable:3912kB kernel_stack:672kB pagetables:3808kB
unstable:0kB bounce:0kB free_pcp:564kB local_pcp:564kB free_cma:0kB
writeback_tmp:0kB pages_scanned:115004 all_unreclaimable? yes
[876715.534022] lowmem_reserve[]: 0 0 17471 17471
[876715.534027] HighMem free:476kB min:512kB low:2808kB high:5104kB
active_anon:1786992kB inactive_anon:446764kB active_file:0kB
inactive_file:28kB unevictable:0kB isolated(anon):0kB isolated(file):0kB
present:2236296kB managed:2236296kB mlocked:0kB dirty:0kB writeback:0kB
mapped:20kB shmem:16kB slab_reclaimable:0kB slab_unreclaimable:0kB
kernel_stack:0kB pagetables:0kB unstable:0kB bounce:0kB free_pcp:592kB
local_pcp:592kB free_cma:0kB writeback_tmp:0kB pages_scanned:7836
all_unreclaimable? yes
[876715.534028] lowmem_reserve[]: 0 0 0 0
[876715.534030] DMA: 44kB (E) 7 8kB (UE) 516kB (UEM) 3 32kB (U) 264kB
(EM) 2 128kB (EM) 3256kB (UEM) 1 512kB (E) 21024kB (UE) 2 2048kB (UE)
14096kB (M) = 12152kB
[876715.534039] Normal: 149 4kB (UEM) 1088kB (UEM) 63 16kB (UE) 3232kB
(UEM) 10 64kB (UE) 11128kB (UEM) 5 256kB (UE) 2512kB (EM) 2 1024kB
(UM) 32048kB (UEM) 14 4096kB (M) = 73380kB
[876715.534047] HighMem: 14kB (U) 1 8kB (U) 116kB (M) 2 32kB (UM)
064kB 1 128kB (M) 1256kB (M) 0 512kB 01024kB 0 2048kB 0*4096kB =
476kB
[876715.534054] Node 0 hugepages_total=0 hugepages_free=0
hugepages_surp=0 hugepages_size=4096kB
Thanks for any hints
Lukas
–
Lukas Ruf http://www.lpr.ch | Ad Personam
Consecom http://www.consecom.com | Ad Laborem
lukas
January 23, 2016, 3:50am
11
The modsec devel team is working hard on the new libmodsecurity. You may
just be better off waiting for them to put the finishing touches on that
project. Nginx + modsec 2.9 likely will get no dev attention moving
forward, given that the whole system is being revamped now.
Sent from my iPhone