]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agoscan-build: fix memleak warning in port parsing
Victor Julien [Thu, 21 Dec 2017 11:07:46 +0000 (12:07 +0100)] 
scan-build: fix memleak warning in port parsing

7 years agodetect/tos: fix memleak in error path
Victor Julien [Thu, 21 Dec 2017 11:00:28 +0000 (12:00 +0100)] 
detect/tos: fix memleak in error path

7 years agoscan-build: fix warning in radix tree
Victor Julien [Thu, 21 Dec 2017 10:00:28 +0000 (11:00 +0100)] 
scan-build: fix warning in radix tree

7 years agoeve.flow: remove "hi" log message
Jason Ish [Tue, 19 Dec 2017 21:44:17 +0000 (15:44 -0600)] 
eve.flow: remove "hi" log message

7 years agoeve.netflow: remove "hi" log message
Jason Ish [Tue, 19 Dec 2017 21:43:50 +0000 (15:43 -0600)] 
eve.netflow: remove "hi" log message

7 years agodecode/vlan: don't consider ARP 'unknown'
Victor Julien [Wed, 20 Dec 2017 08:30:42 +0000 (09:30 +0100)] 
decode/vlan: don't consider ARP 'unknown'

7 years agopfring: add warning for stripped vlan header case
Victor Julien [Wed, 20 Dec 2017 07:57:29 +0000 (08:57 +0100)] 
pfring: add warning for stripped vlan header case

According to PF_RING upstream the vlan header should never be stripped
from the packet PF_RING feeds to Suricata. But upstream also indicated
keeping the check would be a good "safety check".

So in addition to the check, add a warning that warns once (per thread
for implementation simplicity) if the vlan hdr does appear to be stripped
after all.

7 years agopfring: fix vlan handling issues
Victor Julien [Tue, 19 Dec 2017 19:17:39 +0000 (20:17 +0100)] 
pfring: fix vlan handling issues

When Suricata was monitoring traffic with a single vlan layer, the stats
and output instead showed 2. This was caused by the raw packets PF_RING
feeds Suricata would hold the vlan header, but the code assumed that
the header was stripped and the vlan_id passed to Suricata through
PF_RING's extended_hdr.parsed_pkt.

This patch adds the following logic: Check vlan id from the parser packet
PF_RING prepared. PF_RING sets the vlan_id based on its own parsing or
based on the hardware offload. It gives no indication on where the vlan_id
came from, so we rely on the vlan_offset field. If it's 0, we assume the
PF_RING parser did not see the vlan header and got it from the hardware
offload. In this case we will use this information directly, as we won't
get a raw vlan header later. If PF_RING did set the offset, we do the
parsing in the Suricata decoder so that we have full control.

PF_RING *should* put back the vlan header in all cases, and also set the
vlan_offset field, but as a extra precaution keep the check described
above.

Bug #2355.

7 years agoHash table: free bucker in case of insertion error
Pierre Chifflier [Mon, 17 Mar 2014 17:59:35 +0000 (18:59 +0100)] 
Hash table: free bucker in case of insertion error

This fixes a warning raised by cppcheck.

7 years agoHash table: check hash array size when inserting element
Pierre Chifflier [Fri, 14 Mar 2014 17:59:11 +0000 (18:59 +0100)] 
Hash table: check hash array size when inserting element

If the hash function returns an index greater than the array size of the
hash table, the index is not checked. Even if this is the responsibility
of the caller, add a safety check to avoid errors.

7 years agodns-log: don't register if HAVE_RUST
Jason Ish [Mon, 18 Dec 2017 12:58:18 +0000 (06:58 -0600)] 
dns-log: don't register if HAVE_RUST

Log just one notice message when attempting to register
this logger with HAVE_RUST, instead of logging on
every attempt to output a DNS record.

Issue:
https://redmine.openinfosecfoundation.org/issues/2365

