206 Commits

Author SHA1 Message Date
Ervin Hegedus
ac332cc79d
Revert "'jit' variable not initialized when WITH_PCRE2 is defined" 2024-02-07 23:10:22 +01:00
Marc Stern
0cd8b15c5a Fixed variable definition scope (compile error) 2024-02-05 10:36:04 +01:00
Marc Stern
26d2b0d069
Merge pull request #2954 from marcstern/v2/mst/optim2
remove useless memset
2024-02-01 11:08:09 +01:00
Marc Stern
1d9ad64a56 if WITH_PCRE2 id defined, jit was not initialized 2023-09-25 16:15:19 +02:00
Marc Stern
077d1bd0b7 if WITH_PCRE2 id defined, jit was not initialized 2023-09-25 16:00:17 +02:00
Marc Stern
931f8b6ed4
Update re_operators.c 2023-08-21 09:39:42 +02:00
Marc Stern
9c0d05f734
Update re_operators.c 2023-08-21 09:33:27 +02:00
Marc Stern
3dc5ff5f65 remove useless memset 2023-08-11 16:44:18 +02:00
Martin Vierula
2105ed0639 Do not escape special chars in regex pattern with macro 2023-07-27 06:21:45 -07:00
Martin Vierula
a17cbc8f5e
Support for JIT option for PCRE2 2022-12-07 07:47:42 -08:00
Martin Vierula
8fc0b519b7
Support for PCRE2 2022-11-08 08:06:39 -08:00
Martin Vierula
d9df7f529e
Limit rsub null termination to where necessary 2022-09-06 05:29:38 -07:00
John Lightsey
039b35029c
Fix other usage of the global pool for request temporaries in re_operators.c 2021-01-14 14:23:39 -03:00
John Lightsey
e419b50fe7
Store temporaries in the request pool for regexes compiled per-request.
The code for testing regexes with embedded Apache variables
(rule->re_precomp == 1) during request processing was utilizing the global
engine pool for the storage of temporary values. This approach is not
threadsafe, retains the temporary variables longer than they are usable,
and causes corruption of the global pool's "cleanups" linked-lists when
Apache is configured with a threaded MPM.
2021-01-14 14:23:39 -03:00
Felipe Zimmerle
176276a931
Fix the order of error_msg validation
Reported by @marcstern at #2128
2019-07-10 14:52:46 -03:00
Victor Hora
aab128f810 Code cosmetics: checks if actionset is not null before use it 2018-09-22 20:21:23 -04:00
Felipe Zimmerle
739048749e
Fix utf-8 character encoding conversion
Reported on: #1794
2018-09-04 21:02:09 -03:00
Felipe Zimmerle
6406e2108d
Makes `large stream optimization' optional 2017-10-06 16:43:45 +00:00
Allan Boll
6ce7f4d689
Remove the unneeded null termination for the stream_input_data 2017-10-05 17:20:41 +00:00
Allan Boll
afae690655
Preallocate memory when SecStreamInBodyInspection is on. 20x speed improvement for 10mb upload. Also simplified modsecurity_request_body_to_stream. 2017-10-05 17:20:40 +00:00
Victor Hora
9b90d86f75
Add capture action to @detectXSS operator 2017-10-05 03:24:23 +00:00
Robert Paprocki
96a1f55e16
Read fuzzy hash databases on init
Instead of reading the fuzzy db on every invocation, read and store
the db contents during initialization and store the contents in memory.
The only significant behavior change here is that a change in db contents
now (obviously) requires a daemon restart, as no API is provided to
flush the list of ssdeep chunks.
2017-04-06 13:20:24 -03:00
Robert Paprocki
fd49ca7138
Don't leak an fd on fuzzy hash initialization
Since we're re-opening this file with every invocation, let's
close our sanity check fd.
2017-04-06 13:20:24 -03:00
Felipe Zimmerle
b1e4954a86 Closes a file handle that was left opened on fuzzy hash
Fuzzy hash implementation was lefting a file handle behind whenever the results
matched.
2014-12-12 04:34:21 -08:00
Felipe Zimmerle
069122194e Reducing the amount of compilation warnings 2014-12-11 12:42:58 -08:00
Felipe Zimmerle
fa77c93589 Fix typo on fuzzy hash match message
Replaced "Socore" with Score.
2014-12-11 12:42:58 -08:00
Felipe Zimmerle
dc81e4f852 Informs problems and successfully loaded external resources during reload
Resources load mechanism as the SecRemoteRuels were not showing information
about the loaded rules while Apache was reloaded. This patch add such
information to reload in the same way that it was showing on restart.
2014-12-11 12:42:58 -08:00
Felipe Zimmerle
ce4cf24f6e Refactoring external resources download warn messages
Holding the message to be displayed when Apache is ready to write on the
error_log instead of the default output. Regression tests were added.
2014-12-11 12:42:49 -08:00
Felipe Zimmerle
d4a055e78e Checks HTTP code after performing a resource download
As reported by Walter Hop on our dev- mailing list, remote resource download
was not validating the HTTP code, parsing errors pages as resources. This
commit fix  this issue, from now one HTTP error codes will be verified and
treated as errors. Operators are now dealing well with empty values that may
be produced in consequence of a download error.
2014-12-11 12:39:31 -08:00
Felipe Zimmerle
23823bb2c3 Makes Curl no longer a mandatory depedency for ModSecurity core
As reported by Rainer Jung, Curl may not be mandatory to build
	ModSecurity core. This patch make it optional by:
	- Concentrate all downloads using curl on msc_remote_rules.c
	- Split Curl build definitions checks into: WITH_CURL, WITH_REMOTE_RULES
	and WITH_CRYPTO.
	  - WITH_CURL: Contains Culr headers and binaries during the build time.
	  - WITH_REMOTE_RULES: Currently enabled if Curl is present.
	  - WITH_CRYPTO: Set if apr tool was compiled with crypto support.
	- Renames msc_remote_grab_content to msc_remote_download_content
2014-12-03 08:28:59 -08:00
Felipe Zimmerle
9fe72b72de Improves the CA validation
On IIS CA validation was not working as libcurl on windows does not look for a
certificate store, unless it is specified. The resource downloads are now
respecting the SecRemoteRulesFailAction.
2014-11-17 19:32:32 -08:00
Felipe Zimmerle
b5398abaf2 Forces downloads using https-only for resources or rules
This commit makes ModSecurity to refuse to download or install rules
(SecRemoteRules) from sites that are not running HTTPS with a valid and
trusted certificate.
2014-11-14 11:53:40 -08:00
Felipe Zimmerle
899ee0c365 Adds support to load remote resources to pmFromFile and ipMatchFromFile
Initially those directives were only able to load content from a
local file. This commit extends this functionality allowing the user to
provide an HTTP URI that can be downloaded and loaded by ModSecurity.
Initially the download is associated with a server restart. For next
versions we expect to load such resources as it become outdated (Without
need to resetart the server).
2014-11-14 11:53:40 -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
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
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
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
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
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
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
Nick Galbreath
74ec784005 libinjection sync 2013-12-18 04:19:02 +00:00
Breno Silva
0fc4142a31 Change strncpy to memcpy 2013-07-05 02:45:05 -07:00
Breno Silva
4064e74cca Fixed: Libjection 3.0.0 compilation errors 2013-06-19 11:05:59 -07:00
Nick Galbreath
c07b9a5362 libinjection v3.0.0pre21 take 2 2013-06-23 13:58:22 +09:00
Breno Silva
f003243d9c Merge pull request #106 from client9/remotes/trunk
libinjection 2.0.0
2013-05-27 06:08:03 -07:00
Nick Galbreath
3a3fda25f7 libinjection 2.0.0 2013-05-17 23:41:45 +09:00
Breno Silva
fed38c8107 Fixed: return msgs at detectSQLi 2013-05-08 16:22:47 -04:00