70 Commits

Author SHA1 Message Date
Felipe Zimmerle
0787b45481 Adds support to JSON parser in the nginx module
Building with --enable-standalone-module was failing due
the lack of the reference to the msc_json.c file inside the
standalone/Makefile.am. This patch also place the dependency
of the yajl to the nginx module config script.
2014-03-31 16:22:09 -07:00
David Andrews
dda91f1689 Standalone: independently destroy the connection and request pools
Add independent modsecFinishConnection API that allows you to independently
destroy the connection and request pools. This is to facilitate reuse of a
connection for multiple requests.
2014-03-03 14:17:00 -08:00
Felipe Zimmerle
fe14d9df4d nginx: Considering modsec state before apply any rules
For some reason the state of modsec (enable, disable or detecting only) was not
being checked under certain circumstances. For instance, while reading the
body. This was leading ModSecurity to fail and consequently nginx. This patch
added the to standalone implementation mechanism to verify the state that is now
verified under the nginx module.
2014-01-13 18:44:47 -08:00
Felipe Zimmerle
7ac515ee29 nginx: Adds proper support to SecServerSignature
SecServerSignature was leading nginx to crash. It was trying to write over a
memory area that it was not allowed to. In order to fix that a new function was
created on the standalone api. This function is called
modsecIsServerSignatureAvailale. Whenever it returns data it means that the
function SecServerSignature was used by the user. Nginx module was also patched
to support this new function.
2014-01-08 18:06:32 -08:00
Felipe Zimmerle
2a43589395 nginx: Removes problematic performance improvement
In an attempt to boost the performance the headers were being checked in two
different situations, the first if SecResponseBodyAccess was Off and in a
second situation if SecResponseBodyAccess was set to On. This makes sense
however functionalities such as content injection demands the body even if
SecResponseBodyAccess was not enabled. This patch removes the first scenario,
leaving just the second one. After this modification the following regression
tests started to pass:

from: regression/action/10-append-prepend.t
  1) action - append content: passed
  2) action - prepend content: passed
2014-01-07 19:26:43 -08:00
Felipe Zimmerle
e20c800044 nginx: fix missing headers while SecResponseBodyAccess was On
The problem was caused by the fact that ModSecutiry was telling Nginx that
headers had been sent when, in fact, had not. This modification was added in
the past, along with others, in the following commit: fd2c30fa2311e783eecf3bf02bf3dcfbabc3968a
This patch, just removes the "r->header_sent = 1". After that modification
the following regression tests started to work again:

from: action/00-disruptive-actions.t
   3) action - pass in phase:3
   4) action - pass in phase:4
  11) action - deny in phase:3
  12) action - deny in phase:4
  19) action - redirect in phase:3 (get)
  20) action - redirect in phase:4 (get)
  23) action - proxy in phase:3 (get)
  24) action - proxy in phase:4 (get)
from: config/10-response-directives.t
   2) config - SecResponseBodyAccess On
   6) config - SecResponseBodyLimit (greater)
   7) config - SecResponseBodyLimitAction Reject
2014-01-06 19:10:24 -08:00
ahuango
b788ce2608 Clean the garbage character after the duplicated charset property
Pull request #148 by zimmerle doesn't fix the problem. '\0' in format
string won't be processed by "ngx_vslprintf".
When the garbage character is '\n' or '\r', http response is cracked and
browsers may go crashing.
2013-12-18 16:50:44 -08:00
Felipe Zimmerle
87115e770a Adds a default config script to nginx 2013-12-18 03:48:15 -08:00
Felipe Zimmerle
351b9cc357 nginx: generates config file using configure input.
The nginx config file was looking for depedencies by its own,
by doing that it was ignoring the options that were passed to
configure script. This commit deletes this config file and adds
a meta-config which is populated by configure whenever the
standalone-module is enabled.
2013-12-12 15:35:01 -08:00
Felipe \"Zimmerle\" Costa
da16d9e5d5 nginx: adds lua support 2013-12-12 14:53:49 -08:00
Felipe Zimmerle
65d9272fdc nginx: Trying apxs and apxs2 while compiling nginx module 2013-12-12 14:53:49 -08:00
Felipe Zimmerle
35fd75d859 nginx: Trying apxs and apxs2 while compiling nginx module 2013-12-12 14:53:49 -08:00
Felipe Zimmerle
1734221d9d Fix #154, Uses addn instead of apr_table_setn
The headers are represented in the format of an apr_table, which
is able to handle elements with the same key, however the function
apr_table_setn checks if the key exists before add the element, if so
it replaces the old value with the new one. This was making our
implementation to just keep the last added Cookie. The apr_table_addn
function, which is now used, just add a new item without check for
olders one.
2013-10-24 10:55:58 -03:00
Felipe Zimmerle
7f7d00fa2c Revert "Merge pull request #139 from chaizhenhua/remotes/trunk"
This reverts commit 10fd40fb0d06f6c577d870b6f15d2f6e2a3a5b1b, reversing
changes made to 414033aafa94cd50c9b310afd3f164740caccc94.
2013-10-18 11:02:10 -03:00
Felipe Zimmerle
ff19dcd5c5 Bugfix: missing string terminator while mounting the charset (nginx)
The charset in headers is mounted using ngx_snprintf which
does not place the string terminator. This patch adds the
terminator at the end of the string. The size was correctly
allocated, just missing the terminator.