7 years agorust/dns - convert more type values to text
Jason Ish [Mon, 18 Dec 2017 12:46:17 +0000 (06:46 -0600)] 
rust/dns - convert more type values to text

Issue:
https://redmine.openinfosecfoundation.org/issues/2364

Convert more record type and errr code values to text.
Remove duplicate type declarations.

7 years agodetect-engine: add missing mutex unlock
Andreas Herz [Thu, 14 Dec 2017 00:10:33 +0000 (01:10 +0100)] 
detect-engine: add missing mutex unlock

7 years agorule-reload: fix possible hangup with SIGUSR2
Andreas Herz [Wed, 13 Dec 2017 23:59:30 +0000 (00:59 +0100)] 
rule-reload: fix possible hangup with SIGUSR2

In some cases the rule reload could hang. The pending USR2 signals will
be recognized even with the <2 check. Also the SCLogWarning shouldn't be
used in the handler (see Warning about SCLog* API above in the code).

7 years agodoc: initial suricata-update page
Victor Julien [Wed, 6 Dec 2017 21:54:31 +0000 (22:54 +0100)] 
doc: initial suricata-update page

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 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 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 agoConf: Multipe NULL-pointer dereferences in PostConfLoadedSetup
Wolfgang Hotwagner [Mon, 18 Dec 2017 14:49:38 +0000 (14:49 +0000)] 
Conf: Multipe NULL-pointer dereferences in PostConfLoadedSetup

Multiple NULL-pointer dereferences after ConfGet in PostConfLoadedSetup can cause suricata to terminate with segfaults. The ASAN-output:

ASAN:DEADLYSIGNAL =================================================================
5734ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f1a9a3967cc bp 0x7ffdff033ad0 sp 0x7ffdff033250 T0)
 0 0x7f1a9a3967cb (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x447cb)
 1 0x55ba65f66f27 in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2652
 2 0x55ba65f6870e in main /root/suricata-1/src/suricata.c:2898
 3 0x7f1a96aeb2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
 4 0x55ba65af9039 in _start (/usr/local/bin/suricata+0xc8039)

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

This commit fixes Bug #2370 by replacing ConfGet by ConfGetValue

7 years agoConf: Multipe NULL-pointer dereferences after ConfGetBool in StreamTcpInitConfig
Wolfgang Hotwagner [Sun, 17 Dec 2017 22:15:27 +0000 (22:15 +0000)] 
Conf: Multipe NULL-pointer dereferences after ConfGetBool in StreamTcpInitConfig

There are multiple NULL-pointer dereferences after calling ConfGetBool in StreamTcpInitConfig. ConfGetBool calls ConfGet which doesn't check the vptr-argument. This is a sample ASAN-output:

1453ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f2969b83a28 bp 0x7ffdbf613a90 sp 0x7ffdbf613210 T0)
 0 0x7f2969b83a27 in strcasecmp (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x51a27)
 1 0x564185accefd in ConfValIsTrue /root/suricata-1/src/conf.c:559
 2 0x564185accb4f in ConfGetBool /root/suricata-1/src/conf.c:512
 3 0x564185dcbe05 in StreamTcpInitConfig /root/suricata-1/src/stream-tcp.c:381
 4 0x564185e21a88 in PreRunInit /root/suricata-1/src/suricata.c:2264
 5 0x564185e24d2c in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2763
 6 0x564185e2570e in main /root/suricata-1/src/suricata.c:2898
 7 0x7f29662cb2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
 8 0x5641859b6039 in _start (/usr/local/bin/suricata+0xc8039)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x51a27) in strcasecmp
1453ABORTING

This commit replaces ConfGet by ConfGetValue in ConfGetBool. This does not only fix Bug #2368 but might also fix others too.

7 years agoConf: Multipe NULL-pointer dereferences in HostInitConfig
Wolfgang Hotwagner [Sun, 17 Dec 2017 21:54:15 +0000 (21:54 +0000)] 
Conf: Multipe NULL-pointer dereferences in HostInitConfig

