]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
6 years agodefrag: break out of loop in linux profile when able to 3479/head
Jason Ish [Fri, 14 Sep 2018 05:11:14 +0000 (23:11 -0600)] 
defrag: break out of loop in linux profile when able to

6 years agodefrag: remove fragments that have complete overlap
Jason Ish [Thu, 13 Sep 2018 19:09:20 +0000 (13:09 -0600)] 
defrag: remove fragments that have complete overlap

Instead of just marking fragments that have been completely
overlapped and won't be part of the assembled packet, remove
them from the fragment tree when detected.

6 years agodefrag: use rb tree to store fragments
Jason Ish [Mon, 3 Sep 2018 22:53:47 +0000 (16:53 -0600)] 
defrag: use rb tree to store fragments

6 years agounittests: fix format-truncation warning
Victor Julien [Thu, 13 Sep 2018 10:18:32 +0000 (12:18 +0200)] 
unittests: fix format-truncation warning

6 years agostream/segments: change packing to reduce size
Victor Julien [Thu, 30 Aug 2018 15:25:54 +0000 (17:25 +0200)] 
stream/segments: change packing to reduce size

Change the way fields are ordered to reduce TcpSegment structure
with 8 bytes.

6 years agostream/segments: keep track of tree right edge
Victor Julien [Tue, 28 Aug 2018 12:02:40 +0000 (14:02 +0200)] 
stream/segments: keep track of tree right edge

Use this in places where we need to use the outer right
edge of our sequence space.

This way we can avoid walking the tree to find this, which
is a potentially expensive operation.

6 years agostreaming/sbb: convert RB_MIN to 'head'
Victor Julien [Wed, 29 Aug 2018 13:31:39 +0000 (15:31 +0200)] 
streaming/sbb: convert RB_MIN to 'head'

6 years agostreaming: keep track of tree 'head'
Victor Julien [Wed, 29 Aug 2018 13:13:31 +0000 (15:13 +0200)] 
streaming: keep track of tree 'head'

6 years agostreaming: use rbtree for stream blocks
Victor Julien [Mon, 27 Aug 2018 06:11:54 +0000 (08:11 +0200)] 
streaming: use rbtree for stream blocks

Switch StreamBufferBlocks implementation to use RBTREE instead of
a list. This makes inserts/removals and lookups a lot cheaper if
the number of data gaps is large.

Use separate compare functions for inserts and regular lookups.
Inserts care about the offset, while lookups care about the blocks
right edge as well.

6 years agostream/sack: optimize SACK size handling
Victor Julien [Mon, 27 Aug 2018 07:01:16 +0000 (09:01 +0200)] 
stream/sack: optimize SACK size handling

Optimize by keeping count during insert/remove instead of
walking the tree per check.

6 years agostream/sack: turn SACK record list into rbtree
Victor Julien [Sun, 26 Aug 2018 08:14:18 +0000 (10:14 +0200)] 
stream/sack: turn SACK record list into rbtree

Convert to rbtree from linked list. These ranges, of which there can
be multiple per packet, are fully controlled by an attacked. The
attacker could craft a stream of packet in such a way that the list
would grow very large. This would make inserts/removals very expensive,
as well as the list walk that is done and size calculation and pruning
operations.

The RBTREE makes inserts/removals much cheaper, at a slight overhead
for 'normal' operations and slightly higher per record memory use.

6 years agostream/segments: speed up inserts
Victor Julien [Mon, 27 Aug 2018 20:55:19 +0000 (22:55 +0200)] 
stream/segments: speed up inserts

Don't try to do a 'fast path' by checking RB_MAX. RB_MAX walks the
tree which means it can be quite expensive. This cost would be paid
for virtually every data segment. The actual insert that follows would
walk the tree again.

Instead, simply insert it. There is a slight cost of the unnecessary
overlap check, but this is much less than the tree walk in a full
tree.

6 years agostream/segments: remove RB_MIN/RB_MAX
Victor Julien [Tue, 28 Aug 2018 09:50:23 +0000 (11:50 +0200)] 
stream/segments: remove RB_MIN/RB_MAX

6 years agostream/segments: optimize overlap tree operations
Victor Julien [Mon, 27 Aug 2018 10:26:11 +0000 (12:26 +0200)] 
stream/segments: optimize overlap tree operations

