1533 Commits

Author SHA1 Message Date
Felipe Zimmerle
db6bafa2b5 Merge branch 'nginx_refactoring' of https://github.com/defanator/ModSecurity into nginx_refactoring_def 2014-06-05 09:53:50 -07:00
Andrei Belov
d0ead529d9 Explicitly set log object to r->connection->log in preaccess phase handler.
This change fixes a number of scenarios when ModSecurity's log entries
may be written to the wrong file descriptors. In particular, there was
an issue with almost any configuration using nginx cache features
(proxy_cache, fastcgi_cache, etc) when garbage from ModSecurity logs
has been sent to the control socket used for communication between
nginx master process and auxiliary processes (workers, cache manager,
cache loader).

Described behavior was observed with nginx/1.7.0, modsecurity/2.8.0
and OWASP CRS v2.2.9.
2014-06-03 17:30:04 +04:00
Andrei Belov
5d9f0d85b2 All ngx_log_debug() calls changed to ngx_log_debug0(). 2014-06-02 11:48:54 +04:00
Andrei Belov
a20c7a7091 Fixed ngx_http_modsecurity_body_filter() to properly handle filters chain.
Body filter is a wrong place to call ngx_http_next_header_filter() - that
function is intended to be called from header filters.
In case when there were no errors, body filter should call
ngx_http_next_body_filter() eventually.
While here, also removed useless second return.
2014-05-19 16:12:12 +04:00
Andrei Belov
77feb2b761 Fixed ngx_http_modsecurity_header_filter() to call next header filter eventually.
Returning of NGX_OK there may lead to request's hang, in particular when HEAD
method is used.
2014-05-19 15:55:51 +04:00
Andrei Belov
ab04202456 Fixed ngx_http_modsecurity_body_filter() to properly handle filters chain.
Body filter is a wrong place to call ngx_http_next_header_filter() - that
function is intended to be called from header filters.
In case when there were no errors, body filter should call
ngx_http_next_body_filter() eventually.
While here, also removed useless second return.
2014-05-17 06:51:08 -07:00
Andrei Belov
b2bbf91993 Fixed ngx_http_modsecurity_header_filter() to call next header filter eventually.
Returning of NGX_OK there may lead to request's hang, in particular when HEAD
method is used.
2014-05-17 06:51:01 -07:00
Andrei Belov
1d4c122e10 Obtain port from r->connection->local_sockaddr.
This eliminates segfaults caused by unset (NULL) r->port_start
and non-NULL r->port_end. In fact, r->port_start is always NULL,
so it is useless to rely on this pointer.
2014-05-15 21:02:42 -07:00
Andrei Belov
39a07b8133 Removed unneeded and invalid initialization. 2014-05-15 21:01:18 -07:00
Andrei Belov
8a8041170e Fixed segmentation fault if http context is not defined. 2014-05-15 20:39:39 -07:00
Felipe Zimmerle
f8d2eb086b Merge branch 'InfoHunter-master' into nginx_refactoring
Pull request: #720
2014-05-15 19:47:13 -07:00
Andrei Belov
1baeaef7fc Obtain port from r->connection->local_sockaddr.
This eliminates segfaults caused by unset (NULL) r->port_start
and non-NULL r->port_end. In fact, r->port_start is always NULL,
so it is useless to rely on this pointer.
2014-05-15 15:56:44 +04:00
Andrei Belov
f16d98bb75 Removed unneeded and invalid initialization. 2014-05-14 14:45:24 +04:00
Andrei Belov
c74a806ce7 Merge branch 'nginx_refactoring' of github.com:defanator/ModSecurity into nginx_refactoring 2014-05-14 13:25:14 +04:00
paulyang
ccd0b3037d Bugfix: add -P option in test script
Otherwise nginx's installation directory could not be specified.

Signed-off-by: paulyang <paulyang.inf@gmail.com>
2014-05-14 10:04:10 +08:00
Andrei Belov
62ead2a12c Fixed segmentation fault if http context is not defined. 2014-05-12 17:07:59 +04:00
Felipe Zimmerle
9be379fe26 niginx: cosmetics: Changes CRLF to LF 2014-04-30 11:43:32 -07:00
Felipe Zimmerle
c57f27e2c3 nginx: cosmetics: Removes trailing whitespace 2014-04-30 11:43:32 -07:00
Felipe Zimmerle
6ee920d359 nginx: cosmetics: Splits lines longer than 80 characters 2014-04-30 11:43:28 -07:00
Felipe Zimmerle
0abd99a525 Regression: Accept different ports on FULL_REQUEST unit test.
FULL_REQUEST unit test was expecting only for the default regression test
suite port. Now it is expecting for [0-9]+.
2014-04-30 07:24:49 -07:00
Felipe Zimmerle
dfb8bdb77c nginx: copies the req body chain to be processed instead of move
Add a check for the definition MOVE_REQUEST_CHAIN_TO_MODSEC, whenever it is
set the chain will be moved into the brigade. If it was not set the chain
will be only copied. Moving was causing segfaults on the following
regression tests:

 #15 - SecRequestBodyInMemoryLimit
 #16 - SecRequestBodyInMemoryLimit (greater)
 #19 - SecRequestBodyLimitAction ProcessPartial (multipart/greater - chunked)
 (from: regression/config/10-request-directives.t)