Multiple NULL-pointer dereferences after ConfGet in HostInitConfig can cause suricata to terminate with segfaults. The ASAN-output:

==29747==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7ff937904646 bp
    0 0x7ff937904645 in strlen (/lib/x86_64-linux-gnu/libc.so.6+0x80645)
    1 0x7ff93b146eec  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x3beec)
    2 0x5618387c86a3 in HostInitConfig /root/suricata-1/src/host.c:174
    3 0x56183893eccb in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2752
    4 0x56183893f70e in main /root/suricata-1/src/suricata.c:2898
    5 0x7ff9378a42b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    6 0x5618384d0039 in _start (/usr/local/bin/suricata+0xc8039)

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

This commit fixes Bug #2367

7 years agoconf: multiple NULL-pointer dereferences in StreamTcpInitConfig
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 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 agochangelog: update for 4.0.3 suricata-4.0.3
Victor Julien [Wed, 6 Dec 2017 12:23:56 +0000 (13:23 +0100)] 
changelog: update for 4.0.3

7 years agochangelog: update for 4.0.2 suricata-4.0.2
Victor Julien [Wed, 6 Dec 2017 08:07:10 +0000 (09:07 +0100)] 
changelog: update for 4.0.2

7 years agodetect/http_host: add sid to nocase warning 3043/head
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 agodetect/http_start: check if 'line' is valid 3038/head
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
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 3029/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 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 agohttp: allow shinking in HTPRealloc
Victor Julien [Mon, 27 Nov 2017 09:03:46 +0000 (10:03 +0100)] 
http: allow shinking in HTPRealloc

7 years agounix socket: don't loose events when offline 3001/head
Danny Browning [Mon, 6 Nov 2017 23:10:02 +0000 (16:10 -0700)] 
unix socket: don't loose events when offline

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

Fixes issue with events being dropped since socket was non-blocking for
offline run modes.

Add a method for determining offline from run mode. Make sure SCInstance
offline is set correctly. Use current run mode to set socket flags.

7 years agosyslog: treat SC_LOG_PERF messages as LOG_DEBUG
Alexander Gozman [Thu, 9 Nov 2017 11:55:47 +0000 (11:55 +0000)] 
syslog: treat SC_LOG_PERF messages as LOG_DEBUG

SCLogMapLogLevelToSyslogLevel(): treat SC_LOG_PERF messages as LOG_DEBUG

Previously, when logging to syslog, perf events had a default EMERG priority,
which could be a bit confusing.

7 years agoconf: fix NULL-pointer dereference in CoredumpLoadConfig
Wolfgang Hotwagner [Sun, 19 Nov 2017 14:05:04 +0000 (14:05 +0000)] 
conf: fix NULL-pointer dereference in CoredumpLoadConfig

An empty value for coredump.max-dump in the config-file leads to a segfault because of a NULL-pointer dereference in CoredumpLoadConfig().

Here is a configuration example:

coredump.max-dump: []

This lets suricata crash with a segfault:

ASAN-output:
==9412==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f22e851aa28 bp 0x7ffd90006fc0 sp 0x7ffd90006740 T0)
    0 0x7f22e851aa27 in strcasecmp (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x51a27)
    1 0x5608a7ec0108 in CoredumpLoadConfig /root/suricata-1/src/util-coredump-config.c:52
    2 0x5608a7e8bb22 in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2752
    3 0x5608a7e8c577 in main /root/suricata-1/src/suricata.c:2892
    4 0x7f22e4c622b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    5 0x5608a7a30c59 in _start (/usr/local/bin/suricata+0xc4c59)

Bug #2276

7 years agoconf: fix NULL-pointer dereference in ConfGetInt
Wolfgang Hotwagner [Fri, 17 Nov 2017 23:25:08 +0000 (23:25 +0000)] 
conf: fix NULL-pointer dereference in ConfGetInt