Now that with the RBTREE we have a properly sorted Segment tree,
where with exact SEQ matches the tree is sorted by payload_len
smallest to largest, we can avoid walking backwards when checking
for overlaps. Our direct RB_PREV either overlaps or not and that
is a reliable verdict for the rest of the tree.

6 years agostream/segments: turn linked list into rbtree
Victor Julien [Thu, 23 Aug 2018 15:27:08 +0000 (17:27 +0200)] 
stream/segments: turn linked list into rbtree

To improve worst case performance turn the segments list into a rbtree.
This greatly improves inserts, lookups and removals if the number of
segments gets very large.

The tree is sorted by the segment sequence number as its primary key.
If 2 segments have the same seq, the payload_len (segment length) is
used. Then the larger segment will be places after the smaller segment.
Exact matches are not added to the tree.

6 years agotree: add scan-build assertions to suppress FPs
Victor Julien [Tue, 11 Sep 2018 12:54:29 +0000 (14:54 +0200)] 
tree: add scan-build assertions to suppress FPs

6 years agotree: add 2-clause BSD licensed tree.h
Victor Julien [Thu, 23 Aug 2018 11:53:03 +0000 (13:53 +0200)] 
tree: add 2-clause BSD licensed tree.h

6 years agostream: expand GAP detection
Victor Julien [Thu, 30 Aug 2018 13:03:34 +0000 (15:03 +0200)] 
stream: expand GAP detection

6 years agodetect/mpm: minor code cleanup
Victor Julien [Tue, 11 Sep 2018 13:16:10 +0000 (15:16 +0200)] 
detect/mpm: minor code cleanup

6 years agodetect/file: fix minor scan-build warnings
Victor Julien [Wed, 12 Sep 2018 12:47:55 +0000 (14:47 +0200)] 
detect/file: fix minor scan-build warnings

6 years agostream/tcp: be more liberal in last_ack
Victor Julien [Sun, 2 Sep 2018 09:34:42 +0000 (11:34 +0200)] 
stream/tcp: be more liberal in last_ack

Don't set even if seq is before next_seq, as this could still be
a valid packet that was sent before the state was reached.

6 years agostream/tcp: add debug statements to state dispatcher
Victor Julien [Sun, 2 Sep 2018 09:34:22 +0000 (11:34 +0200)] 
stream/tcp: add debug statements to state dispatcher

6 years agoapp-layer-ssl: don't decode empty extensions 3478/head
Mats Klepsland [Sat, 15 Sep 2018 12:01:11 +0000 (14:01 +0200)] 
app-layer-ssl: don't decode empty extensions

6 years agodoc: add documentation for Lua function 'TlsGetVersion'
Mats Klepsland [Tue, 28 Aug 2018 20:54:07 +0000 (22:54 +0200)] 
doc: add documentation for Lua function 'TlsGetVersion'

6 years agolua: add function 'TlsGetVersion'
Mats Klepsland [Tue, 28 Aug 2018 20:46:26 +0000 (22:46 +0200)] 
lua: add function 'TlsGetVersion'

Add another function to get TLS version, since 'TlsGetCertInfo' only
works when a TLS session contains a clear text certificate, which is
not the case in TLSv1.3 or when a session is resumed.

6 years agodoc: update tls.version documentation
Mats Klepsland [Mon, 27 Aug 2018 10:43:06 +0000 (12:43 +0200)] 
doc: update tls.version documentation

6 years agodetect-tls-version: add support for 'raw' matching
Mats Klepsland [Mon, 27 Aug 2018 08:13:00 +0000 (10:13 +0200)] 
detect-tls-version: add support for 'raw' matching

Add support for matching a 'raw' TLS version using a hex string, e.g:

  tls.version:0x7f12;

The above example matches TLSv1.3 draft 16.

6 years agodetect-tls-version: add support for TLSv1.3
Mats Klepsland [Thu, 23 Aug 2018 17:31:40 +0000 (19:31 +0200)] 
detect-tls-version: add support for TLSv1.3

6 years agodetect-ssl-version: add support for TLSv1.3
Mats Klepsland [Thu, 23 Aug 2018 16:16:29 +0000 (18:16 +0200)] 
detect-ssl-version: add support for TLSv1.3

6 years agolua: use 'SSLVersionToString' in TlsGetCertInfo()
Mats Klepsland [Wed, 22 Aug 2018 20:08:35 +0000 (22:08 +0200)] 
lua: use 'SSLVersionToString' in TlsGetCertInfo()

