]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agohostbits: fix test setup 3108/head
Victor Julien [Sat, 14 Oct 2017 21:14:31 +0000 (23:14 +0200)] 
hostbits: fix test setup

7 years agofile_data: move tests into tests/
Victor Julien [Sat, 14 Oct 2017 08:09:57 +0000 (10:09 +0200)] 
file_data: move tests into tests/

7 years agofile_data: unify inspect engines
Victor Julien [Thu, 12 Oct 2017 16:19:23 +0000 (18:19 +0200)] 
file_data: unify inspect engines

Call HTTP from the generic file_data engine.

7 years agofile_data: smtp file_data to generic file_data
Victor Julien [Fri, 29 Sep 2017 21:09:15 +0000 (23:09 +0200)] 
file_data: smtp file_data to generic file_data

Generalize the SMTP file_data inspection into a 'files'
file_data inspection that can be used for any protocol
that uses the File API.

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

7 years agoapp-layer: use bool for 'HasDecoderEvents'
Victor Julien [Sun, 8 Oct 2017 16:23:22 +0000 (18:23 +0200)] 
app-layer: use bool for 'HasDecoderEvents'

7 years agodetect: no tcp flags in mask for pseudo packets
Victor Julien [Tue, 7 Nov 2017 10:28:01 +0000 (11:28 +0100)] 
detect: no tcp flags in mask for pseudo packets

7 years agodetect/mpm: micro optimization in setup
Victor Julien [Sun, 17 Dec 2017 19:08:12 +0000 (20:08 +0100)] 
detect/mpm: micro optimization in setup

7 years agodetect: remove old simd references
Victor Julien [Sun, 8 Oct 2017 12:28:19 +0000 (14:28 +0200)] 
detect: remove old simd references

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: minor code cleanups
Victor Julien [Wed, 20 Dec 2017 08:03:33 +0000 (09:03 +0100)] 
pfring: minor code cleanups

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 agoapp-layer-ftp: add memcap for ftp
Eric Leblond [Fri, 24 Nov 2017 15:59:34 +0000 (16:59 +0100)] 
app-layer-ftp: add memcap for ftp

Add a memory cap for the FTP protocol.

7 years agodoc: update file extraction document
Eric Leblond [Sun, 19 Nov 2017 19:27:17 +0000 (20:27 +0100)] 
doc: update file extraction document

Define the list of protocol parsers supporting extraction in one
single place following Andreas Herz' suggestion.

7 years agodoc: update following ftp-data changes
Eric Leblond [Sun, 19 Nov 2017 19:22:46 +0000 (20:22 +0100)] 
doc: update following ftp-data changes

7 years agodetect-ftpdata: match on ftp-data operation
Eric Leblond [Sun, 19 Nov 2017 19:21:08 +0000 (20:21 +0100)] 
detect-ftpdata: match on ftp-data operation

This keyword mathes on ftp operation STOR and RETR. It will allow
rules writer to select if the alert has to be on a put or a fetch
operation.

It is now possible to write a signature like:

  alert ftp-data any any -> any any (msg:"FTP data get firwmare"; ftdata_command:retr; sid:2; rev:1;)

to alert when a file is retrieved from a FTP server.

7 years agoapp-layer-ftp: add ftp-data support
Eric Leblond [Wed, 13 Sep 2017 14:48:29 +0000 (15:48 +0100)] 
app-layer-ftp: add ftp-data support

Use expectation to be able to identify connections that are
ftp data. It parses the PASV response, STOR message and the
RETR message to provide extraction of files.

Implementation in Rust of FTP messages parsing is available.

Also this patch changes some var name prefixed by ssh to ftp.

7 years agoapp-layer-expectation: expectation system
Eric Leblond [Tue, 12 Sep 2017 13:11:01 +0000 (14:11 +0100)] 
app-layer-expectation: expectation system

This patch provides a working expectation system. This will allow
suricata to have a way to identify parallel connections opened by
a protocol such as FTP.

Expectation are a chained list and there is a cleaning by timeout
of the entries.

This patch also defined a counter of expectations that is also
used to check if we need to query IPPairs. This way we only query
the IPPairs store if we have an expectation.

7 years agoapp-layer: add Flow to probing parser functions
Eric Leblond [Tue, 12 Sep 2017 15:43:41 +0000 (16:43 +0100)] 
app-layer: add Flow to probing parser functions

7 years agoflow: add parent_id field
Eric Leblond [Sat, 16 Sep 2017 12:28:22 +0000 (13:28 +0100)] 
flow: add parent_id field

This patch adds a parent_id field to the Flow structure that
contain the flow ID of the parent connection for protocol with
dynamic parallel connection opening like FTP.

7 years agodetect: increase signature mask length
Eric Leblond [Fri, 15 Sep 2017 13:33:33 +0000 (14:33 +0100)] 
detect: increase signature mask length

7 years agosuricata: storage early to get it everywhere
Eric Leblond [Tue, 12 Sep 2017 21:53:51 +0000 (22:53 +0100)] 
suricata: storage early to get it everywhere

7 years agodoc: add memcap commands in unix-socket section 3104/head
Giuseppe Longo [Fri, 1 Dec 2017 13:48:54 +0000 (14:48 +0100)] 
doc: add memcap commands in unix-socket section