If there are empty values in the config-file where integer values are expected, strtoimax in the ConfGetInt-function will segfault because of NULL-pointer dereference.

Here is a configuration example:

pcre.match-limit: []

This will let suricata crash with a segfault.
ASAN-output:

ASAN:DEADLYSIGNAL =================================================================
16951ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fa690e3ccc5 bp 0x000000000000 sp 0x7ffd0d770ad0 T0)
0 0x7fa690e3ccc4 (/lib/x86_64-linux-gnu/libc.so.6+0x36cc4)
1 0x7fa6946a6534 in strtoimax (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x44534)
2 0x55e0aeba6499 in ConfGetInt /root/suricata-1/src/conf.c:390
3 0x55e0aed2545d in DetectPcreRegister /root/suricata-1/src/detect-pcre.c:99
4 0x55e0aec1b4ce in SigTableSetup /root/suricata-1/src/detect.c:3783
5 0x55e0aeeed58d in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2690
6 0x55e0aeeee4f2 in main /root/suricata-1/src/suricata.c:2892
7 0x7fa690e262b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
8 0x55e0aea92d39 in _start (/usr/local/bin/suricata+0xc7d39)

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

This commit fixes Ticket #2275

7 years agoconf: fix NULL-pointer dereference in ParseSizeString
Wolfgang Hotwagner [Fri, 17 Nov 2017 17:47:41 +0000 (17:47 +0000)] 
conf: fix NULL-pointer dereference in ParseSizeString

If someone accidently writes invalid characters in some parts of the suricata.yaml-configfile, the size-parameter of the ParseSizeString-function becomes NULL and gets dereferenced. Suricata crashes with SEGV. This commit fixes Ticket #2274

The following config value leads to a Segfault:
app-layer.protocols.smtp.inspected-tracker.content-inspect-window: *4096

7 years agoupdated links to suricata.readthedocs.io
jason taylor [Thu, 2 Nov 2017 12:33:54 +0000 (08:33 -0400)] 
updated links to suricata.readthedocs.io

Signed-off-by: jason taylor <jtfas90@gmail.com>
7 years agodetect/dns: fix misdetection on dns_query on udp 2982/head
Victor Julien [Tue, 7 Nov 2017 16:18:30 +0000 (17:18 +0100)] 
detect/dns: fix misdetection on dns_query on udp

If 'raw' content patterns were used in a dns_query rule, the raw
patterns would only be evaluated for TCP, but not for UDP.

This patch adds the inspection for UDP as well.

Bug #2263.

7 years agovalgrind: suppressions for NIC offloading calls 2969/head
Peter Manev [Wed, 1 Nov 2017 12:19:21 +0000 (13:19 +0100)] 
valgrind: suppressions for NIC offloading calls

7 years agodetect/profile: minor fixes
Victor Julien [Wed, 1 Nov 2017 09:16:15 +0000 (10:16 +0100)] 
detect/profile: minor fixes

7 years agoinstall: use up to date url for 'make install-full'
Victor Julien [Sun, 29 Oct 2017 07:38:43 +0000 (08:38 +0100)] 
install: use up to date url for 'make install-full'

7 years agotravis: allow rust-stable build to fail 2952/head
Jason Ish [Tue, 24 Oct 2017 22:34:00 +0000 (16:34 -0600)] 
travis: allow rust-stable build to fail

7 years agotravis: rust 1.21.0 build
Jason Ish [Tue, 24 Oct 2017 14:25:59 +0000 (08:25 -0600)] 
travis: rust 1.21.0 build

7 years agotravis: do make distcheck on Rust 1.15.0 build
Jason Ish [Tue, 24 Oct 2017 12:52:25 +0000 (06:52 -0600)] 
travis: do make distcheck on Rust 1.15.0 build

7 years agodetect: don't register http_*_line twice
Victor Julien [Tue, 24 Oct 2017 06:56:48 +0000 (08:56 +0200)] 
detect: don't register http_*_line twice

