919 Commits

Author SHA1 Message Date
Felipe Zimmerle
59a1746be7 Using real server signature on status call
On Apache platform the server signature can be replaced using the
SecServerSignature directive. Status call was using the signature informed by
this directive instead of using the original one. As reported at #702.
2014-11-14 11:53:39 -08:00
Felipe Zimmerle
8305600d50 Trims long `apache version' in the status call
As reported at #714 status calls with long `apache version' name was broken.
DNS queries cannot be so long. This field is now limited to 25 characters
which is a valid size when encoded into base32
2014-11-14 11:53:39 -08:00
Felipe Zimmerle
de1c028d12 Declares msre_var *rvar at the beggining of the function
Necessary to fix the build on Win8 VS 2011
2014-11-14 11:53:39 -08:00
Felipe Zimmerle
a45fe95ed5 FuzzyHash: if disable giving an run time error instead of config
FuzzyHash operator is optional and only installed if the headers for libfuzzy
was found in the system. Otherwise, the FuzzyHash operator is disable during
the compilation. After this commit, if some rules tries to use it, ModSecurity
will produce an runtime error not a config time error, allowing the web server
to procede normal with its operations.
2014-11-14 11:53:39 -08:00
Felipe \"Zimmerle\" Costa
7affec82a8 iis: Adds ssdeep support 2014-11-14 11:53:39 -08:00
Felipe Zimmerle
96865a92d3 Adds fuzzyHash operator
The fuzzyHash operator can be used to match files. In conjuntcion
with FILES_TMP_CONTENT collection it can scan uploaded files and
try to match it with a pre caculated list of know malicious content,
more details on how it works can be found on ssdeep website:
http://ssdeep.sourceforge.net/
2014-11-14 11:53:39 -08:00
Felipe Zimmerle
873c628b1a Adds ssdeep support in our build system
ssdeep will be used with the @fuzzyHash operator which is under
development
2014-11-14 11:53:39 -08:00
Felipe Zimmerle
accb1820e0 Adds collection FILES_TMP_CONTENT
The collection is filled with a key-value set where value is the content of
the file which was uploaded. This collection can be used with all supported
operators, however SecUploadKeepFiles should be set to 'On' in order
to have this collection filled.
2014-11-14 11:52:56 -08:00
Mauro Faccenda
87df4827dc Print YAJL version on startup. Closing issue: #703 2014-09-30 10:40:03 -03:00
Felipe Zimmerle
046b553736 Fix ipMatch entry on ErrorLog and DebugLog
ipMatch message on error log was not correct, it was missing the matched
ip address. This commit adds the correct matched ip address.
(See issue #738)
2014-06-12 15:49:19 -07:00
Felipe Zimmerle
5d92e448ae Fixes subnets representations using slash notation
The ipv4 representation was only accepting slash notation with masks
represented in 2 digits. In the ipv6 implementation several fixies were made:
The maximum value to a bitmask was 64 which is not the reality, as ipv6 can
handle 128 bits. The second change was also to enable mask representation with
more and less than 2 digits. A more general fix was added to allow the unit
tests to work even if a invalid ip/range was informed during the creation of
the "tree", now it is checking if the tree is NULL while performing the
execution of the operator. Initial problem was reported at the issue: #706.
2014-06-11 09:31:53 -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
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
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
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
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
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
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
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
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
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
Justin Gerace
498b9b2e7a Don't reject a large request with ProcessPartial set 2014-02-28 12:36:48 -08:00
Felipe Zimmerle
063dd640e5 Adds internal error messages while parsing the configutarion
Before this patch, if something went wrong while loading the configuration in
memory, not in terms of syntax but other run time factors such as memory
allocation, the webserver will refuse to start and no further message was given
to the user. This patch adds "Internal Error messages" that are intend to let
the user know more information about the problem that he/she is facing.
2014-02-24 03:56:17 -08:00
Felipe Zimmerle
795d6a64d2 nginx: Warn about not workable 'proxy'
Proxy is not yet ready for nginx. Instead of give a generic error, this patch
adds a clean message explains that such functionality is not available on the
nginx port. This patch also modifies the test cases to reflect this changes.
2014-01-09 11:12:28 -08:00