6 years agotlslog: add support for TLSv1.3
Mats Klepsland [Wed, 22 Aug 2018 12:25:55 +0000 (14:25 +0200)] 
tlslog: add support for TLSv1.3

6 years agooutput-json-tls: add support for TLSv1.3
Mats Klepsland [Wed, 22 Aug 2018 12:24:42 +0000 (14:24 +0200)] 
output-json-tls: add support for TLSv1.3

6 years agoapp-layer-ssl: add function to get string from version
Mats Klepsland [Tue, 28 Aug 2018 20:25:50 +0000 (22:25 +0200)] 
app-layer-ssl: add function to get string from version

Add 'SSLVersionToString' to get string from version.

6 years agoapp-layer-ssl: add support for earlier TLSv1.3 drafts
Mats Klepsland [Wed, 22 Aug 2018 19:12:40 +0000 (21:12 +0200)] 
app-layer-ssl: add support for earlier TLSv1.3 drafts

Add support for TLSv1.3 draft 1 to draft 21.

6 years agoapp-layer-ssl: add support for TLSv1.3 from draft 22
Mats Klepsland [Wed, 22 Aug 2018 12:21:24 +0000 (14:21 +0200)] 
app-layer-ssl: add support for TLSv1.3 from draft 22

Add support for draft 22 to draft 28 and for the final
version (RFC8446) of TLSv1.3.

6 years agoapp-layer-ssl: add support for session tickets
Mats Klepsland [Tue, 21 Aug 2018 10:58:44 +0000 (12:58 +0200)] 
app-layer-ssl: add support for session tickets

Add support for logging a session as 'resumed' when using a non-empty
session ticket extension in the client hello record.

6 years agoapp-layer-ssl: add better session id support
Mats Klepsland [Tue, 21 Aug 2018 06:21:21 +0000 (08:21 +0200)] 
app-layer-ssl: add better session id support

Verify that the session id from both the client hello record and the
server hello record matches before marking the session as 'resumed'.

6 years agoapp-layer-ssl: decode server hello record
Mats Klepsland [Sun, 19 Aug 2018 18:49:45 +0000 (20:49 +0200)] 
app-layer-ssl: decode server hello record

Decoding server hello is needed to do a better implementation of
session resumption.

6 years agodoc: README.md minor fixes 3470/head
jason taylor [Thu, 30 Aug 2018 14:11:48 +0000 (10:11 -0400)] 
doc: README.md minor fixes

- Capitalization update
- Typo fix
- Spacing update

Signed-off-by: jason taylor <jtfas90@gmail.com>
6 years agoflow/timeout: code simplification and cleanup
Victor Julien [Wed, 29 Aug 2018 19:14:28 +0000 (21:14 +0200)] 
flow/timeout: code simplification and cleanup

6 years agostream: minor code cleanup
Victor Julien [Wed, 29 Aug 2018 11:10:41 +0000 (13:10 +0200)] 
stream: minor code cleanup

6 years agorules: hide 'template' from --list-keywords
Victor Julien [Thu, 30 Aug 2018 07:11:07 +0000 (09:11 +0200)] 
rules: hide 'template' from --list-keywords

6 years agorules: hide internal keywords from --list-keywords
Victor Julien [Thu, 30 Aug 2018 07:09:49 +0000 (09:09 +0200)] 
rules: hide internal keywords from --list-keywords

6 years agoflow-manager: fix unittest initialization 3466/head
Victor Julien [Sun, 26 Aug 2018 06:56:33 +0000 (08:56 +0200)] 
flow-manager: fix unittest initialization

6 years agoapp-layer-ssl: make sure that JA3 stuff is only initialized once
Mats Klepsland [Sat, 25 Aug 2018 19:50:05 +0000 (21:50 +0200)] 
app-layer-ssl: make sure that JA3 stuff is only initialized once

Avoid possible memory leaks by making sure that JA3 buffer and
string is only initialized once.