7 years agodetect: test for byte_extract/isdataat large values
Victor Julien [Sat, 21 Oct 2017 08:17:07 +0000 (10:17 +0200)] 
detect: test for byte_extract/isdataat large values

7 years agodetect: handle very large byte_extract'ed values in isdataat
Victor Julien [Sat, 21 Oct 2017 08:16:30 +0000 (10:16 +0200)] 
detect: handle very large byte_extract'ed values in isdataat

7 years agodetect: add unittest for byte_extract/isdataat
Victor Julien [Sat, 21 Oct 2017 08:01:20 +0000 (10:01 +0200)] 
detect: add unittest for byte_extract/isdataat

7 years agodetect: implement byte_extract support for isdataat
Victor Julien [Sat, 21 Oct 2017 08:00:47 +0000 (10:00 +0200)] 
detect: implement byte_extract support for isdataat

7 years agodetect: add debug statements for byte_extract/isdataat
Victor Julien [Sat, 21 Oct 2017 08:00:08 +0000 (10:00 +0200)] 
detect: add debug statements for byte_extract/isdataat

7 years agodetect-asn1: fix memory leak in error path
Victor Julien [Fri, 20 Oct 2017 08:04:25 +0000 (10:04 +0200)] 
detect-asn1: fix memory leak in error path

7 years agodetect: fix port parsing memory leak
Victor Julien [Fri, 20 Oct 2017 07:50:59 +0000 (09:50 +0200)] 
detect: fix port parsing memory leak

Leak in error path as seen by scan-build:

  CC       detect-engine-port.o
detect-engine-port.c:1083:13: warning: Potential leak of memory pointed to by 'temp_rule_var_port'
    return -1;
            ^

7 years agodetect-id: clean up to suppress minor coverity warning
Victor Julien [Fri, 20 Oct 2017 07:24:23 +0000 (09:24 +0200)] 
detect-id: clean up to suppress minor coverity warning

7 years agoredis: suppress minor coverity warning
Victor Julien [Fri, 20 Oct 2017 07:17:30 +0000 (09:17 +0200)] 
redis: suppress minor coverity warning

7 years agodecoder: implement IEEE802.1AH
Victor Julien [Thu, 19 Oct 2017 11:47:35 +0000 (13:47 +0200)] 
decoder: implement IEEE802.1AH

7 years agorandom: fix random logic with getrandom
Victor Julien [Tue, 24 Oct 2017 10:04:43 +0000 (12:04 +0200)] 
random: fix random logic with getrandom

The older random functions returned random values in the range of
0 - RAND_MAX. This is what the http randomize code was expecting.

Newer methods, based on getrandom (or probably Windows too), return
a much large range of values, including negative values and >RAND_MAX.

This patch adds a wrapper to turn the returned value into the expected
range before using it in the http code.

The same is true for the stream engine.

7 years agorandom: support getrandom(2) if available 2944/head
Victor Julien [Thu, 19 Oct 2017 07:51:18 +0000 (09:51 +0200)] 
random: support getrandom(2) if available

Ticket: #2193

7 years agonapatech: fix minor memleak in error path
Victor Julien [Thu, 19 Oct 2017 07:03:13 +0000 (09:03 +0200)] 
napatech: fix minor memleak in error path

7 years agoyaml: print errors if integers are invalid
Victor Julien [Thu, 19 Oct 2017 06:59:36 +0000 (08:59 +0200)] 
yaml: print errors if integers are invalid

7 years agodetect: error out on invalid detect.profile option
Victor Julien [Thu, 19 Oct 2017 06:41:09 +0000 (08:41 +0200)] 
detect: error out on invalid detect.profile option

Bug #891.

7 years agoyaml: add 'append' to stats-log entry
Victor Julien [Thu, 19 Oct 2017 06:24:47 +0000 (08:24 +0200)] 
yaml: add 'append' to stats-log entry

Bug #798