7 years agosuricatasc: add commands for memcap handling
Giuseppe Longo [Mon, 20 Nov 2017 14:22:54 +0000 (15:22 +0100)] 
suricatasc: add commands for memcap handling

7 years agorunmode-unix-socket: add commands for memcap handling
Giuseppe Longo [Mon, 20 Nov 2017 14:19:45 +0000 (15:19 +0100)] 
runmode-unix-socket: add commands for memcap handling

This permits to handle memcap values through
unix socket for:
- stream
- stream-reassembly
- flow
- applayer-proto-http
- defrag
- ippair
- host

It will be possible to show or change a memcap value
for a specified configuration and list all memcap values
available.

The following commands are registered for unix-socket:
- memcap-set
- memcap-show
- memcap-list

Output:
>>> memcap-show flow
Success:
{
    "value": "64mb"
}

>>> memcap-set flow 64mb
Success:
"memcap value for 'flow' updated: 67108864"

Command with invalid memcap key:
>>> memcap-set udp 32mb
Error:
"Available config: stream stream-reassembly flow applayer-proto-http defrag ippair host"

Command with an invalid memcap value:
>>> memcap-set http 32mmb
Error:
"error parsing memcap specified, value not changed"

7 years agohost: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:13:00 +0000 (15:13 +0100)] 
host: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

Another function is added to gets
the memuse value since it will be shown
through unix-socket.

7 years agoippair: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:11:15 +0000 (15:11 +0100)] 
ippair: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

Another function is added to gets
the memuse value since it will be shown
through unix-socket.

7 years agodefrag: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:09:17 +0000 (15:09 +0100)] 
defrag: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

Another function is added to gets
the memuse value since it will be shown
through unix-socket.

7 years agohtp: destroy atomic vars
Giuseppe Longo [Mon, 11 Dec 2017 08:42:56 +0000 (09:42 +0100)] 
htp: destroy atomic vars

Atomic vars declared in app-layer-htp-mem.c were not
destroyed when suricata is shutdown.

7 years agohtp: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:06:54 +0000 (15:06 +0100)] 
htp: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

7 years agoflow: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:02:32 +0000 (15:02 +0100)] 
flow: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

FlowGetMemuse() function is made as public
because the memuse value will be shown
through unix-socket.

7 years agostream-tcp: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 13:39:22 +0000 (14:39 +0100)] 
stream-tcp: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

7 years agostream-tcp-reassemble: declare 'size' as uint64_t
Giuseppe Longo [Wed, 13 Dec 2017 11:26:35 +0000 (12:26 +0100)] 
stream-tcp-reassemble: declare 'size' as uint64_t

According to all checking memcap functions,
the size passed as argument is declared as uint64_t
except for StreamTcpReassembleCheckMemcap where it's
defined as uint32_t.

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 agodoc: document log reopen unix socket command
Eric Leblond [Tue, 12 Dec 2017 11:48:42 +0000 (12:48 +0100)] 
doc: document log reopen unix socket command

7 years agounix-socket: add logs reopen command
Eric Leblond [Mon, 27 Nov 2017 10:23:24 +0000 (11:23 +0100)] 
unix-socket: add logs reopen command

We did had a race condition with running logrotate with multiple
EVE Json files. Consequence was one of the file not being reopen
by suricata that did continue to write to the rotated one.

Trying fix on signal handler did fail so this patch implements
log rotation support by adding a dedicated command to unix socket
to reopen the log files.

7 years agodns-log: don't register if HAVE_RUST 3103/head
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 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 agocontent: fix depth/within, offset/distance mix
Victor Julien [Fri, 15 Dec 2017 08:44:12 +0000 (09:44 +0100)] 
content: fix depth/within, offset/distance mix

7 years agotemplate scripts: fixup detect setup scripts 3093/head
Jason Ish [Wed, 13 Dec 2017 22:18:40 +0000 (16:18 -0600)] 
template scripts: fixup detect setup scripts

Update scripts to reflect recent changes in the detection files.

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 3090/head
Victor Julien [Wed, 6 Dec 2017 21:54:31 +0000 (22:54 +0100)] 
doc: initial suricata-update page

7 years agopcap-directory: fix double free in error path 3085/head
Victor Julien [Wed, 13 Dec 2017 12:05:23 +0000 (13:05 +0100)] 
pcap-directory: fix double free in error path

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

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

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

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

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

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

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

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

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

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

Seen underflow issues on profiling on arm (gettimeofday based.

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

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

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

Bug: 2354

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

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

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

Ticketno: Bug #2349

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bug #2306.

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

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

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

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

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

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

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

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

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

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

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

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

Examples:

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

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

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

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

Add lots of test cases.

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

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

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

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

Engine state will not reset between files.

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

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

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

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

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

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

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

This add a new command the new naming convention.

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

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

This permits to print the invalid rules through
unix socket.

An example output is the following:

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

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

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

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

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

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

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

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

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

This permits to print engine stats through
unix socket.

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

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

The following is a snippet of the generated EVE entry:

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

Multi-tenancy enabled:

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

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

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

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

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

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

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

This adds dns header's flags in eve
log.

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

Based on the list in suricata.yaml

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

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

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

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

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

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

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

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

(plus remove lingering screenshot of a rule)

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

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

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

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

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

Most importantly, conventions are now placed in tip boxes

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