]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agochanglog: update for 4.0.5 3472/head suricata-4.0.5
Victor Julien [Mon, 16 Jul 2018 14:31:37 +0000 (16:31 +0200)] 
changlog: update for 4.0.5

7 years agompm/hs: fix minor coverity warning
Victor Julien [Tue, 3 Apr 2018 10:10:46 +0000 (12:10 +0200)] 
mpm/hs: fix minor coverity warning

CID 1428797 (#1 of 1): Unchecked return value (CHECKED_RETURN)
    check_return: Calling HashTableAdd without checking return value
    (as is done elsewhere 5 out of 6 times).

7 years agoenip: harden byte parsing code
Victor Julien [Thu, 19 Apr 2018 12:55:01 +0000 (14:55 +0200)] 
enip: harden byte parsing code

Make sure we never read more than we have.

Reported-by: Henning Perl
7 years agossh: fix out of bounds read in banner parsing
Victor Julien [Thu, 19 Apr 2018 09:27:43 +0000 (11:27 +0200)] 
ssh: fix out of bounds read in banner parsing

Reported-by: Henning Perl
7 years agorust/dns - remove extra parantheses
Jason Ish [Mon, 25 Jun 2018 14:40:54 +0000 (08:40 -0600)] 
rust/dns - remove extra parantheses

Removes rust compiler warning.

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

7 years agodetect/debug: suppress noisy info messages
Victor Julien [Thu, 28 Jun 2018 08:43:25 +0000 (10:43 +0200)] 
detect/debug: suppress noisy info messages

7 years agoyaml-loader: fix memory leak on fail include
Jason Ish [Mon, 25 Jun 2018 13:08:38 +0000 (07:08 -0600)] 
yaml-loader: fix memory leak on fail include

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

If an include failed to load, either by the file not existing or
a parse error, the file pointer and yaml parser instance were
leaked.

7 years agodetect: fix memory leak in app-layer-event keyword
Victor Julien [Wed, 4 Jul 2018 13:10:34 +0000 (15:10 +0200)] 
detect: fix memory leak in app-layer-event keyword

Bug #2515.

7 years agohttp: fix setting event on the last tx
Victor Julien [Thu, 5 Jul 2018 09:43:41 +0000 (11:43 +0200)] 
http: fix setting event on the last tx

7 years agohttp: set events for too many layers of compression
Victor Julien [Thu, 5 Jul 2018 08:01:47 +0000 (10:01 +0200)] 
http: set events for too many layers of compression

libhtp would already issue warnings, but these were not mapped
to events yet.

7 years agostream: support RST getting lost/ignored
Victor Julien [Thu, 10 May 2018 15:23:05 +0000 (17:23 +0200)] 
stream: support RST getting lost/ignored

In case of a valid RST on a SYN, the state is switched to 'TCP_CLOSED'.
However, the target of the RST may not have received it, or may not
have accepted it. Also, the RST may have been injected, so the supposed
sender may not actually be aware of the RST that was sent in it's name.

In this case the previous behavior was to switch the state to CLOSED and
accept no further TCP updates or stream reassembly.

This patch changes this. It still switches the state to CLOSED, as this
is by far the most likely to be correct. However, it will reconsider
the state if the receiver continues to talk.

To do this on each state change the previous state will be recorded in
TcpSession::pstate. If a non-RST packet is received after a RST, this
TcpSession::pstate is used to try to continue the conversation.

If the (supposed) sender of the RST is also continueing the conversation
as normal, it's highly likely it didn't send the RST. In this case
a stream event is generated.

Ticket: #2501

Reported-By: Kirill Shipulin
7 years agostream-events: fix mapping
Victor Julien [Mon, 21 May 2018 14:15:39 +0000 (16:15 +0200)] 
stream-events: fix mapping

7 years agodetect/stream_size: code cleanups
Victor Julien [Thu, 24 May 2018 12:56:03 +0000 (14:56 +0200)] 
detect/stream_size: code cleanups

7 years agodetect/stream_size: apply rule to packets & stream
Victor Julien [Wed, 23 May 2018 11:55:30 +0000 (13:55 +0200)] 
detect/stream_size: apply rule to packets & stream

The use of stream_size in combination with raw content matches is an
indication that the rule needs to be evaluated per packet, not just
per reassembled stream chunk.

7 years agoutil-random: fix detection of getrandom failure
Eric Leblond [Thu, 24 May 2018 11:43:30 +0000 (13:43 +0200)] 
util-random: fix detection of getrandom failure

7 years agoutil-random: workaround getrandom unavailability
Eric Leblond [Wed, 23 May 2018 06:57:13 +0000 (08:57 +0200)] 
util-random: workaround getrandom unavailability

getrandom syscall availability is detected at runtime. So it is
possible that the build is done on a box that supports it but
the run is done on a system with no availability. So a workaround
solution is needed to fix this case.

Also we have seen some issue in docker environment where the build
is detecting getrandom but where it does not work at runtime.

For both reasons, the code is updated to have a call to a fallback
function if ever the getrandom call returns that the syscall is
not available.

7 years agoFix segfault when the protocol is anything other than HTTP
Elazar Broad [Wed, 2 May 2018 16:38:40 +0000 (12:38 -0400)] 
Fix segfault when the protocol is anything other than HTTP

When a file is transferred over anything other than HTTP, the previously hard-coded HTTP protocol would trigger a non-existent index into htp_list_array_get(), causing a segfault. This patch mimics the logic in detect-lua-extensions.c.

7 years agoUpdate ntp-parser to 0.2.0
Pierre Chifflier [Tue, 15 May 2018 13:33:30 +0000 (15:33 +0200)] 
Update ntp-parser to 0.2.0

7 years agoutil-ioctl: fix a typo in setter message
Eric Leblond [Thu, 19 Apr 2018 14:58:27 +0000 (16:58 +0200)] 
util-ioctl: fix a typo in setter message

7 years agoaf-packet: dump counters when timeout occurs
Eric Leblond [Thu, 19 Apr 2018 17:13:20 +0000 (19:13 +0200)] 
af-packet: dump counters when timeout occurs

When traffic is becoming null (mainly seen in tests) we reach the
situation where there is timeouts in the poll on the socket and
only that. Existing code is then just looping on the poll and
the result is that the packet iface counters are not updated.

This patch calls the dump counter function to be sure to get
the counter right faster (and not only right at exit).

7 years agohyperscan: don't abort on payloads > 64k
Victor Julien [Wed, 25 Apr 2018 15:23:45 +0000 (17:23 +0200)] 
hyperscan: don't abort on payloads > 64k

SPM API was recently updated to accept 32 bit length fields instead of
16 bits. This could trigger a BUG_ON in the hyperscan implementation.

7 years agodetect: fix buffer length to uint32
Maurizio Abba [Tue, 10 Apr 2018 14:37:41 +0000 (15:37 +0100)] 
detect: fix buffer length to uint32

There is a difference in the size of the buffer length as passed from
the content buffers (cfr HttpReassembledBody.buffer_len) and the buflen
variable passed to mpm primitives. This can cause a misdetection
whenever the bufferlen is multiple of 65536 (as uint16(X*65536) == 0).
Increasing the buflen variable type to uint32 solves the issue (this
does not cause any issue with primitives, they all accept uint32).

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 agounified2: address strict aliasing issue
Victor Julien [Wed, 4 Apr 2018 11:49:35 +0000 (13:49 +0200)] 
unified2: address strict aliasing issue

7 years agodecode/ipv6: expose addr as 'struct in6_addr' as well
Victor Julien [Wed, 4 Apr 2018 11:28:29 +0000 (13:28 +0200)] 
decode/ipv6: expose addr as 'struct in6_addr' as well

7 years agoconfigure: fix small issue with libevent check
Victor Julien [Tue, 3 Apr 2018 10:06:37 +0000 (12:06 +0200)] 
configure: fix small issue with libevent check

7 years agoBug #2466: map SC_LOG_CONFIG level to syslogs LOG_DEBUG
Alexander Gozman [Mon, 26 Mar 2018 14:14:48 +0000 (14:14 +0000)] 
Bug #2466: map SC_LOG_CONFIG level to syslogs LOG_DEBUG

7 years agoPrint syslog format with SCLogDebug() instead of printf()
Alexander Gozman [Thu, 29 Mar 2018 15:55:52 +0000 (15:55 +0000)] 
Print syslog format with SCLogDebug() instead of printf()

7 years agodoc: add by_either to suppress explanation
Victor Julien [Thu, 29 Mar 2018 13:31:47 +0000 (15:31 +0200)] 
doc: add by_either to suppress explanation

7 years agodoc: minor fix
Victor Julien [Thu, 29 Mar 2018 13:13:18 +0000 (15:13 +0200)] 
doc: minor fix

7 years agoconfigure: allow to disable libnss and libnspr
Renato Botelho [Thu, 22 Mar 2018 14:02:42 +0000 (11:02 -0300)] 
configure: allow to disable libnss and libnspr

Let user chose to disable libnss and libnspr support even if these
libraries are installed in the system. Default remains to enable when
libraries are found and disable parameter were not used

7 years agonfs/rpc: fix reponse parsing
Victor Julien [Wed, 21 Mar 2018 14:50:11 +0000 (15:50 +0100)] 
nfs/rpc: fix reponse parsing

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