This bug was report at:
- https://www.modsecurity.org/tracker/browse/MODSEC-420
- https://github.com/SpiderLabs/ModSecurity/issues/142

Both reports cames with patch, first by Veli Pekka Jutila and
second by wellumies.
2013-09-30 21:56:57 -03:00
Felipe Zimmerle
57330da9a1 nginx: Makes the build script to check for deps
The ModSecurity module has some dependencies that may not be part
of the Nginx build, and so it is not part of the configuration
options. In order to resolve this dependencies automatically this
`config' is now making use of the pkg-config, utility that is
popular to make this compatible layer between different Linux
distributions and operational systems.
2013-09-18 09:19:41 -03:00
chaizhenhua
e0993fcd7a Fixed fd leackage after reload 2013-08-27 22:10:46 +08:00
Breno Silva
885eeecefb Fix outbound size of salt variable 2013-06-12 09:51:25 -07:00
Breno Silva
a79e818497 Merge pull request #116 from chaizhenhua/remotes/trunk
Nginx: Fixed segfaults on reload
2013-06-12 07:32:53 -07:00
chaizhenhua
4ffdf9bf6d Nginx: Fixed segfaults on reload 2013-06-11 19:44:02 +08:00
chaizhenhua
bad4586277 Nginx: Try to fix eats 100% cpu in ngx_event_pipe_write_to_downstream issue 2013-05-13 21:46:43 +08:00
Breno Silva
400a5f5f55 Nginx: Fix implicit declaration of base64 encode funtion 2013-05-13 03:54:18 -04:00
Breno Silva
35b36b7032 Nginx: Fix UNIQUE_ID 2013-05-13 03:34:47 -04:00
Breno Silva
6126374890 Merge pull request #96 from chaizhenhua/remotes/trunk
Nginx: Try to fix eats 100% cpu in ngx_event_pipe_write_to_downstream issue..
2013-05-13 07:30:27 -07:00
Breno Silva
aa18ec7f45 Updated copyright dates 2013-04-19 03:20:46 -04:00
chaizhenhua
fd2c30fa23 Nginx: minor improve 2013-04-17 11:17:17 +08:00
chaizhenhua
fdf0ba540f Nginx Improved: set filter_need_in_memory flag so that nginx transfer response in memory, we do not need read from file buffer. 2013-04-11 16:02:06 +08:00
chaizhenhua
74278a8e9e Nginx Improved response body filter, issue #56 might be fixed 2013-04-09 10:31:16 +08:00
chaizhenhua
e553761aec Nginx Improved: if "SecResponseBodyAccess off" do not copy response body buffer 2013-04-07 12:32:10 +08:00
chaizhenhua
ddd6bd2a70 Nginx Improved: modsec terminate handling 2013-04-05 02:41:34 +08:00
chaizhenhua
5ce1818a9a Nginx Fixed if "master_process off" is set nginx will crash at exit 2013-04-04 21:42:05 +08:00
chaizhenhua
a951a83eec Nginx: Improved redirect action work for phases except log 2013-03-31 15:26:45 +08:00
chaizhenhua
088c660d58 Improved build script 2013-03-31 15:24:45 +08:00
chaizhenhua
42e9a5ab24 Nginx: Fixed internal request finalized after rewrite with regex 2013-03-28 12:08:40 +08:00
chaizhenhua
86871ccab1 Fixed: Nginx crash in ngx_pool_context.c 2013-03-28 11:04:33 +08:00
chaizhenhua
6934acf0e1 Nginx: Fixed memory leakage 2013-03-28 10:20:22 +08:00
chaizhenhua
a87b06f9f0 Nginx: Fixed config file 2013-03-28 10:11:28 +08:00
Breno Silva
2fcc08952b Nginx: fix makefile 2013-03-23 12:33:44 -04:00
chaizhenhua
177b5b9c98 Nginx: Added SecDisableBackendCompression support
Nginx: Added internel redirected request processing
2013-03-22 14:42:56 +08:00
Breno Silva
43162f52cf Fixed: Nginx return 500 when request body is off 2013-03-05 02:38:46 -04:00
Breno Silva
4a8e536b0b Nginx: fixed SecRequestBodyAccess 2013-01-30 16:51:42 -04:00
chaizhenhua
1a89b6b8a6 Fixed deny not work in response phase, Fixed debug log message 2013-01-31 09:09:28 +08:00
chaizhenhua
ed1d3d927a Fixed Action Drop not work 2013-01-27 08:05:46 +08:00
chaizhenhua
972d9e2abf Added Response Phase for Nginx 2013-01-26 22:44:54 +08:00
Greg Wroblewski
c53e743c86 IIS version improvements 2013-01-18 11:39:05 -08:00
Breno Silva
54245c9248 Merge pull request #27 from chaizhenhua/read_client_request_body
remove Nginx ModSecurityPass command
2013-01-11 11:50:43 -08:00
chaizhenhua
0566d652c7 Fixed hang up when post multiple request 2013-01-09 11:08:08 +08:00
chaizhenhua
22b8293fdf Fixed content length error 2013-01-07 10:42:15 +08:00
chaizhenhua
275cb28a0e Added 'ngx_modsecurity_write_body_cb' so that NGINX can deal with STREAM_INPUT_BODY 2013-01-06 21:51:36 +08:00
chaizhenhua
604643c4b9 change CRLF to LF 2013-01-06 16:26:10 +08:00