2014-04-30 07:24:49 -07:00
Felipe Zimmerle
e7760c4ef3 nginx: better dealing with chunked request body 2014-04-30 07:24:46 -07:00
Felipe Zimmerle
2c6bcd7469 nginx: looking for segfaults on the regression test.
If nginx segfaults it will return, warning that the test failed.
2014-04-30 07:23:39 -07:00
Felipe Zimmerle
a5db5ff641 nginx refactoring
Refactoring on the nginx module, including:
 - Better handling larger posts;
 - Now using nginx echo module during the regression tests.
 - Better interacting with neginx chain rules
 - Separation of the request handling and content filters.
 - Better handling nginx sessions and resource counts to allow a
   more efficient garbage collector.
 - Handling both http/1.0 and 1.1, including keep-alive.
 - Tests are now capable to test nginx as a proxy or end-server.
 - Tested agains nginx 1.6 and 1.7.
2014-04-30 07:23:23 -07:00
Felipe Zimmerle
c4a5a1e11a Version 2.8.0
* Updated change log.
* Removed -RC1 from the release version.
2014-04-14 10:12:03 -07:00
Felipe Zimmerle
50e4961dd4 Uses autotools to idenfiy if sys/utsname.h is present
Fix build problem on the msc_status_engine, reported by: Walter Hop and
Derek Werthmuller.
2014-04-14 07:55:21 -07:00
Felipe Zimmerle
33231378d7 Increases the package version on the configure.ac
Changed to 2.8
2014-04-11 05:32:19 -07:00
Felipe Zimmerle
480f6bac77 Merge pull request #692 from rcbarnett/master
Update CHANGES for Chunked Encoding CVE Credits
2014-04-03 09:40:51 -03:00
Ryan Barnett
62a76e1ed6 Update CHANGES 2014-04-03 08:36:42 -04:00
Felipe Zimmerle
ad5824c00c Fix type on the CHANGES file. 2014-04-01 03:11:01 -07:00
Felipe Zimmerle
0826380acd Version 2.8.0 2014-03-31 19:31:02 -07:00
Felipe Zimmerle
385a2828e8 Code cosmetics: Reduces the amounts of warning.
Removes the warnings by adding missing headers and removed unused variables.
2014-03-31 16:22:11 -07:00
Felipe Zimmerle
1e63e49db4 Uses %zu to print size_t instead of %d.
This will help to reduce the amount of warnings during the compilation
See #631 for further information.
2014-03-31 16:22:11 -07:00
Felipe Zimmerle
503e8f6c8e Updates the libinjection
Windows compilation was failing due to the utilization of size_t which is part
of the strings.h. strings.h was not part of windows and so the compilation
was failing. This update fix that. Issue #65 on libinjection:
https://github.com/client9/libinjection/issues/65
2014-03-31 16:22:11 -07:00
Felipe Zimmerle
66939d059b Adds initial support to @detectXSS
Libinject was recently updated to support XSS detection. This commit adds
initial support to it.
2014-03-31 16:22:11 -07:00
Felipe Zimmerle
47f5cf92db Removes forced chartset
Apperantly forcing the charset is not placing any benefits, instead it is
cousing problems as documented on #650. This still experimental, just
testing against our regression tests. Such feature was added by the commit:
177b5b9c989b0095e5c91b01d205df64e65e6c9e.
2014-03-31 16:22:11 -07:00
Felipe Zimmerle
efef989ddd Renames Sec{Read|Write}StateLimits
The Sec{Read|Write}StateLimits are filters related to the connections, when the
server did not know yet which vhost the request goes to. This means that once
those configrations are set it will be applied to entire server. This patch
just renames the Sec{Read|Write}StateLimits to SecConn{Read|Write}StateLimits
to make it more clear to the user. SecConnectionEngine was also renamed to
SecConnEngine.
2014-03-31 16:22:11 -07:00
Felipe Zimmerle
48d85c7d6e Places connection filter engine in a separated configuration
Different from the Rules or other options, the connections filters are applied
to entire server, not to a single vhost, or so. In order to keep it clear to
the user this patches adds "SecConnectionEngine" which works in the same way
that SecRuleEngine does.
2014-03-31 16:22:10 -07:00
Felipe Zimmerle
a15f8813e9 Honor the SecRuleEngine while filtering connections
The SecRuleEngine has the capability to Enable, Disable or even to place the
ModSecurity in DetectionOnly mode. The SecReadStateLimit and SecWriteStateLimit
were not honoring such state, due the fact that our configuration belongs to
requests not to connections, the only struct that exists while those filters
are placed. By adding a global variable "conn_limits_filter_state" we are now
able to identify the current state of the ModSecurity, once the configuration
is loaded this variable is set and used by the connections filters.
2014-03-31 16:22:10 -07:00
Felipe Zimmerle
0037a0732a Using RadixTree instead of list to storage IPs
Used by the operator @ipMatch and variants, this structure storage all the IPs
addresses for later comparison. Last version was using RadixTree only if the
set of IPs was specified from files. IPs specified as parameters, was using
a chained list. Chained lists may affect the performance, since lookups in
worst case will be O(n). RadixTrees could provide better results depending
on the amount of elements and its contents.
2014-03-31 16:22:10 -07:00
Felipe Zimmerle
80185e2a90 Bugfix: Missing ipv6 support check
The Function "ip_tree_from_file" was making a reference for
IPV6_TREE whitout checkingx if it was supported or not.
2014-03-31 16:22:10 -07:00
Felipe Zimmerle
b9fdc4fe3b Adds support to suspicious and whitelist to Read and Write limits
The operators @ipMatch, @ipMatchF and @ipMatchFromFile were
added to the functions: SecReadStateLimit and SecReadStateLimit,
by using them it is possible to declare a suspicious list. When
a suspicious list is given, the {Read|Write}StateLimit will be
applied just to the IPs that belongs to that restricted list.
Note that the negative of those operators (e.g. !@ipMatch) can be
used to place a whitelist. The {Read|Write}StateLimit
restrictions will not be applied to those in the whitelist.
This current version the Sec{Read|Write}StateLimit can be used
varios times to add elements to both lists, however, the
last informed limit will be applied for the entire group. This
feature is experimental, and suggestions on how to improve it
are very welcome. For further discussion use the issue: #353.
2014-03-31 16:22:10 -07:00
Felipe "Zimmerle" Costa
8ff3de5b6f iis: Disables installer repair
Currently we don't have support to repair, so, this commit is
marking it as disabled.
2014-03-31 16:22:10 -07:00
Felipe "Zimmerle" Costa
d6dd1f0e94 iis: Adding VC110 files to the Windows installer
For some reason the DLLs still demands the dependencies of the
VC110 files. Providing those as part of the MSI installer
2014-03-31 16:22:10 -07:00
Felipe Zimmerle
28d4f9fce1 iis: Checks Win version before declare inet_pton
Checking for `!(NTDDI_VERSION >= NTDDI_VISTA)` to decide whenever or not
to declare the inet_pton function.
2014-03-31 16:22:10 -07:00
Felipe Zimmerle
bd0980f63d Reverts commit: a4202146b8d26b6615bbab986383fe0afae60d77
Testing inet_pton with the help of Steffen. Acording to Steffen we can use
!(NTDDI_VERSION >= NTDDI_VISTA) to identify that the specific Windows version
has this function defined or not, if so we can use the Windows version.
Reverting this commit to avoid to overwrite the Windows' function. And
see the original error that happened before this commit.
2014-03-31 16:22:10 -07:00
Felipe "Zimmerle" Costa
93b12df721 iis: Removes unnecessary files.
"Installer project" is now longer used.
2014-03-31 16:22:10 -07:00
Felipe "Zimmerle" Costa
fe727c7021 iis: Updated OWASP crs to version 2.2.9 2014-03-31 16:22:10 -07:00
Felipe "Zimmerle" Costa
10db384316 iis: Adds cleanup methods to the installer
Older versions of ModSecurity left files/configurations behind. This commit
adds capability to cleanup the IIS configuration files.
2014-03-31 16:22:10 -07:00
Felipe "Zimmerle" Costa
f8f06f7930 IIS: Updates build_msi.bat to fit the new WiX install options
Instead of -dPlatform a recent update in the WiX files are demanding
the parameter -arch, although this parameter is not valid nor needed
while running "light".
2014-03-31 16:22:10 -07:00