Commit Graph

8468 Commits (suricata-4.0.6)
 

Author SHA1 Message Date
Victor Julien 2c40c34ad2 doc: fix http_header_names example 8 years ago
Jason Ish 29e20c08e9 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
8 years ago
Jason Ish 8d1739b972 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.
8 years ago
Jason Ish 3e0a1c8c5d dnp3: regenerate object decoding code 8 years ago
Jason Ish c19ac42979 dnp3-gen: require jinja2 v2.10 or later
Previous versions, but not all, have issues tracking
variables.
8 years ago
Philippe Antoine 3196142411 dnp3-gen: fix heap buffer overflow in generated code
Due to missing check before memcpy.
8 years ago
Victor Julien f767c0c5b0 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.
8 years ago
Victor Julien 60bab318c9 der: warn if null passed to decoders
Remove null checks for errcode.
8 years ago
Victor Julien 2dc344edb0 detect: fix out of bounds write in thread space creation 8 years ago
Victor Julien 2b9d242033 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.
8 years ago
Victor Julien 660c1de7ba 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.
8 years ago
Victor Julien 97ebd3b05a 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.
8 years ago
Victor Julien 8f20318481 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.
8 years ago
Victor Julien c5e345f5b8 nfs: remove old test code 8 years ago
Victor Julien e6936c34fa pcre: don't leak memory in data extraction 8 years ago
Victor Julien e238277830 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 {
8 years ago
Victor Julien a83c9a376d rust/filetracker: if file API return error, trunc file 8 years ago
Victor Julien 06c47a7bd7 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.
8 years ago
Victor Julien 10b53ad597 file: minor cleanups 8 years ago
Victor Julien d2b7b08a0f file: use enum for state
Makes debugging easier.
8 years ago
Victor Julien 9fec31fb0f rust/file: handle file open errors 8 years ago
Victor Julien 95acbf4a58 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.
8 years ago
Victor Julien 7fad49cb04 rust/core: comment cleanup 8 years ago
Victor Julien f2ba14a98b rust: don't gen C headers if Rust isn't enabled 8 years ago
Martin Natano 7f3d623abc 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.
8 years ago
Alexander Gozman 32dc16f085 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.
8 years ago
Victor Julien 868acb8301 stream/midstream: be more liberal with window
Use the wscale setting when updating the window, even if it's very
high.
8 years ago
Maurizio Abba 8623b52db4 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.
8 years ago
Victor Julien 316788ad5c rust/nfs: improve file close handling 8 years ago
Nick Price 82d66b8e94 rust/nfs: don't panic on malformed NFS traffic
Instead set events.
8 years ago
Eric Leblond dbd925cd23 af-packet: free ring buffer at exit 8 years ago
Victor Julien 40e2257f21 scan-build: fix memleak warning in port parsing 8 years ago
Victor Julien b11897921f detect/tos: fix memleak in error path 8 years ago
Victor Julien fcb81d1390 scan-build: fix warning in radix tree 8 years ago
Jason Ish 0cc3ba3e70 eve.flow: remove "hi" log message 8 years ago
Jason Ish dc10f085ef eve.netflow: remove "hi" log message 8 years ago
Victor Julien 445f2f2bc5 decode/vlan: don't consider ARP 'unknown' 8 years ago
Victor Julien 6fe3620bff 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.
8 years ago
Victor Julien 0a1298696d 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.
8 years ago
Pierre Chifflier 68ee43b9e6 Hash table: free bucker in case of insertion error
This fixes a warning raised by cppcheck.
8 years ago
Pierre Chifflier 1a1bfc734c 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.
8 years ago
Jason Ish cff8b32a09 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
8 years ago
Jason Ish 51188e44f9 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.
8 years ago
Andreas Herz ade46544ca detect-engine: add missing mutex unlock 8 years ago
Andreas Herz 61403bfcc9 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).
8 years ago
Victor Julien a966be1e11 doc: initial suricata-update page 8 years ago
Victor Julien ff350d3e27 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.
8 years ago
Victor Julien cacd8d1158 qa: add more drmemory suppressions for hyperscan 8 years ago
Victor Julien bbe21d2b37 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.
8 years ago
Wolfgang Hotwagner 49a74cc35c 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
8 years ago