]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agowirefuzz: add 'quiet' mode 3373/head
Victor Julien [Wed, 2 May 2018 07:00:35 +0000 (09:00 +0200)] 
wirefuzz: add 'quiet' mode

Adds -q commandline option to force quiet operation.

7 years agohtp: cleanup and fix test
Victor Julien [Mon, 23 Apr 2018 10:33:02 +0000 (12:33 +0200)] 
htp: cleanup and fix test

7 years agohttp: add tests for header folding
Victor Julien [Thu, 19 Apr 2018 14:31:43 +0000 (16:31 +0200)] 
http: add tests for header folding

To test for https://github.com/OISF/libhtp/issues/159

7 years agohttp: clean up unittest
Victor Julien [Thu, 19 Apr 2018 13:34:51 +0000 (15:34 +0200)] 
http: clean up unittest

7 years agopcap-log: don't divide by 0 on no traffic
Victor Julien [Mon, 7 May 2018 14:20:45 +0000 (16:20 +0200)] 
pcap-log: don't divide by 0 on no traffic

7 years agooutput: fix logging wrong direction in tls upgrade 3353/head
Victor Julien [Fri, 2 Mar 2018 12:44:43 +0000 (13:44 +0100)] 
output: fix logging wrong direction in tls upgrade

When upgrading to TLS from HTTP logging of the final HTTP tx could
have the wrong direction. This was due to the original packet triggering/
finalizing the upgrade would be used as the base for both the toserver
and toclient pseudo packet meaning it was wrong in one direction.

This patch creates a pseudo packet in the same way as the flow timeout
code does, so it no longer takes the raw original packet in.

Bug #2430

7 years agochangelog: update for 4.0.4 suricata-4.0.4
Victor Julien [Tue, 13 Feb 2018 14:05:56 +0000 (15:05 +0100)] 
changelog: update for 4.0.4

7 years agorust/nfs: fix memory leak
Victor Julien [Tue, 13 Feb 2018 13:04:04 +0000 (14:04 +0100)] 
rust/nfs: fix memory leak

7 years agoautogen/rust: remove Cargo.lock
Victor Julien [Tue, 30 Jan 2018 11:20:42 +0000 (12:20 +0100)] 
autogen/rust: remove Cargo.lock

Remove Cargo.lock to avoid issues when updating Cargo.toml

7 years agodoc: fix http_header_names example
Victor Julien [Tue, 13 Feb 2018 10:41:33 +0000 (11:41 +0100)] 
doc: fix http_header_names example

7 years agoconf/yaml: don't allow empty key values
Jason Ish [Wed, 7 Feb 2018 21:11:54 +0000 (15:11 -0600)] 
conf/yaml: don't allow empty key values

When loading an empty file, libyaml will fire a single scalar
event causing us to create a key that contains an empty string.
We're not interested in this, so skip an empty scalar value
when expecting a key.

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/2418

7 years agorust/dns: fix overflow of event counter
Jason Ish [Mon, 12 Feb 2018 20:47:14 +0000 (14:47 -0600)] 
rust/dns: fix overflow of event counter

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

Rust will panic if this value is incremented over the max
value for a u16. Instead, use a bool as the Rust DNS code
was never decrementing this counter, effectively using
it as a bool.

7 years agodnp3: regenerate object decoding code
Jason Ish [Fri, 26 Jan 2018 22:15:09 +0000 (16:15 -0600)] 
dnp3: regenerate object decoding code

7 years agodnp3-gen: require jinja2 v2.10 or later
Jason Ish [Fri, 26 Jan 2018 22:14:11 +0000 (16:14 -0600)] 
dnp3-gen: require jinja2 v2.10 or later

Previous versions, but not all, have issues tracking
variables.

7 years agodnp3-gen: fix heap buffer overflow in generated code
Philippe Antoine [Fri, 26 Jan 2018 22:09:18 +0000 (16:09 -0600)] 
dnp3-gen: fix heap buffer overflow in generated code

Due to missing check before memcpy.

7 years agoder: fix recursion depth not being handled correctly
Victor Julien [Fri, 2 Feb 2018 10:17:23 +0000 (11:17 +0100)] 
der: fix recursion depth not being handled correctly