7 years agochangelog: update for 4.0.1 release suricata-4.0.1
Victor Julien [Wed, 18 Oct 2017 08:33:47 +0000 (10:33 +0200)] 
changelog: update for 4.0.1 release

7 years agoautotools: fix distcheck with rust enabled
Jason Ish [Wed, 18 Oct 2017 12:53:03 +0000 (14:53 +0200)] 
autotools: fix distcheck with rust enabled

7 years agostats: use unshortened interface names in counters 2941/head
Sascha Steinbiss [Sat, 16 Sep 2017 06:29:35 +0000 (07:29 +0100)] 
stats: use unshortened interface names in counters

7 years agojson: skip over double dots in output tokenizing
Sascha Steinbiss [Fri, 1 Sep 2017 14:24:56 +0000 (16:24 +0200)] 
json: skip over double dots in output tokenizing

Interface name shortening introduces double periods ('..') as spacers,
which cause issues during JSON stats serialization as there '.'
characters are also used as separators to define nesting of the JSON
output. This commit makes sure that '..' are skipped during tokenizing.
Fixes Redmine bug #2208.

7 years agorust/file: improve truncation handling 2940/head
Victor Julien [Mon, 2 Oct 2017 16:34:08 +0000 (18:34 +0200)] 
rust/file: improve truncation handling

7 years agodetect/state: fix offset mask logic
qiangbei [Sun, 8 Oct 2017 12:49:05 +0000 (20:49 +0800)] 
detect/state: fix offset mask logic

changed 0xef to 0x7f

7 years agorunmodes: fix 'threads' option parsing
Victor Julien [Fri, 13 Oct 2017 07:22:49 +0000 (09:22 +0200)] 
runmodes: fix 'threads' option parsing

Don't cast int to uint8_t for no reason. Add warning that upper
limit for threads is 1024.

Small code cleanups.

Bug: #2228

7 years agooutput: harden output deinit
Victor Julien [Sun, 15 Oct 2017 19:25:07 +0000 (21:25 +0200)] 
output: harden output deinit

If thread setup fails allow output deinit code to be called with
NULL data without crashing.

7 years agostream: improve error handling of ssn/segment pools
Victor Julien [Fri, 13 Oct 2017 07:05:02 +0000 (09:05 +0200)] 
stream: improve error handling of ssn/segment pools

With large number of threads the default memcaps lead to pool setup
failures. Make sure these are reported properly so that the user
knows what is going on.

Bug: #2226

7 years agorust/dns: fix new warning in rustc 1.21 2937/head
Victor Julien [Sun, 15 Oct 2017 19:18:22 +0000 (21:18 +0200)] 
rust/dns: fix new warning in rustc 1.21

7 years agorust/nfs: fix new warnings in rustc 1.21
Victor Julien [Sun, 15 Oct 2017 19:16:56 +0000 (21:16 +0200)] 
rust/nfs: fix new warnings in rustc 1.21

7 years agodoc/file_data: add note on negated matching 2925/head
Victor Julien [Thu, 5 Oct 2017 09:11:13 +0000 (11:11 +0200)] 
doc/file_data: add note on negated matching

Explain issue #2216 and how to avoid it.

7 years agodoc/napatech: formatting fixes
Victor Julien [Thu, 5 Oct 2017 09:11:00 +0000 (11:11 +0200)] 
doc/napatech: formatting fixes

7 years agoprofiling: fix app-layer profiling and csv output 2924/head
Victor Julien [Sun, 24 Sep 2017 11:55:34 +0000 (13:55 +0200)] 
profiling: fix app-layer profiling and csv output

7 years agodebug: free pcre memory used for output filtering
Victor Julien [Tue, 3 Oct 2017 08:31:39 +0000 (10:31 +0200)] 
debug: free pcre memory used for output filtering

7 years agotls: don't set event on small input data
Victor Julien [Fri, 29 Sep 2017 17:10:46 +0000 (19:10 +0200)] 
tls: don't set event on small input data

