1500 Commits

Author SHA1 Message Date
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
Felipe "Zimmerle" Costa
4d7d1ba822 iis: Adds listing dependencies script
This script could be used in order to verify all ModSecurity run time
dependencies. It is now part of ModSecurity folder in Program menu.
Cosmetics changes in the installer
2014-03-31 16:22:10 -07:00
Felipe "Zimmerle" Costa
619758c0c2 iis: Adds condition to avoid the use of 32b msi on a 64b os
The 64bits version of the package offer the possibility to install the 32bits
version of the DLL along with all 32bits dependencies.
2014-03-31 16:22:10 -07:00
Felipe "Zimmerle" Costa
93a86f6f33 iis: Adds Visual C++ 12.0 Runtime to be part of the msi package
Visual C++ 12.0 Runtime files are now part of ModSecurity MSI package.
Users don't have to download the vcredist files anymore. Build script
was also updated, to handle the new flag -arch.
2014-03-31 16:22:10 -07:00
Felipe Zimmerle
ec61749a68 Changes JSON parser to not accept parcial contents
Also cleanup installer file.
2014-03-31 16:22:10 -07:00
Felipe Zimmerle
966e7e1ff1 Adds verification before access the strcmp
Audit log was making the assumption that "arg->origin" was filled which
is not necessary true. This commit adds an verification.
2014-03-31 16:22:09 -07:00
Felipe Zimmerle
c5c2690809 Adds origin to the paramenters that cames from JSON
That is necessary otherwise the Auditlog will try to access it generating
a segfault.
2014-03-31 16:22:09 -07:00
Felipe Zimmerle
52bef20ce5 Adds unit test to the JSON parser
Unit test to test whenever the JSON parser is enabled
2014-03-31 16:22:09 -07:00
Felipe Zimmerle
a95f37196e Adds JSON support on ISS port
The JSON parse is already supported in Nginx and Apache
versions. This patch adds support on the IIS port.
2014-03-31 16:22:09 -07:00
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
Felipe Zimmerle
09ced44ffa Supports the yajl version 2
Initially the code was made to support the yajl version 1. The
version 2 is now the default option in most of Linux distributions.
2014-03-31 16:22:09 -07:00
Felipe Zimmerle
8d4c3e4f5c Makes the build system to look for yajl using a macro file
Now searching for yajl using find_yajl.m4 macro file instead
of using pkg-config directly. If YAJL was not found or if it
was disabled in the configure phase, the code will be compiled
without JSON support.
2014-03-31 16:22:09 -07:00
Ulisses Albuquerque
e90874a694 Added sample JSON content-type rule 2014-03-31 16:22:09 -07:00
Ulisses Albuquerque
c23097ce18 Added support for JSON body processor 2014-03-31 16:22:09 -07:00
Felipe Zimmerle
410aca9d78 Optimization on the status engine call
The status string was too long. By removing meaningless stuff, such as: runtime
version of Lua, we have reduced the length of the status string. Limitations
were also placed regarding the size of the ModSecurity version. Big queries may
lead to failure, due to restrictions of "gethostbyname". There is also a bit of
code cosmetics in this patch: big functions were broken into smaller.
2014-03-31 16:22:05 -07:00
Felipe "Zimmerle" Costa
20014c808c Adds modsecStatusEngineCall to standalone API
In ModSecurityIIS the configuration is loaded upon the first request
is received. In other words, SecStatusEngine value can be only
loaded once the first request hit the server, and so, the status
function was moved to proceed just after the configuration got loaded.
This update is IIS only.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
d75e443b9b Adds regression test to SecStatusEngine
Just checking the error log while have SecStatusEngine set to On in a first
test and Off in a second.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
a6d93441c1 Places StatusEngine to be Off by default
StatusEngine is now marked as Off by default. This patch also adds the
SecStatusEngine directive to our recommend configuration file.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
e131e2222d Adds support to status engine on IIS version
Fixes on the windows versions: build, mac address and machine name retrieval
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
f86a71f7a7 Adds SecStatusEngine On/Off switch
Add the possibility to turn the Status Engine On or Off using the
directive SecStatusEngine [On/Off]. By default it is On.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
0c6a661c69 First version of the status engine implementation
The Status Engine allow the measurements of how many ModSecurity
instances are running around the world, as long as information
on how many times it had been restarted and so on. Everytime that
the server is started it perform a DNS query that is redirected
to our servers, that query constains information about the
ModSecurity version and it dependencies versions. It also sends a
unique indetification generate locally for the server, avoiding
counting the same server twice while generating the statistics.
This id is a sha-1 hash of the machine name + mac address of the
first network adapter. In this commit it is enabled by default,
in the release will be a configuration option to disable this
functionality. It also important to cite that the information
gather by this query will be also available in ModSecurity website
public open via a JSON stateless API. There will be an fancy
heatmap as well.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
d93ce9ceee Adds REQUEST_FULL and REQUEST_FULL_LENGTH variables
This variable is a combination from REQUEST_LINE, REQUEST_HEADERS and
REQUEST_BODY (if any). Expects for \n\n in between each of those values.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
62f3d02894 Adds utf8toUnicode.t to our unit tests
A bug was reported related to our utf8toUnicode transformation, so, adding this
unit test to confirm the bug and to check whenever it is fixed. Bug #671.
2014-03-31 07:14:55 -07:00
Greg Chow
5b0c933cf3 Fixes UTF8 to Unicode conversion bug in 4-byte encodings 2014-03-31 07:14:55 -07:00
Ewald Dieterich
7e459827e0 Log why writing to audit log failed
Add error description from apr_strerror() to message that is logged if
writing to audit log failed.
2014-03-31 07:14:55 -07:00
Ewald Dieterich
607dfd229a Fix segmentation fault if writing to audit log fails
A segmentation fault occurs if concurrent audit log format is enabled
(SecAuditLogType Concurrent) and writing to the log fails.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
5342f36162 iis: Uses code 400 instead of 44 in modsecurity.conf
Following the recent changes that has been made on:
modsecurity.conf-recommended
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
a0ed3dbbe2 Merge pull request #666 from derhansen/master
Uses code 400 instead of 44 in modsecurity.conf-recommended
2014-03-31 07:13:46 -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
David Andrews
27dd513ab6 Flip allocations that happen during initialization (typically) over to use non-global apr memory pools. 2014-03-03 08:00:53 -08:00
Felipe Zimmerle
31d7fc6d38 Code cosmetics: Place copy_rules in nice shape.
Continuation of kukackajiri's work to provide fixes for errors pointed by
Parfait. The function copy_rules had an integer as return code but it was not
filed proper neither checked by its callers. This commit just adds sanity
checks and documentation for the copy_rules function. Marking were placed
on the copy_rules callers, but the return code is not handled yet.
For kukackajiri's work, see merge request: #612
2014-03-03 04:27:29 -08:00
Jiri Kukacka
62a6f228f8 Fixes for Parfait errors - mostly unhandled NULL pointer dereference and data type mismatch 2014-02-28 17:05:41 -08:00
Felipe Zimmerle
5f996d45f0 Adds regression test to SecRequestBodyLimitAction
This commits adds the following regiression test to SecRequestBodyLimitAction:
* config - SecRequestBodyLimitAction Reject (multipart/greater - chunked): passed
* config - SecRequestBodyLimitAction Reject (plain/greater): passed
* config - SecRequestBodyLimitAction ProcessPartial (multipart/greater - chunked): passed
* config - SecRequestBodyLimitAction ProcessPartial (plain/greater): passed
2014-02-28 13:33:49 -08:00
Justin Gerace
498b9b2e7a Don't reject a large request with ProcessPartial set 2014-02-28 12:36:48 -08:00