In a mix of sequences the 'depth reached' error would not
be fully propagated.

Found with AFL.

7 years agoder: warn if null passed to decoders
Victor Julien [Fri, 2 Feb 2018 10:56:16 +0000 (11:56 +0100)] 
der: warn if null passed to decoders

Remove null checks for errcode.

7 years agodetect: fix out of bounds write in thread space creation
Victor Julien [Tue, 13 Feb 2018 10:22:33 +0000 (11:22 +0100)] 
detect: fix out of bounds write in thread space creation

7 years agothresholds: fix issues with host based thresholds 3233/head
Victor Julien [Tue, 16 Jan 2018 10:54:39 +0000 (11:54 +0100)] 
thresholds: fix issues with host based thresholds

The flow manager thread (that also runs the host cleanup code) would
sometimes free a host before it's thresholds are timed out. This would
lead to misdetection or too many alerts.

This was mostly (only?) visible on slower systems. And was caused by a
mismatch between time concepts of the async flow manager thread and the
packet threads, resulting in the flow manager using a timestamp that
was before the threshold entry creation ts. This would lead to an
integer underflow in the timeout check, leading to a incorrect conclusion
that the threshold entry was timed out.

To address this,  check if the 'check' timestamp is not before the creation
timestamp.

7 years agostream: set event for suspected data injection during 3whs
Victor Julien [Wed, 24 Jan 2018 15:37:27 +0000 (16:37 +0100)] 
stream: set event for suspected data injection during 3whs

This rule will match on the STREAM_3WHS_ACK_DATA_INJECT, that is
set if we're:
- in IPS mode
- get a data packet from the server
- that matches the exact SEQ/ACK expectations for the 3whs

The action of the rule is set to drop as the stream engine will drop.
So the rule action is actually not needed, but for consistency it
is drop.

7 years agostream: handle data on incomplete 3whs
Victor Julien [Wed, 24 Jan 2018 14:59:57 +0000 (15:59 +0100)] 
stream: handle data on incomplete 3whs

If we have only seen the SYN and SYN/ACK of the 3whs, accept from
server data if it perfectly matches the SEQ/ACK expectations. This
might happen in 2 scenarios:

1. packet loss: if we lost the final ACK, we may get data that fits
   this pattern (e.g. a SMTP EHLO message).

2. MOTS/MITM packet injection: an attacker can send a data packet
   together with its SYN/ACK packet. The client due to timing almost
   certainly gets the SYN/ACK before considering the data packet,
   and will respond with the final ACK before processing the data
   packet.

In IDS mode we will accept the data packet and rely on the reassembly
engine to warn us if the packet was indeed injected.

In IPS mode we will drop the packet. In the packet loss case we will
rely on retransmissions to get the session back up and running. For
the injection case we blocked this injection attempt.

7 years agostream: still inspect packets dropped by stream
Victor Julien [Wed, 24 Jan 2018 14:59:14 +0000 (15:59 +0100)] 
stream: still inspect packets dropped by stream

The detect engine would bypass packets that are set as dropped. This
seems sane, as these packets are going to be dropped anyway.

However, it lead to the following corner case: stream events that
triggered the drop could not be matched on the rules. The packet
with the event wouldn't make it to the detect engine due to the bypass.

This patch changes the logic to not bypass DROP packets anymore.
Packets that are dropped by the stream engine will set the no payload
inspection flag, so avoid needless cost.

7 years agonfs: remove old test code
Victor Julien [Tue, 6 Feb 2018 09:35:05 +0000 (10:35 +0100)] 
nfs: remove old test code

7 years agopcre: don't leak memory in data extraction
Victor Julien [Mon, 29 Jan 2018 10:26:01 +0000 (11:26 +0100)] 
pcre: don't leak memory in data extraction

7 years agorust/nfs: explicitly handle GAPs from C
Victor Julien [Thu, 25 Jan 2018 16:55:17 +0000 (17:55 +0100)] 
rust/nfs: explicitly handle GAPs from C