On very small data the max loop count could be 0. Make sure
it's always at least 1.

7 years agoprscript: update urls to use OISF repo
Eric Leblond [Sat, 30 Sep 2017 10:35:14 +0000 (12:35 +0200)] 
prscript: update urls to use OISF repo

7 years agotravis: hook check-setup.sh into the build 2923/head
Jason Ish [Sun, 1 Oct 2017 10:28:47 +0000 (11:28 +0100)] 
travis: hook check-setup.sh into the build

Only do it for one build, for now use the one that also
enables Rust.

7 years agotemplate: script to check the setup scripts
Jason Ish [Sun, 1 Oct 2017 10:28:07 +0000 (11:28 +0100)] 
template: script to check the setup scripts

This script applies the setup scripts one by one followed
by a make distcheck.

7 years agotemplate scripts: allow to be called from top or src
Jason Ish [Sun, 1 Oct 2017 09:41:29 +0000 (10:41 +0100)] 
template scripts: allow to be called from top or src

Allow the template setup script to be called from the top source
directory or from ./src to unify where they can be executed
from.

7 years agotemplates: rename scripts to use - instead of _
Jason Ish [Sun, 1 Oct 2017 08:54:13 +0000 (09:54 +0100)] 
templates: rename scripts to use - instead of _

Use "-" consistently instead of a mix of - and _.

setup_decoder.sh -> setup-decoder.sh
setup_simple_detect.sh -> setup-simple-detect.sh

7 years agogithub: codeowners syntax fixes 2917/head
Victor Julien [Sat, 30 Sep 2017 14:50:47 +0000 (16:50 +0200)] 
github: codeowners syntax fixes

7 years agogithub: add codeowners file 2912/head
Victor Julien [Sat, 30 Sep 2017 11:13:58 +0000 (13:13 +0200)] 
github: add codeowners file

Initial version.

See https://help.github.com/articles/about-codeowners/

7 years agotemplate: fix decoder setup script 2900/head
Victor Julien [Wed, 6 Sep 2017 12:56:06 +0000 (14:56 +0200)] 
template: fix decoder setup script

7 years agotemplate: fix setup detect script
Victor Julien [Mon, 4 Sep 2017 19:03:56 +0000 (21:03 +0200)] 
template: fix setup detect script

7 years agotemplate: minor updates
Victor Julien [Mon, 4 Sep 2017 12:54:24 +0000 (14:54 +0200)] 
template: minor updates

Merge inspect engine into keyword

7 years agodns: fix last timestamp handling
Derek [Thu, 7 Sep 2017 03:23:25 +0000 (20:23 -0700)] 
dns: fix last timestamp handling

Fixes incorrect variable in ticket #2207

In app-layer-dns-tcp.c in the DNSTCPResponseParse function
a variable is set to last_req when it should be last_resp.
This makes it consistent with UDP DNS response parsing.

7 years agoaf-packet: free bpf program
Eric Leblond [Mon, 18 Sep 2017 18:30:20 +0000 (20:30 +0200)] 
af-packet: free bpf program

This fixes a small memory leak when Suricata is running with a
BPF filter.

7 years agoaf-packet: call thread deinit function
Eric Leblond [Mon, 18 Sep 2017 18:24:29 +0000 (20:24 +0200)] 
af-packet: call thread deinit function

7 years agoprscript: update docker code
Eric Leblond [Sat, 9 Sep 2017 09:13:29 +0000 (11:13 +0200)] 
prscript: update docker code

Update docker code to latest docker python API. This patch
preserves backwrd compatibility with older versions.

7 years agodoc: reflect most recent cpu affinity settings 2890/head
Andreas Herz [Sat, 9 Sep 2017 21:22:06 +0000 (23:22 +0200)] 
doc: reflect most recent cpu affinity settings

Some settings like output-cpu-set never been used and detect got renamed
to worker. This reflects those changes already present in the yaml also
within the documentation.