6 years agoapp-layer-ssl: fix memleak/coredump (Bug #2603)
Mats Klepsland [Sat, 25 Aug 2018 16:47:18 +0000 (18:47 +0200)] 
app-layer-ssl: fix memleak/coredump (Bug #2603)

6 years agoaf-packet: close the socket in case of early fail
Eric Leblond [Tue, 28 Aug 2018 20:46:25 +0000 (22:46 +0200)] 
af-packet: close the socket in case of early fail

6 years agolog-filestore: fix file descriptor leak
Eric Leblond [Wed, 22 Aug 2018 22:21:51 +0000 (00:21 +0200)] 
log-filestore: fix file descriptor leak

In the case we exceed the number of simultaneously open
file we can reach a state were we will not close the file
after writing.

Thanks to Steve Grubb <sgrubb@redhat.com> for the analysis.

6 years agoprofiling/app-layer: fix TCP parsers showing UDP stats
Victor Julien [Wed, 29 Aug 2018 10:11:03 +0000 (12:11 +0200)] 
profiling/app-layer: fix TCP parsers showing UDP stats

6 years agoprofiling: add missing logger labels
Victor Julien [Wed, 29 Aug 2018 10:08:59 +0000 (12:08 +0200)] 
profiling: add missing logger labels

6 years agodetect: clean up sgh flags and add cocci check 3457/head
Victor Julien [Thu, 16 Aug 2018 20:15:09 +0000 (22:15 +0200)] 
detect: clean up sgh flags and add cocci check

6 years agostream: minor code cleanups
Victor Julien [Thu, 16 Aug 2018 19:59:37 +0000 (21:59 +0200)] 
stream: minor code cleanups

6 years agodetect/mpm: clean up setup code
Victor Julien [Thu, 16 Aug 2018 12:57:20 +0000 (14:57 +0200)] 
detect/mpm: clean up setup code

6 years agodhcp: check length of option before accessing
Jason Ish [Mon, 13 Aug 2018 04:44:02 +0000 (22:44 -0600)] 
dhcp: check length of option before accessing

Prevent Rust index out of bounds panic.

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

6 years agodhcp: remove println!() that got committed
Jason Ish [Mon, 13 Aug 2018 04:40:10 +0000 (22:40 -0600)] 
dhcp: remove println!() that got committed

6 years agodetect: fix file_data detect issue with alert ip
Victor Julien [Wed, 15 Aug 2018 10:28:52 +0000 (12:28 +0200)] 
detect: fix file_data detect issue with alert ip

Fix mpm progress being updated by irrelevant engines. Esp in the
case of file_data engines, signature can contain multiple versions
of the same engine, registered for different 'progress' values.

This would lead to signatures being considered 'can't match' even
in cases where they clearly could still match.

Only consider those progress values that apply to the protocol in
use.

6 years agodetect/parse: try to set flow direction for sigs w/o explict app proto as well
Victor Julien [Wed, 15 Aug 2018 10:15:26 +0000 (12:15 +0200)] 
detect/parse: try to set flow direction for sigs w/o explict app proto as well

6 years agoconfigure: added rust install notes
jason taylor [Tue, 17 Jul 2018 13:27:23 +0000 (09:27 -0400)] 
configure: added rust install notes

Signed-off-by: jason taylor <jtfas90@gmail.com>
6 years agoconfigure: updated fedora/centos references
jason taylor [Tue, 17 Jul 2018 00:53:24 +0000 (20:53 -0400)] 
configure: updated fedora/centos references

* updated fedora yum references to dnf
* updated/added centos/rhel references

Signed-off-by: jason taylor <jtfas90@gmail.com>
6 years agoeve/http: add tx->request_port_number as http_port
Maurizio Abba [Fri, 3 Aug 2018 12:51:13 +0000 (13:51 +0100)] 
eve/http: add tx->request_port_number as http_port

Add the port specified in the hostname (if any) to the http object in
eve. The port may be different from the dest_port used by the TCP flow.

6 years agoyaml: add var for DC_SERVERS (Domain Controller)
Konstantin Klinger [Mon, 23 Jul 2018 12:46:33 +0000 (14:46 +0200)] 
yaml: add var for DC_SERVERS (Domain Controller)

6 years agoyaml: add note for dns v1 not available with rust
Konstantin Klinger [Mon, 23 Jul 2018 12:50:21 +0000 (14:50 +0200)] 
yaml: add note for dns v1 not available with rust

6 years agoyaml: add note for dns.log with Rust
Konstantin Klinger [Mon, 23 Jul 2018 12:48:29 +0000 (14:48 +0200)] 
yaml: add note for dns.log with Rust

It is not availbale when rust is enabled.

6 years agodoc: iprep supports CIDR networks
Eric Leblond [Sat, 4 Aug 2018 07:49:59 +0000 (09:49 +0200)] 
doc: iprep supports CIDR networks

6 years agoutil-unittest: fix typo
Eric Leblond [Sat, 4 Aug 2018 07:40:41 +0000 (09:40 +0200)] 
util-unittest: fix typo

6 years agodetect/files: fix inspection issues with 'alert ip'
Victor Julien [Tue, 14 Aug 2018 09:12:37 +0000 (11:12 +0200)] 
detect/files: fix inspection issues with 'alert ip'

Don't track the 'skipped' engines as matches.

6 years agodetect/filehash: try to open data file from rulefile dir
Victor Julien [Tue, 14 Aug 2018 08:17:37 +0000 (10:17 +0200)] 
detect/filehash: try to open data file from rulefile dir

If the data file can't be found in the default location, which
normally is 'default-rule-path', try to see if it can be found
in the path of the rule file that references it.

This makes QA much easier.

6 years agofiles: only prune in own direction
Victor Julien [Tue, 14 Aug 2018 07:21:04 +0000 (09:21 +0200)] 
files: only prune in own direction

Only prune files in own direction. The opposite direction may still
require inspection.

6 years agococci: add more flag checks 3453/head
Victor Julien [Mon, 13 Aug 2018 08:23:59 +0000 (10:23 +0200)] 
cocci: add more flag checks

6 years agodetect: use BIT_* macros
Victor Julien [Mon, 13 Aug 2018 08:13:53 +0000 (10:13 +0200)] 
detect: use BIT_* macros

Also add notes that when adding flags they should be added to the
analyzer as well.

6 years agostream: use BIT_U8 for stream flags
Victor Julien [Mon, 13 Aug 2018 07:21:05 +0000 (09:21 +0200)] 
stream: use BIT_U8 for stream flags

7 years agodetect/prefilter: speed up setup 3451/head
Victor Julien [Thu, 9 Aug 2018 22:06:24 +0000 (00:06 +0200)] 
detect/prefilter: speed up setup

If the global detect.prefilter.default setting is not "auto", it is
wasteful to run each prefilter setup routine. This patch tracks which
of the engines have been explicitly enabled in the rules and only
runs those.

7 years agodetect/prefilter: fix prefilter when setting is 'mpm'
Victor Julien [Thu, 9 Aug 2018 15:35:32 +0000 (17:35 +0200)] 
detect/prefilter: fix prefilter when setting is 'mpm'

When prefilter is not enabled globally, it is still possible to
enable it per signature. This was broken however, as the setup
code would never be called.

This commit always call the setup code and lets that sort out
which signatures (if any) to enable prefiltering for.

7 years agodetect: include keyword types in detect.h
Victor Julien [Thu, 9 Aug 2018 22:05:50 +0000 (00:05 +0200)] 
detect: include keyword types in detect.h

7 years agodetect/analyzer: show pattern that is used by mpm
Victor Julien [Thu, 9 Aug 2018 21:27:00 +0000 (23:27 +0200)] 
detect/analyzer: show pattern that is used by mpm

Set a new DETECT_CONTENT_MPM flag on the pattern that is selected
during setup.

7 years agodetect/prefilter: fix alias for fast_pattern
Victor Julien [Thu, 9 Aug 2018 15:33:19 +0000 (17:33 +0200)] 
detect/prefilter: fix alias for fast_pattern

If prefilter is used on a content keyword, it acts as a simple
fast_pattern statement. This was broken because the SIG_FLAG_PREFILTER
flag bypasses MPM for a sig. This commits fixes this by not setting
the flag when it should act as fast_pattern.

7 years agodetect: limit flush logic to sigs that need it
Victor Julien [Thu, 9 Aug 2018 13:32:49 +0000 (15:32 +0200)] 
detect: limit flush logic to sigs that need it

Limit the early 'flush' logic to sigs that actually need to match
on both stream and http bodies.

7 years agodetect/analyzer: add built-in lists
Victor Julien [Thu, 9 Aug 2018 11:45:24 +0000 (13:45 +0200)] 
detect/analyzer: add built-in lists

7 years agodetect: don't setup PMATCH if it will be unused
Victor Julien [Thu, 9 Aug 2018 11:45:04 +0000 (13:45 +0200)] 
detect: don't setup PMATCH if it will be unused

Safes a bit of memory and makes it easier to debug.

7 years agodetect/analyzer: add Signature::flags
Victor Julien [Thu, 9 Aug 2018 11:10:38 +0000 (13:10 +0200)] 
detect/analyzer: add Signature::flags

7 years agodetect: remove STATE_MATCH flag use at runtime
Victor Julien [Thu, 9 Aug 2018 10:35:58 +0000 (12:35 +0200)] 
detect: remove STATE_MATCH flag use at runtime

Instead, use it only at init time and use Signature::app_inspect
directly at runtime.

7 years agodetect: cleanup direct SIG_FLAG_STATE_MATCH use
Victor Julien [Thu, 9 Aug 2018 09:51:07 +0000 (11:51 +0200)] 
detect: cleanup direct SIG_FLAG_STATE_MATCH use

This flag should normally not be set manually. It will be set by the
code registering the app engines in a signature.

7 years agodetect/dnp3: cleanup list and proto registration
Victor Julien [Thu, 9 Aug 2018 09:45:18 +0000 (11:45 +0200)] 
detect/dnp3: cleanup list and proto registration

7 years agodetect: remove SIG_FLAG_STATE_MATCH flag check
Victor Julien [Thu, 9 Aug 2018 09:32:00 +0000 (11:32 +0200)] 
detect: remove SIG_FLAG_STATE_MATCH flag check

It could not fail as before it the flag was already checked as a bail
out condition.

7 years agodetect: minor formatting fixups
Victor Julien [Thu, 9 Aug 2018 09:21:01 +0000 (11:21 +0200)] 
detect: minor formatting fixups

7 years agoflow: reduce structure size by removing gap
Victor Julien [Thu, 9 Aug 2018 09:14:33 +0000 (11:14 +0200)] 
flow: reduce structure size by removing gap

7 years agodetect/http: flush bodies when inspecting stream
Victor Julien [Wed, 8 Aug 2018 12:06:43 +0000 (14:06 +0200)] 
detect/http: flush bodies when inspecting stream

The HTTP bodies (http_client_body and http_server_body/file_data) use
settings to control how much data we have before doing first inspection:

    request-body-minimal-inspect-size
    response-body-minimal-inspect-size

These settings default to 32k as quite some existing rules need this.

At the same time, the 'raw stream' inspection uses its own limits. By
default it inspects the data in blocks of about 2.5k. This could lead
to a situation where rules would not match.

For example, with 2 rules like this:

    content:"abc"; content:"data="; http_client_body; depth:5; sid:1;
    content:"xyz"; sid:2;

Sid 1 would only be inspected when the POST body reached the 32k limit
or when it was complete. Observed case shows the POST body to be 18k.
Sid 2 is inspected as soon as the 2.5k limit is reached, and then again
for each 2.5k increment. This moves the raw stream tracker forward.

So by the time sid 1 is inspected, some 18/19k into the stream, the
raw stream tracker is actually already moved forward for approximately
17.5k, this leads to the stream match of sid 1 possibly not matching.
Since the body match is at the start of the buffer, it makes sense
that the body and stream are inspected together.

The body inspection uses a tracker 'body_inspected', that keeps track
of how far into the body both MPM and per signature inspection has
moved.

This patch updates the logic in 2 ways:

1. it triggers earlier HTTP body inspection, which is matched to the
   stream inspection. When the detection engine finds it has stream
   data available for inspection, it passes the new 'STREAM_FLUSH'
   flag to the HTTP body inspection code. Which will then do an
   early inspection, even if still before the min inspect size.

2. to still somewhat adhere to the min inspect size, the body
   tracker is not updated until the min inspect size is reached.
   This will lead to some re-evaluation of the same body data.

If raw stream reassembly is disabled, this 'STREAM_FLUSH' flag is
never set, and the old behavior is used.

Bug #2522.

7 years agostream: improve TCP CLOSED handling
Victor Julien [Mon, 30 Jul 2018 08:26:21 +0000 (10:26 +0200)] 
stream: improve TCP CLOSED handling

Trigger app layer reassembly in both directions as soon as we've set
the TCP state to closed.

In IDS mode, if a toserver packet would close the state, the app layer
would not get updated until the next toclient packet. However, in
detection, the raw stream inspection would already use all available
stream data in detection and move the 'raw stream progress' tracker
forward. When in later (a) packet(s) the app layer was updated and
inspection ran on the app layer, the stream progress was already
moved too far forward. This would lead to signatures that matched
on both stream and app layer to not match.

By triggering the app layer reassembly as soon as the TCP state is
set to closed, the inspection as both the stream and app layer data
available at the same time so these rules can match.

Bug: #2570
Bug: #2554

7 years agodetect: add debug statements to stream inspect
Victor Julien [Wed, 8 Aug 2018 05:04:09 +0000 (07:04 +0200)] 
detect: add debug statements to stream inspect

7 years agoproto/detect: add debug info
Victor Julien [Wed, 8 Aug 2018 05:03:25 +0000 (07:03 +0200)] 
proto/detect: add debug info

7 years agoflow: flag packets as established for async
Victor Julien [Tue, 7 Aug 2018 11:28:55 +0000 (13:28 +0200)] 
flow: flag packets as established for async

If a stream is async we see only on side of the traffic. This would
lead to the flow engine not flagging packets as 'established' even
if the flow state was in fact established. The flow was tagged as
such by the TCP engine.

This patch considers the flow state for setting the packet flag.

Bug #2491.

7 years agorust/smb: implement stream-depth, unlimited by default
Victor Julien [Tue, 7 Aug 2018 08:57:49 +0000 (10:57 +0200)] 
rust/smb: implement stream-depth, unlimited by default

7 years agostream-tcp: fix typo in debug message
Eric Leblond [Tue, 12 Jun 2018 16:59:46 +0000 (18:59 +0200)] 
stream-tcp: fix typo in debug message

7 years agoapp-layer-htp: close file with TRUNCATE state
Giuseppe Longo [Mon, 12 Mar 2018 11:41:35 +0000 (12:41 +0100)] 
app-layer-htp: close file with TRUNCATE state

When a file in TOSERVER direction is being stored and
libhtp or stream depth limit is reached,
it will be closed by HTPCallbackRequest without setting
any flags so the file state will be set to CLOSED
instead of TRUNCATED.

7 years agoapp-layer-parser: split registration flags
Victor Julien [Tue, 7 Aug 2018 08:19:02 +0000 (10:19 +0200)] 
app-layer-parser: split registration flags

7 years agoapp-layer-parser: don't overwrite stream_depth value
Giuseppe Longo [Thu, 18 Jan 2018 11:49:53 +0000 (12:49 +0100)] 
app-layer-parser: don't overwrite stream_depth value

When an app-layer parser is enabled, it could set its
own stream_depth value calling the API AppLayerParserSetStreamDepth.

Then, the function AppLayerParserPostStreamSetup will replace
the stream_depth value already set with stream_config.reassembly_depth.

To avoid overwriting, in AppLayerParserSetStreamDepth API a flag
will be set internally to specify that a value is already set.

7 years agodoc: update multi-tentant for device feature 3447/head
Victor Julien [Wed, 31 May 2017 07:55:33 +0000 (09:55 +0200)] 
doc: update multi-tentant for device feature

7 years agomulti-tenant: introduce device selector
Victor Julien [Wed, 31 May 2017 07:33:16 +0000 (09:33 +0200)] 
multi-tenant: introduce device selector

Add device to tenant mapping support:

  mappings:
  - device: ens5f0
    tenant-id: 1
  - device: ens5f1
    tenant-id: 23

Implemented by assigning the tenant id to the 'livedev', which means
it's only supported for capture methods that use the livedev API.

It's also currently not supported for IPS. In a case like 'eth0 -> eth1'
it's unclear which tenant should be used for the return traffic in a
flow, where the incoming device is 'eth1'.

7 years agorust/dhcp: free events and destate at tx end 3446/head
Victor Julien [Mon, 6 Aug 2018 10:08:20 +0000 (12:08 +0200)] 
rust/dhcp: free events and destate at tx end

7 years agodecode: set pktlen of decode handler to uint32
Maurizio Abba [Tue, 16 Jan 2018 16:53:51 +0000 (16:53 +0000)] 
decode: set pktlen of decode handler to uint32

Change the decode handler signature to increase the size of its decode
handler, from uint16 to uint32. This is necessary to let suricata use
interfaces with mtu > 65535 (ex: lo interface has default size 65536).

It's necessary to change several primitive for Packet manipulation, to
unify the parameter "packet length" whenever we are before IP decoding.

Add tests before calling DecodeIPVX function to avoid a possible
integer overflow over the len parameter.