It seems that Rust optimizes this code in such a way that it
passes the null ptr along as real data.

    if buf.as_ptr().is_null() && input_len > 0 {

7 years agorust/filetracker: if file API return error, trunc file
Victor Julien [Thu, 25 Jan 2018 14:31:35 +0000 (15:31 +0100)] 
rust/filetracker: if file API return error, trunc file

7 years agorust/nfs: fix read reply handling
Victor Julien [Thu, 25 Jan 2018 13:56:05 +0000 (14:56 +0100)] 
rust/nfs: fix read reply handling

READ replies with large data chunks are processed partially to avoid
queuing too much data. When the final chunk was received however, the
start of the chunk would already tag the transaction as 'done'. The
more aggressive tx freeing that was recently merged would cause this
tx to be freed before the rest of the in-progress chunk was done.

This patch delays the tagging of the tx until the final data has been
received.

7 years agofile: minor cleanups
Victor Julien [Thu, 25 Jan 2018 10:02:33 +0000 (11:02 +0100)] 
file: minor cleanups

7 years agofile: use enum for state
Victor Julien [Thu, 25 Jan 2018 09:32:13 +0000 (10:32 +0100)] 
file: use enum for state

Makes debugging easier.

7 years agorust/file: handle file open errors
Victor Julien [Thu, 25 Jan 2018 09:05:55 +0000 (10:05 +0100)] 
rust/file: handle file open errors

7 years agorust/file: change return type for FileOpenFileWithId
Victor Julien [Thu, 25 Jan 2018 08:56:37 +0000 (09:56 +0100)] 
rust/file: change return type for FileOpenFileWithId

Make it int so we can easily check it in Rust. No consumer used the
File pointer that was returned before anyway.

7 years agorust/core: comment cleanup
Victor Julien [Thu, 25 Jan 2018 08:47:02 +0000 (09:47 +0100)] 
rust/core: comment cleanup

7 years agorust: don't gen C headers if Rust isn't enabled
Victor Julien [Mon, 29 Jan 2018 13:16:01 +0000 (14:16 +0100)] 
rust: don't gen C headers if Rust isn't enabled

7 years agoapp-layer-htp, stream-tcp: prevent modulo bias in RandomGetWrap()
Martin Natano [Mon, 30 Oct 2017 15:03:25 +0000 (16:03 +0100)] 
app-layer-htp, stream-tcp: prevent modulo bias in RandomGetWrap()

RAND_MAX is not guaranteed to be a divisor of ULONG_MAX, so take the
necessary precautions to get unbiased random numbers. Although the
bias might be negligible, it's not advisable to rely on it.

7 years agoaf_packet: bug #2422.
Alexander Gozman [Thu, 18 Jan 2018 09:05:15 +0000 (09:05 +0000)] 
af_packet: bug #2422.

This commit fixes a leak of mmap'ed ring buffer that was not
unmaped when a socket was closed. In addition, the leak could
break an inline channel on certain configurations.

Also slightly changed AFPCreateSocket():
1. If an interface is not up, it does not try to apply any
   settings to a socket. This reduces a number of error messages
   while an interface is down.
2. Interface is considered active if both IFF_UP and IFF_RUNNING
   are present.

7 years agostream/midstream: be more liberal with window
Victor Julien [Wed, 17 Jan 2018 12:04:54 +0000 (13:04 +0100)] 
stream/midstream: be more liberal with window

Use the wscale setting when updating the window, even if it's very
high.

7 years agotime: Force init cached_minute_start array
Maurizio Abba [Thu, 11 Jan 2018 14:34:37 +0000 (14:34 +0000)] 
time: Force init cached_minute_start array

In offline mode, if the starting timestamp is 0 suricata will never
initialize cached_minute_start array. This cause the timestamp to be
ignored when needed (e.g., in fast.log).

This commit will force the initialization of this array.

7 years agorust/nfs: improve file close handling
Victor Julien [Tue, 17 Oct 2017 08:19:00 +0000 (10:19 +0200)] 
rust/nfs: improve file close handling

7 years agorust/nfs: don't panic on malformed NFS traffic
Nick Price [Thu, 28 Dec 2017 16:11:17 +0000 (11:11 -0500)] 
rust/nfs: don't panic on malformed NFS traffic

Instead set events.

7 years agoaf-packet: free ring buffer at exit
Eric Leblond [Mon, 1 Jan 2018 18:03:24 +0000 (19:03 +0100)] 
af-packet: free ring buffer at exit

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;
            ^