]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agopcap-directory: fix double free in error path 3085/head
Victor Julien [Wed, 13 Dec 2017 12:05:23 +0000 (13:05 +0100)] 
pcap-directory: fix double free in error path

7 years agoapp-layer/counters: check counter id
Victor Julien [Wed, 13 Dec 2017 09:28:19 +0000 (10:28 +0100)] 
app-layer/counters: check counter id

Check counter id before updating a counter. In case of a disabled
parser with the protocol detection enable, the id can be 0. In
debug mode this would lead to a BUG_ON.

7 years agosource-pcap-file: Fix coverity findings (Bug #2356)
Danny Browning [Wed, 13 Dec 2017 01:07:09 +0000 (18:07 -0700)] 
source-pcap-file: Fix coverity findings (Bug #2356)

https://redmine.openinfosecfoundation.org/issues/2356

Address issues found by coverity for resource leaks and use after free.

7 years agosuricata: pcap-file-continuous ignores other options (Bug #2253)
Danny Browning [Tue, 12 Dec 2017 20:07:42 +0000 (13:07 -0700)] 
suricata: pcap-file-continuous ignores other options (Bug #2253)

https://redmine.openinfosecfoundation.org/issues/2353

Command line option pcap-file-continuous was ignoring command line options
passed after its usage. Fixed bug, fixed formatting of help command
regarding pcap-file-continuous.

7 years agoqa: add more drmemory suppressions for hyperscan
Victor Julien [Tue, 5 Dec 2017 14:36:22 +0000 (15:36 +0100)] 
qa: add more drmemory suppressions for hyperscan

7 years agoprefilter/profile: validate end > start
Victor Julien [Tue, 12 Dec 2017 20:05:34 +0000 (21:05 +0100)] 
prefilter/profile: validate end > start

Seen underflow issues on profiling on arm (gettimeofday based.

7 years agoconf: multiple NULL-pointer dereferences in StreamTcpInitConfig 3078/head
Wolfgang Hotwagner [Mon, 11 Dec 2017 20:20:00 +0000 (20:20 +0000)] 
conf: multiple NULL-pointer dereferences in StreamTcpInitConfig

There are several NULL-pointer derefs in StreamTCPInitConfig. All of them happen because ConfGet returns 1 even if the value is NULL(due to misconfiguration for example).
This commit introduces a new function "ConfGetValue". It adds return values for NULL-pointer to ConfGet and could be used as a replacement for ConfGet.

Note: Simply modify ConfGet might not be a good idea, because there are some places where ConfGet should return 1 even if "value" is NULL. For example if ConfGet should get a Config-Leave in the yaml-hierarchy.

Bug: 2354

7 years agoconf: multiple NULL-pointer dereferences in FlowInitConfig
Wolfgang Hotwagner [Sat, 9 Dec 2017 13:18:49 +0000 (13:18 +0000)] 
conf: multiple NULL-pointer dereferences in FlowInitConfig

This commit fixes multiple NULL-pointer dereferences in FlowInitConfig after reading in config-values(flow.hash-size, flow.prealloc and flow.memcap) for flow. Here is a sample ASAN-output:

=================================================================
ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fea73456646 bp 0x7fffd70e1ba0 sp 0x7fffd70e1328 T0)
0 0x7fea73456645 in strlen (/lib/x86_64-linux-gnu/libc.so.6+0x80645)
1 0x7fea76c98eec (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x3beec)
2 0x5643efb4c205 in FlowInitConfig /root/suricata-1/src/flow.c:455
3 0x5643efcd1751 in PreRunInit /root/suricata-1/src/suricata.c:2247
4 0x5643efcd49f4 in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2748
5 0x5643efcd5402 in main /root/suricata-1/src/suricata.c:2884
6 0x7fea733f62b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
7 0x5643ef8761a9 in _start (/usr/local/bin/suricata+0xc51a9)

Ticketno: Bug #2349

7 years agoconf: use of NULL-pointer in DetectLoadCompleteSigPath
Wolfgang Hotwagner [Fri, 8 Dec 2017 22:01:38 +0000 (22:01 +0000)] 
conf: use of NULL-pointer in DetectLoadCompleteSigPath

The "sig_file" argument of DetectLoadCompleteSigPath() is not checked for NULL-values. If this argument is NULL a SEGV occurs because of a dereferenced NULL-pointer in strlen in PathIsAbsolute. This commit fixes bug #2347. Here is the ASAN-output:

==17170==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fd1afa00646 bp 0x7ffe8398e6d0 sp 0x7ffe8398de58 T0)
    0 0x7fd1afa00645 in strlen (/lib/x86_64-linux-gnu/libc.so.6+0x80645)
    1 0x7fd1b3242eec  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x3beec)
    2 0x5561c8cddf7f in PathIsAbsolute /root/suricata-1/src/util-path.c:40
    3 0x5561c8cddfea in PathIsRelative /root/suricata-1/src/util-path.c:65
    4 0x5561c89275e4 in DetectLoadCompleteSigPath /root/suricata-1/src/detect.c:264
    5 0x5561c8929e75 in SigLoadSignatures /root/suricata-1/src/detect.c:486
    6 0x5561c8c0f2b3 in LoadSignatures /root/suricata-1/src/suricata.c:2419
    7 0x5561c8c1051d in PostConfLoadedDetectSetup /root/suricata-1/src/suricata.c:2550
    8 0x5561c8c12424 in main /root/suricata-1/src/suricata.c:2887
    9 0x7fd1af9a02b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    10 0x5561c87b31a9 in _start (/usr/local/bin/suricata+0xc51a9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x80645) in strlen

7 years agoconf: NULL-pointer dereference in ConfUnixSocketIsEnable
Wolfgang Hotwagner [Fri, 8 Dec 2017 21:39:11 +0000 (21:39 +0000)] 
conf: NULL-pointer dereference in ConfUnixSocketIsEnable

The value for the configuration-option "unix-command.enabled" is not properly checked in ConfUnixSocketIsEnable. This causes a NULL-pointer dereference in strcmp. This commit fixes bug #2346. The ASAN-output looks like:

ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f03b69737cc bp 0x7ffcef322c10 sp 0x7ffcef322390 T0)
0 0x7f03b69737cb (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x447cb)
1 0x5617a76d3f55 in ConfUnixSocketIsEnable /root/suricata-1/src/util-conf.c:104
2 0x5617a741b6e7 in DetectEngineMultiTenantSetup /root/suricata-1/src/detect-engine.c:2447
3 0x5617a769e0c3 in PostConfLoadedDetectSetup /root/suricata-1/src/suricata.c:2527
4 0x5617a76a0424 in main /root/suricata-1/src/suricata.c:2887
5 0x7f03b30c82b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
6 0x5617a72411a9 in _start (/usr/local/bin/suricata+0xc51a9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x447cb

7 years agoconf: Memory-leak in DetectAddressTestConfVars
Wolfgang Hotwagner [Fri, 8 Dec 2017 21:05:29 +0000 (21:05 +0000)] 
conf: Memory-leak in DetectAddressTestConfVars

There is a memory-leak in DetectAddressTestConfVars. If the programm takes the "goto error"-path, the pointers gh and ghn will not be freed. This commit fixes bug #2345. Here is the ASAN-output:

=================================================================
ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
0 0x7f4347cb1d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
1 0x55fe1fc8dcfc in DetectAddressHeadInit /root/suricata-1/src/detect-engine-address.c:1534
2 0x55fe1fc8c50a in DetectAddressTestConfVars /root/suricata-1/src/detect-engine-address.c:1306
3 0x55fe1ff356bd in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2696
4 0x55fe1ff365eb in main /root/suricata-1/src/suricata.c:2884
5 0x7f43443892b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
0 0x7f4347cb1d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
1 0x55fe1fc8dcfc in DetectAddressHeadInit /root/suricata-1/src/detect-engine-address.c:1534
2 0x55fe1fc8c524 in DetectAddressTestConfVars /root/suricata-1/src/detect-engine-address.c:1310
3 0x55fe1ff356bd in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2696
4 0x55fe1ff365eb in main /root/suricata-1/src/suricata.c:2884
5 0x7f43443892b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

SUMMARY: AddressSanitizer: 48 byte(s) leaked in 2 allocation(s).

7 years agooutput: don't deadlock on log reopen failure
Victor Julien [Thu, 7 Dec 2017 16:47:03 +0000 (17:47 +0100)] 
output: don't deadlock on log reopen failure

If output log reopen fails, don't try to output the error. This would
lead to a deadlock as reopen was called from a SCLogMessage call. This
call already held the output lock.

Bug #2306.

7 years agoconfigure: style fixup
Victor Julien [Mon, 11 Dec 2017 16:58:20 +0000 (17:58 +0100)] 
configure: style fixup

7 years agodetect: move rule loading into loader files
Victor Julien [Sun, 8 Oct 2017 11:52:12 +0000 (13:52 +0200)] 
detect: move rule loading into loader files

7 years agodetect: move keyword registration into own file
Victor Julien [Sun, 8 Oct 2017 10:37:41 +0000 (12:37 +0200)] 
detect: move keyword registration into own file

7 years agodetect: move grouping/building code into own file
Victor Julien [Sun, 8 Oct 2017 10:17:33 +0000 (12:17 +0200)] 
detect: move grouping/building code into own file

Clean up main detect.c file by moving things related to rule
grouping out.

7 years agodetect: move unittests into tests/
Victor Julien [Sun, 8 Oct 2017 09:55:55 +0000 (11:55 +0200)] 
detect: move unittests into tests/

7 years agompm/ac-ks: apply offset/depth
Victor Julien [Mon, 6 Nov 2017 13:41:39 +0000 (14:41 +0100)] 
mpm/ac-ks: apply offset/depth

7 years agompm/ac-ks: coding style fixes
Victor Julien [Mon, 6 Nov 2017 13:29:15 +0000 (14:29 +0100)] 
mpm/ac-ks: coding style fixes

7 years agompm/ac: add depth/offset support
Victor Julien [Sat, 4 Nov 2017 10:12:23 +0000 (11:12 +0100)] 
mpm/ac: add depth/offset support

7 years agompm: add depth/offset support
Victor Julien [Sat, 4 Nov 2017 10:11:54 +0000 (11:11 +0100)] 
mpm: add depth/offset support

7 years agodetect: content limits propagation
Victor Julien [Sun, 5 Nov 2017 10:37:48 +0000 (11:37 +0100)] 
detect: content limits propagation

Propagate inspection limits from anchered keywords to the rest of
a rule.

Examples:

content:"A"; depth:1; is anchored, it can only match in the first byte

content:"A"; depth:1; content:"BC"; distance:0; within:2;
"BC" can only be in the 2nd and 3rd byte of the payload. So effectively
it has an implicite offset of 1 and an implicit depth of 3.

content:"A"; depth:1; content:"BC"; distance:0; can assume offset:1; for
the 2nd content.

content:"A"; depth:1; pcre:"/B/R"; content:"C"; distance:0; can assume
at least offset:1; for content "C". We can't analyzer the pcre pattern
(yet), so we assume it matches with 0 bytes.

Add lots of test cases.

7 years agokeyword-filesize: add units
Andreas Herz [Fri, 4 Aug 2017 23:06:22 +0000 (01:06 +0200)] 
keyword-filesize: add units

7 years agosource-pcap-file: Pcap Directory Mode (Feature #2222)
Dana Helwig [Thu, 27 Apr 2017 17:17:16 +0000 (11:17 -0600)] 
source-pcap-file: Pcap Directory Mode (Feature #2222)

https://redmine.openinfosecfoundation.org/issues/2222

Pcap file mode that when passed a directory will process all files in
that directory. If --pcap-file-continuous or continuous option is passed
in json, the directory will be monitored  until the directory is
moved/deleted, suricata is interrupted, or the pcap-interrupt command
is used with unix command socket. Existing file implementation and new
directory implementation has moved from source-pcap-file into
pcap-file-helper and pcap-directory-helper.

Engine state will not reset between files.

Also satisfies:
 * https://redmine.openinfosecfoundation.org/issues/2299
 * https://redmine.openinfosecfoundation.org/issues/724
 * https://redmine.openinfosecfoundation.org/issues/1476

Co-Authors: Dana Helwig <dana.helwig@protectwise.com> and
Danny Browning <danny.browning@protectwise.com>

7 years agodoc: add ruleset commands available in unix socket
Eric Leblond [Thu, 29 Sep 2016 21:23:21 +0000 (23:23 +0200)] 
doc: add ruleset commands available in unix socket

7 years agounix-manager: block live reload when -s/-S is specified
Giuseppe Longo [Tue, 2 Aug 2016 14:09:41 +0000 (16:09 +0200)] 
unix-manager: block live reload when -s/-S is specified

Currently, when live reload is executed through
unix-socket, suri prints in the console the following
error message:
"Live rule reload not possible if -s or -S option used at runtime."

Instead, prints "done" in unix socket,
when the live reload is not executed.

7 years agounix-manager: add "ruleset-reload-rules" command
Giuseppe Longo [Tue, 2 Aug 2016 13:11:07 +0000 (15:11 +0200)] 
unix-manager: add "ruleset-reload-rules" command

This add a new command the new naming convention.

The (old) command "reload-rules" is kept for
backward compatibility

7 years agounix-manager: print failed rules
Giuseppe Longo [Mon, 19 Oct 2015 13:06:17 +0000 (15:06 +0200)] 
unix-manager: print failed rules

This permits to print the invalid rules through
unix socket.

An example output is the following:

>>> show-failed-rules
Success:
[
    {
        "filename": "/home/eric/git/oisf/benches/tls-store.rules",
        "line": 2,
        "rule": "alert ts any any -> any 334 (msg:\"Store TLS\"; tls.store; sid:2; rev:1;)"
    },
    {
        "filename": "/home/eric/git/oisf/benches/tls-store.rules",
        "line": 3,
        "rule": "alert ls any any -> any 334 (msg:\"Store TLS\"; tls.store; sid:3; rev:1;)"
    }
]

The dump is limited to 20 entries to avoid to send a too big
message to the client that don't support it by default.

7 years agodetect: save invalid rules
Giuseppe Longo [Mon, 19 Oct 2015 13:02:13 +0000 (15:02 +0200)] 
detect: save invalid rules

This keeps the invalid rules in string format into a list,
added in DetectEngineCtx.

7 years agounix-socket: add ruleset-reload-nonblocking command
Eric Leblond [Fri, 16 Oct 2015 14:19:03 +0000 (16:19 +0200)] 
unix-socket: add ruleset-reload-nonblocking command

Add a non blocking function to reload rules. It will be useful
for remote system management to avoid to block them waiting the
reload. And as we now have a last-reload command we can get the
status of the current reload.

7 years agodetect-engine: remove DONE state
Giuseppe Longo [Wed, 4 May 2016 15:13:39 +0000 (17:13 +0200)] 
detect-engine: remove DONE state

Remove the DONE state to fix a problem with state not being
changed correctly when multiple reload were done. As DONE was
not really useful, we can remove it.

7 years agounix-socket: add commands to print engine stats
Giuseppe Longo [Fri, 9 Oct 2015 07:27:08 +0000 (09:27 +0200)] 
unix-socket: add commands to print engine stats

This permits to print engine stats through
unix socket.

7 years agojson-stats: print engine stats
Giuseppe Longo [Fri, 9 Oct 2015 07:16:40 +0000 (09:16 +0200)] 
json-stats: print engine stats

This adds the engine stats in stats event.
If multi-tenancy is enabled, it will add
stats for each tenant

The following is a snippet of the generated EVE entry:

"detect":{"engines":[{"last_reload":"2015-10-13T09:59:48.044996+0200","rules_loaded":17184,"rules_failed":0}],"alert":28}

Multi-tenancy enabled:

"detect":{"engines":[{"id":1,"last_reload":"2015-10-13T09:56:46.447153+0200","rules_loaded":17084,"rules_failed":0},
                     {"id":2,"last_reload":"2015-10-13T09:56:36.504877+0200","rules_loaded":3268,"rules_failed":0}],
                     "alert":28}

7 years agodetect-engine: add reload time/rules stats
Giuseppe Longo [Fri, 9 Oct 2015 06:59:48 +0000 (08:59 +0200)] 
detect-engine: add reload time/rules stats

This patch adds the following stats for
the detect engine:
- time of the last reload
- number of rules loaded
- number of rules failed

7 years agodoc: update docs for DNS flags logging 3062/head
Pascal Delalande [Fri, 8 Dec 2017 10:37:54 +0000 (11:37 +0100)] 
doc: update docs for DNS flags logging

7 years agodns: store flags for logging for TCP
Pascal Delalande [Fri, 8 Dec 2017 10:37:36 +0000 (11:37 +0100)] 
dns: store flags for logging for TCP

7 years agoDns logger display flags information
Clément Galland [Thu, 19 Oct 2017 13:47:03 +0000 (13:47 +0000)] 
Dns logger display flags information

7 years agodns: log flags field
Giuseppe Longo [Tue, 20 Dec 2016 14:33:09 +0000 (15:33 +0100)] 
dns: log flags field

This adds dns header's flags in eve
log.

Signed-off-by: Eric Leblond <eric@regit.org>
7 years agodoc: Amend the list of accepted protocols
Ralph Broenink [Sun, 3 Dec 2017 15:13:38 +0000 (16:13 +0100)] 
doc: Amend the list of accepted protocols

Based on the list in suricata.yaml

7 years agodoc: Add my own name to the acknowledgements
Ralph Broenink [Sat, 14 Oct 2017 10:34:28 +0000 (12:34 +0200)] 
doc: Add my own name to the acknowledgements

7 years agodoc: Move IP reputation keyword to rules section
Ralph Broenink [Sat, 14 Oct 2017 10:29:05 +0000 (12:29 +0200)] 
doc: Move IP reputation keyword to rules section

7 years agodoc: Restructure ToC
Ralph Broenink [Sat, 14 Oct 2017 10:19:33 +0000 (12:19 +0200)] 
doc: Restructure ToC

* All sections up to 2 levels deep are now shown regardless of whether they are a separate page
* Rename Xbits and Thresholding for more consistent naming
* Minor adjustment in the Payload Keywords section

7 years agodoc: Make the header keywords section separate sections in ToC
Ralph Broenink [Sat, 14 Oct 2017 10:15:44 +0000 (12:15 +0200)] 
doc: Make the header keywords section separate sections in ToC

7 years agodoc: Move flowint as integral part of flow keywords
Ralph Broenink [Sat, 14 Oct 2017 10:13:17 +0000 (12:13 +0200)] 
doc: Move flowint as integral part of flow keywords

7 years agodoc: Minor changes in structuring of HTTP Keywords / Snort differences
Ralph Broenink [Sat, 14 Oct 2017 10:09:31 +0000 (12:09 +0200)] 
doc: Minor changes in structuring of HTTP Keywords / Snort differences

7 years agodoc: Move pcre entirely to Payload Keywords section
Ralph Broenink [Sat, 14 Oct 2017 10:06:53 +0000 (12:06 +0200)] 
doc: Move pcre entirely to Payload Keywords section

(plus remove lingering screenshot of a rule)

7 years agodoc: Move fast_pattern and prefilter to dedicated page
Ralph Broenink [Sat, 14 Oct 2017 10:02:55 +0000 (12:02 +0200)] 
doc: Move fast_pattern and prefilter to dedicated page

7 years agodoc: Moved explanation of normalized buffers to rules introduction
Ralph Broenink [Sat, 14 Oct 2017 09:57:00 +0000 (11:57 +0200)] 
doc: Moved explanation of normalized buffers to rules introduction

7 years agodoc: Move the definition of modifier keywords to the introduction
Ralph Broenink [Sat, 14 Oct 2017 09:52:13 +0000 (11:52 +0200)] 
doc: Move the definition of modifier keywords to the introduction

7 years agodoc: Completely rewrite the rules introduction for more clearity
Ralph Broenink [Sat, 14 Oct 2017 09:49:43 +0000 (11:49 +0200)] 
doc: Completely rewrite the rules introduction for more clearity

7 years agodoc: Meta-settings -> Meta Keywords plus some textual changes
Ralph Broenink [Sat, 14 Oct 2017 09:47:38 +0000 (11:47 +0200)] 
doc: Meta-settings -> Meta Keywords plus some textual changes

Most importantly, conventions are now placed in tip boxes

7 years agodoc: Use lowercased keyword names as section titles
Ralph Broenink [Sat, 14 Oct 2017 09:43:58 +0000 (11:43 +0200)] 
doc: Use lowercased keyword names as section titles

7 years agodoc: Replace images of tables and rules with text in rules docs
Ralph Broenink [Sat, 14 Oct 2017 09:37:42 +0000 (11:37 +0200)] 
doc: Replace images of tables and rules with text in rules docs

In some chapters of the rules documentation, many sections used examples of rules, but these were inserted into images. These have been replaced by text and HTML emphasis.

Additionally, some tables embedded into images were also replaced by reST tables.

7 years agodoc: Add suricata.css to allow for some custom styling
Ralph Broenink [Sat, 14 Oct 2017 09:17:19 +0000 (11:17 +0200)] 
doc: Add suricata.css to allow for some custom styling

7 years agodetect/uri: apply urilen contents as depth
Victor Julien [Fri, 24 Nov 2017 14:49:26 +0000 (15:49 +0100)] 
detect/uri: apply urilen contents as depth

7 years agodetect/http_uri: remove broken tests
Victor Julien [Fri, 24 Nov 2017 14:48:26 +0000 (15:48 +0100)] 
detect/http_uri: remove broken tests

7 years agoconf: stack-based buffer-overflow in ParseFilename
Wolfgang Hotwagner [Wed, 6 Dec 2017 11:12:42 +0000 (11:12 +0000)] 
conf: stack-based buffer-overflow in ParseFilename

There is a stack-based buffer-overflow in ParseFilename. Since the length of "outputs.pcap-log.filename" is not checked and the destination buffer "str" has a fixed length of 512 bytes, a buffer overflow happens with long filenames. An attacker could exploit this for code execution if the configuration-file is not protected properly. This commit fixes ticket #2335

This is what the asan-output looks like:

~/suricata-1/src# suricata -T -c ./suricata.yaml
[27871] 3/12/2017 -- 20:48:13 - (suricata.c:1876) <Info> (ParseCommandLine) -- Running suricata under test mode
[27871] 3/12/2017 -- 20:48:13 - (suricata.c:1109) <Notice> (LogVersion) -- This is Suricata version 4.0.0-dev (rev f3fea60b)
=================================================================
==27871==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffbe9d75e0 at pc 0x55897b5f935f bp 0x7fffbe9d72b0 sp 0x7fffbe9d72a8
WRITE of size 1 at 0x7fffbe9d75e0 thread T0 (Suricata-Main)
    0 0x55897b5f935e in ParseFilename /root/suricata-1/src/log-pcap.c:895
    1 0x55897b5fb173 in PcapLogInitCtx /root/suricata-1/src/log-pcap.c:985
    2 0x55897b6af103 in RunModeInitializeOutputs /root/suricata-1/src/runmodes.c:752
    3 0x55897b72c6b5 in PreRunPostPrivsDropInit /root/suricata-1/src/suricata.c:2263
    4 0x55897b730416 in main /root/suricata-1/src/suricata.c:2898
    5 0x7f947f6db2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    6 0x55897b2d4c19 in _start (/usr/local/bin/suricata+0xc4c19)

Address 0x7fffbe9d75e0 is located in stack of thread T0 (Suricata-Main) at offset 672 in frame
    0 0x55897b5f7fcc in ParseFilename /root/suricata-1/src/log-pcap.c:836

  This frame has 3 object(s):
    [32, 104) 'toks'
    [160, 672) 'str' <== Memory access at offset 672 overflows this variable
    [704, 2752) '_sc_log_msg'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /root/suricata-1/src/log-pcap.c:895 in ParseFilename
Shadow bytes around the buggy address:
  0x100077d32e60: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00 00 00
  0x100077d32e70: 00 00 00 00 00 f4 f4 f4 f2 f2 f2 f2 00 00 00 00
  0x100077d32e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100077d32e90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100077d32ea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x100077d32eb0: 00 00 00 00 00 00 00 00 00 00 00 00[f2]f2 f2 f2
  0x100077d32ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100077d32ed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100077d32ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100077d32ef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100077d32f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==27871==ABORTING

7 years agorate_filter by_both through IPPair storage 3056/head
Ruslan Usmanov [Fri, 27 Oct 2017 16:50:32 +0000 (12:50 -0400)] 
rate_filter by_both through IPPair storage

Ticket https://redmine.openinfosecfoundation.org/issues/2127

7 years agoenum: don't printf on util-enum errors 3044/head
Danny Browning [Fri, 1 Dec 2017 18:23:30 +0000 (11:23 -0700)] 
enum: don't printf on util-enum errors

When util-enum encounters an error around enum value it should log the error
rather than losing it to console with printf.

Bug #2268

7 years agodetect/http_host: add sid to nocase warning
Victor Julien [Fri, 1 Dec 2017 22:34:32 +0000 (23:34 +0100)] 
detect/http_host: add sid to nocase warning

7 years agohosts: release packet references to hosts
Victor Julien [Sun, 3 Dec 2017 21:10:37 +0000 (22:10 +0100)] 
hosts: release packet references to hosts

7 years agoAdds options to mark when a file is final. 3037/head
Gaurav Singh [Tue, 17 Oct 2017 01:01:53 +0000 (18:01 -0700)] 
Adds options to mark when a file is final.

This takes the form of an option to add the pid of the process to file
names. Additionally, it adds a suffix to the file name to indicate it is
not finalized.

Adding the pid to the file name reduces the likelihood that a file is
overwritten when suricata is unexpectedly killed. The number in the
waldo file is only written out during a clean shutdown. In the event
of an improper shutdown, extracted files will be written using the old
number and existing files with the same name will be overwritten.

Writes extracted files and their metadata to a temporary file suffixed
with '.tmp'. Renames the files when they are completely done being
written. As-is there is no way to know that a file on disk is still
being written to by suricata.

7 years agodetect/http_start: check if 'line' is valid
Victor Julien [Fri, 1 Dec 2017 08:23:29 +0000 (09:23 +0100)] 
detect/http_start: check if 'line' is valid

In certain conditions like low memory the line can be NULL.

Bug #2307.

7 years agodetect/flowint: harden code 3032/head
Victor Julien [Thu, 30 Nov 2017 07:04:48 +0000 (08:04 +0100)] 
detect/flowint: harden code

Make sure packet has a flow.

Related to bug #2288.

7 years agodetect/flowint: only check if packet has flow
Victor Julien [Thu, 30 Nov 2017 06:53:31 +0000 (07:53 +0100)] 
detect/flowint: only check if packet has flow

Fixed bug #2288.

7 years agodetect/flowint: improve unittests
Victor Julien [Thu, 30 Nov 2017 08:07:40 +0000 (09:07 +0100)] 
detect/flowint: improve unittests

In preparation of fixing bug #2288, make sure the unittests setup
the flow in the packet properly.

7 years agounittest/helpers: add helper to assign flow to packet
Victor Julien [Thu, 30 Nov 2017 08:07:20 +0000 (09:07 +0100)] 
unittest/helpers: add helper to assign flow to packet

7 years agodetect/depth: reject rules with depth smaller than content 3024/head
Victor Julien [Tue, 28 Nov 2017 09:28:07 +0000 (10:28 +0100)] 
detect/depth: reject rules with depth smaller than content

7 years agodetect-parse: string copy not required 3022/head
Jason Ish [Tue, 21 Nov 2017 20:01:21 +0000 (14:01 -0600)] 
detect-parse: string copy not required

Without using pcre, copies of the strings are no longer
required.

7 years agodetect-parse: don't use pcre for rule parsing
Jason Ish [Tue, 13 Sep 2016 17:03:06 +0000 (11:03 -0600)] 
detect-parse: don't use pcre for rule parsing

Don't use pcre for the high level rule parsing, instead
using a tokenizing parser for breaking out the rule
into keywords and options.

Much faster, especially on older CPUs. Should also allow
us to provide better context where a rule parse error
occurs.

7 years agorunmodes: config test is offline
Victor Julien [Mon, 27 Nov 2017 16:36:38 +0000 (17:36 +0100)] 
runmodes: config test is offline

7 years agoafl: enable afl dumps by envvar
Victor Julien [Mon, 27 Nov 2017 14:57:16 +0000 (15:57 +0100)] 
afl: enable afl dumps by envvar

If SC_AFL_DUMP_FILES is set the inputs are stored to disk.

7 years agohttp: allow shinking in HTPRealloc 3017/head
Victor Julien [Mon, 27 Nov 2017 09:03:46 +0000 (10:03 +0100)] 
http: allow shinking in HTPRealloc

7 years agoAdd support for PCAP LINKTYPE_IPV4
Pierre Chifflier [Fri, 24 Nov 2017 07:15:33 +0000 (08:15 +0100)] 
Add support for PCAP LINKTYPE_IPV4

7 years agomingw: service init compile warning fix
Victor Julien [Sun, 26 Nov 2017 20:29:46 +0000 (21:29 +0100)] 
mingw: service init compile warning fix

7 years agooutput: clean up log API unittests
Victor Julien [Sun, 26 Nov 2017 10:36:19 +0000 (11:36 +0100)] 
output: clean up log API unittests

Disable for MinGW as the setenv/getenv implementations seems to
be undeterministic.

7 years agoflow: optimize Flow structure layout
Victor Julien [Sun, 26 Nov 2017 09:30:47 +0000 (10:30 +0100)] 
flow: optimize Flow structure layout

Shrink structure with 8 bytes by moving new ttl fields into an
existing 'gap'.

Also fixes a strange ASAN issue in GCC 5.4.0 in unittests.

7 years agothresholds: simplify config parsing
Victor Julien [Sat, 25 Nov 2017 13:30:58 +0000 (14:30 +0100)] 
thresholds: simplify config parsing

7 years agodetect: make glob.h optional
Victor Julien [Mon, 17 Jul 2017 09:19:20 +0000 (11:19 +0200)] 
detect: make glob.h optional

glob.h is not available on MinGW.

Simply use the input on the rule list as a literal pattern.

7 years agodetect: fix flow bypass flag handling
Victor Julien [Sun, 8 Oct 2017 13:27:00 +0000 (15:27 +0200)] 
detect: fix flow bypass flag handling

7 years agodetect/analyzer: formatting fixup 3013/head
Victor Julien [Fri, 3 Nov 2017 07:05:35 +0000 (08:05 +0100)] 
detect/analyzer: formatting fixup

7 years agodetect: constify rule group lookup
Victor Julien [Mon, 9 Oct 2017 07:06:47 +0000 (09:06 +0200)] 
detect: constify rule group lookup

7 years agodetect: minor profiling cleanup
Victor Julien [Sun, 8 Oct 2017 16:20:18 +0000 (18:20 +0200)] 
detect: minor profiling cleanup

7 years agodetect/mpm: minor cleanup: remove unused function arg
Victor Julien [Fri, 6 Oct 2017 12:07:51 +0000 (14:07 +0200)] 
detect/mpm: minor cleanup: remove unused function arg

7 years agodetect-state: minor cleanups
Victor Julien [Fri, 6 Oct 2017 10:24:15 +0000 (12:24 +0200)] 
detect-state: minor cleanups

7 years agodetect: constify address match functions
Victor Julien [Sat, 7 Oct 2017 10:18:20 +0000 (12:18 +0200)] 
detect: constify address match functions

7 years agodetect: style cleanup
Victor Julien [Wed, 11 Oct 2017 16:14:16 +0000 (18:14 +0200)] 
detect: style cleanup

7 years agoapp-layer: minor cleanup
Victor Julien [Wed, 11 Oct 2017 16:13:58 +0000 (18:13 +0200)] 
app-layer: minor cleanup

7 years agoapp-layer: cleanup: use true bool type for 'logger'
Victor Julien [Thu, 5 Oct 2017 16:50:22 +0000 (18:50 +0200)] 
app-layer: cleanup: use true bool type for 'logger'

7 years agoapp-layer: minor cleanups and optimizations
Victor Julien [Thu, 5 Oct 2017 16:02:58 +0000 (18:02 +0200)] 
app-layer: minor cleanups and optimizations

Use flow protomap instead of dynamically converting the ip proto in
each call.

Use const for vars where possible.

7 years agostream: minor debug addition
Victor Julien [Fri, 13 Oct 2017 09:33:26 +0000 (11:33 +0200)] 
stream: minor debug addition

7 years agodetect: minor cleanups
Victor Julien [Sun, 8 Oct 2017 11:15:12 +0000 (13:15 +0200)] 
detect: minor cleanups

7 years agodetect: minor comment cleanup
Victor Julien [Mon, 23 Oct 2017 09:46:18 +0000 (11:46 +0200)] 
detect: minor comment cleanup

7 years agodetect: run buffer setup callback before validate
Victor Julien [Sun, 5 Nov 2017 21:25:11 +0000 (22:25 +0100)] 
detect: run buffer setup callback before validate

7 years agorust: require at least libc 0.2.33 3009/head
Victor Julien [Wed, 22 Nov 2017 14:40:49 +0000 (15:40 +0100)] 
rust: require at least libc 0.2.33

Required to be higher than 0.2.24 for IPPROTO_UDP. Upgraded to latest
version.

7 years agorust/ntp: convert parser to new registration method
Pierre Chifflier [Thu, 26 Oct 2017 06:05:41 +0000 (08:05 +0200)] 
rust/ntp: convert parser to new registration method

Converting the NTP parser to the new registration method is a simple,
3-steps process:
- change the extern functions to use generic input parameters (functions
  in all parsers must share common types to be generic) and cast them
- declare the Parser structure
- remove the C code and call the registration function

7 years agorust: generate declaration for extern unsafe funcs
Pierre Chifflier [Thu, 26 Oct 2017 06:18:46 +0000 (08:18 +0200)] 
rust: generate declaration for extern unsafe funcs

7 years agorust/applayer: add registration iface for parsers
Pierre Chifflier [Thu, 26 Oct 2017 05:57:03 +0000 (07:57 +0200)] 
rust/applayer: add registration iface for parsers

Add Rust support for the common interface to declare and register all
parsers.

Add a common structure definition to contain all required elements
required for registering a parser, similar to the C interface.
This also reduces the risk of incorrectly registering a parser: the
compiler prevents omitting required functions from the structure, and
functions (even if external) are type-checked. Optional functions are
explicitly marked.

7 years agoapplayer: add registration interface for parsers
Pierre Chifflier [Fri, 27 Oct 2017 11:10:04 +0000 (13:10 +0200)] 
applayer: add registration interface for parsers

Add a common structure definition to contain all required elements
required for registering a parser.
This also reduces the risk of incorrectly registering a parser: the
compiler will type-check functions.

The registration function allows factorization of the code. It can be
used to register parsers, but is not mandatory.

If extra registration code (for functions not in the structure)
it is still possible by calling the C functions after the registration.

7 years agoapplayer: add StringToAppProto
Pierre Chifflier [Thu, 26 Oct 2017 05:53:12 +0000 (07:53 +0200)] 
applayer: add StringToAppProto

Add StringToAppProto to map a protocol name to a AppProto.

Exposing this function is required to let parsers discover their
AppProto identifier constant dynamically.
For example, a parser can request this value, and use it for
registration without knowing the value.