]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
3 years agoutil/lua-common: use lua_pushnumber for SCFileInfo 6412/head
Juliana Fajardini [Thu, 16 Sep 2021 13:48:09 +0000 (14:48 +0100)] 
util/lua-common: use lua_pushnumber for SCFileInfo

(cherry picked from commit b3f447a0df0d389184febc06dc7445ddcae940e2)

3 years agoutil/lua-common: use pushinteger w/ byte & pkt cnt
Juliana Fajardini [Tue, 7 Sep 2021 09:37:19 +0000 (10:37 +0100)] 
util/lua-common: use pushinteger w/ byte & pkt cnt

LuaCallbackStatsPushToStackFromFlow tuple is composed of integer values
not all of them had been converted to lua_pushinteger yet.

(cherry picked from commit 8b53468d32e5b14817a41c6b0656cd3569a87749)

3 years agoutil/lua-common: update copyright year
Juliana Fajardini [Mon, 26 Jul 2021 14:35:40 +0000 (15:35 +0100)] 
util/lua-common: update copyright year

(cherry picked from commit 82cd125c62ac349c529582455eae19455fe2d50f)

3 years agoutil-lua-common: use lua_pushinteger w/ int values
Juliana Fajardini [Mon, 26 Jul 2021 12:24:02 +0000 (13:24 +0100)] 
util-lua-common: use lua_pushinteger w/ int values

replace lua_pushnumber with lua_pushinteger for SCFlowStats and
SCRuleIds.

(cherry picked from commit 9b6ce274877ca825dbcbda0a7e540660004b5390)

3 years agolua/output: fix typo
Juliana Fajardini [Thu, 22 Jul 2021 19:58:01 +0000 (20:58 +0100)] 
lua/output: fix typo

(cherry picked from commit 00d7a152eb730158be4840d224430bd0331e8ec6)

3 years agolua: use pushinteger for int in flow/packet tuples
Juliana Fajardini [Mon, 5 Jul 2021 11:18:41 +0000 (12:18 +0100)] 
lua: use pushinteger for int in flow/packet tuples

(cherry picked from commit 7592a9be433b9decba1c40928e6840d0a5071ace)

3 years agodoc/lua-functions: add sha items to SCFileInfo doc
Juliana Fajardini [Tue, 14 Sep 2021 09:04:38 +0000 (10:04 +0100)] 
doc/lua-functions: add sha items to SCFileInfo doc

(cherry picked from commit 751906b71d95380e64779f569b08195d6f388a2e)

3 years agodetect: fix multi-inspect buffer issue
Jeff Lucovsky [Sat, 18 Sep 2021 14:17:28 +0000 (10:17 -0400)] 
detect: fix multi-inspect buffer issue

Fix multi-inspect buffer issue caused by setting up for multi but not
using it for inspection.

3 years agoutil/lua-common: fix SCFileInfo bug & doc comment
Juliana Fajardini [Tue, 14 Sep 2021 08:49:07 +0000 (09:49 +0100)] 
util/lua-common: fix SCFileInfo bug & doc comment

The callback for FileInfo was returning the wrong value, resulting
in loss of some tuple values for one calling SCFileInfo in a script.

The documentation comment wasn't mentioning the sha items that are
pushed.

(cherry picked from commit 1315cb793b884140b51e9934ebbdc7493be22db5)

3 years agoci: rebase specified s-v pr
Philippe Antoine [Mon, 5 Jul 2021 14:37:03 +0000 (16:37 +0200)] 
ci: rebase specified s-v pr

So that CI does not fail, if suricata PR got upgraded in a new
version, but S-V PR did not get upgraded, and S-V changed
in master

(cherry picked from commit 3e81d20a71deb2a061d3f86430b88b8bdd4b7d6d)

3 years agoci: dummy git configuration for rebase
Philippe Antoine [Fri, 27 Aug 2021 15:36:50 +0000 (17:36 +0200)] 
ci: dummy git configuration for rebase

(cherry picked from commit 7fa3e8df615215a1628fc1e37f4913d93ced3a92)

3 years agoapp-layer/pd: review bailout conditions
Philippe Antoine [Wed, 9 Jun 2021 10:09:23 +0000 (12:09 +0200)] 
app-layer/pd: review bailout conditions

To take TCP window into account
And to actually bail out if we received too much data
where the limit is configured by stream.reassembly.depth

(cherry picked from commit f77b027ada0436855109f422bfa4d491dba846c7)

3 years agoapp-layer/pd: only consider actual available data
Victor Julien [Wed, 21 Apr 2021 13:20:49 +0000 (15:20 +0200)] 
app-layer/pd: only consider actual available data

For size limit checks consider only available data at the stream start
and before any GAPS.

The old check would consider too much data if there were temporary gaps,
like when a data packet was in-window but (far) ahead of the expected
segment.

(cherry picked from commit 7a114e506a27fcb2a3b5ed28b1c10fe100cf78c6)

3 years agostreaming/buffer: account sbb data size
Victor Julien [Fri, 4 Jun 2021 13:31:33 +0000 (15:31 +0200)] 
streaming/buffer: account sbb data size

When tracking data track the size of the blocks so that in case
of gaps we can still know how much data we hold.

(cherry picked from commit be1baa8cab1bc51228d2d882b15880a36c377be4)

3 years agodnp3: regenerate object decoding code
Philippe Antoine [Thu, 8 Jul 2021 13:02:50 +0000 (15:02 +0200)] 
dnp3: regenerate object decoding code

Ticket: #4558
So as to avoid intra-structure overflow

(cherry picked from commit 44bd3169eb1ab0501d909fe261b3dafde6375400)

3 years agodnp3: adds bounds check for prefix chararray
Philippe Antoine [Thu, 8 Jul 2021 13:01:15 +0000 (15:01 +0200)] 
dnp3: adds bounds check for prefix chararray

Ticket: #4558
Avoids intra structure overflow

(cherry picked from commit 126a7dcb4f1818a806c882c54da864992bb304d5)

3 years agodnp3: use base64 macro in gen script
Philippe Antoine [Thu, 8 Jul 2021 12:57:56 +0000 (14:57 +0200)] 
dnp3: use base64 macro in gen script

As is done already in C
cf commit ea0936199d142fc52ec69baf7984cbdd92dd4705

(cherry picked from commit 5ec9688f03eb611b8ec3108a4f20db2baf87b225)

3 years agocounters: only print alerts if stats are enabled
Shivani Bhardwaj [Mon, 21 Jun 2021 18:35:06 +0000 (00:05 +0530)] 
counters: only print alerts if stats are enabled

(cherry picked from commit a17da8374a905ad31a4fa66f85ee1cc73b857389)

3 years agothreading: respect SC_MAX_CPUS envvar 6373/head
Victor Julien [Sat, 11 Sep 2021 13:43:29 +0000 (15:43 +0200)] 
threading: respect SC_MAX_CPUS envvar

3 years agogithub-ci: run suricata-verify in quiet mode 6370/head
Jason Ish [Fri, 10 Sep 2021 16:49:42 +0000 (10:49 -0600)] 
github-ci: run suricata-verify in quiet mode

Makes it easier to pick out the failing tests.

3 years agogithub-ci: prepare cbindgen in its own job
Jason Ish [Fri, 10 Sep 2021 16:14:47 +0000 (10:14 -0600)] 
github-ci: prepare cbindgen in its own job

We already do this in master. For 5.0.x it should clear up any
issues where our MSRV isn't suitable to build cbindgen.

3 years agoipv6: decoder event on invalid length
Philippe Antoine [Mon, 19 Jul 2021 15:31:32 +0000 (17:31 +0200)] 
ipv6: decoder event on invalid length

From RFC 2460, section 4.5,
each fragment, except the last one, must have a length
which is a multiple of 8

(cherry picked from commit ca760e305cd74933b685b1bd5be795b24a7d94a7)

4 years agorelease: 5.0.7; update changelog; require htp 0.5.38 suricata-5.0.7
Jason Ish [Wed, 30 Jun 2021 14:26:14 +0000 (08:26 -0600)] 
release: 5.0.7; update changelog; require htp 0.5.38

4 years agoswf: right input length for decompression
Philippe Antoine [Thu, 29 Apr 2021 09:57:15 +0000 (11:57 +0200)] 
swf: right input length for decompression

(cherry picked from commit 4d2f9cc8a0409bb03f5d285bb83d64afec08ba2a)

4 years agoikev2: remove transforms fields
Shivani Bhardwaj [Fri, 25 Jun 2021 10:29:31 +0000 (15:59 +0530)] 
ikev2: remove transforms fields

4 years agorust: SCLogDebug is real nop when built as release
Philippe Antoine [Thu, 6 May 2021 11:30:49 +0000 (13:30 +0200)] 
rust: SCLogDebug is real nop when built as release

Before, even if there were no outputs, all the arguments
were evaluated, which could turn expensive

All variables which are used only in certain build configurations
are now prefixed by underscore to avoid warnings

(cherry picked from commit ef5755338fa6404b60e7f90bfbaca039b2bfda1e)

4 years agosmtp: null terminate before calling strtoul
Philippe Antoine [Thu, 22 Apr 2021 08:28:15 +0000 (10:28 +0200)] 
smtp: null terminate before calling strtoul

by copying in a temporary buffer
as is done in ByteExtractString

(cherry picked from commit 33fa7ab5969d3fc5ca088c003bd4dbfe76d77b6b)

4 years agostream/tcp: avoid evasion linked to ACK handling
Eric Leblond [Fri, 28 May 2021 09:38:18 +0000 (11:38 +0200)] 
stream/tcp: avoid evasion linked to ACK handling

Actual code will completely discard TCP analysis of a packet that
don't have the ACK bit set but have a ACK value set. This will be
for example the case of all SYN packets that have a ACK value.

Problem is that these type of packets are legit for the operating
systems and for the RFC. The consequence is that an attacker
sending a SYN packet with a non null ACK value will open succesfully
a TCP session to its target and this session will have no protocol
discovery, no TCP streaming and no application layer analysis.
Result is  a quasi full evasion of the TCP stream that will only
appear in the flow log if this log is enable or alert on tcp-pkt
signature that are uncommon.

The patch is updating the code to only discard packets that do not
have the SYN flag set. This prevents the evasion and complies with the
RFC that states that the ACK bit should always be set once the
TCP session is established.

This addresses CVE-2021-35063.

Fixes: fa692df37 ("stream: reject broken ACK packets")
Bug: #4513.

4 years agodetect: track base id for xform buffers
Victor Julien [Thu, 25 Feb 2021 19:06:40 +0000 (20:06 +0100)] 
detect: track base id for xform buffers

Buffers with transforms are based on the non-transformed "base"
buffer, with a new ID assigned and the transform callbacks added.

This patch stores the id of the original buffer in the new buffer
inspect and prefilter structures. This way the buffers with and
without transforms can share some of the logic are progression
of file and body inspection trackers.

Related tickets: #4361 #4199 #3616

(cherry picked from commit 975062cf401f79c00abf728d923c65aabd143af2)

4 years agodetect/file.data: fix mixing transforms (file api)
Victor Julien [Thu, 25 Feb 2021 19:07:41 +0000 (20:07 +0100)] 
detect/file.data: fix mixing transforms (file api)

Fix handling of file progress tracking for regular file.data along
with transform combinations for the part of the implementation that
uses the File API.

This is done by implementing the 'base id' logic.

Related tickets: #4361 #4199 #3616

(cherry picked from commit 54ad7de9cea22b9a3c3e7cc64145155126f4dada)

4 years agodetect: fix multi inspect buffer issue; clean up
Victor Julien [Thu, 13 May 2021 05:50:12 +0000 (07:50 +0200)] 
detect: fix multi inspect buffer issue; clean up

Fix multi inspect buffer API causing cleanup logic in the single
inspect buffer paths. This could lead to a buffer overrun in the
"to clear" logic.

Multi buffers now use InspectionBufferSetupMulti instead of
InspectionBuffer. This is enforced by a check in debug validation.

Simplify the multi inspect buffer setup code and update the callers.

(cherry picked from commit 3dc50322db0efb92683b9578c7dccd1fae4b5cb2)

4 years agodetect: set event if max inspect buffers exceeded
Victor Julien [Thu, 13 May 2021 06:06:11 +0000 (08:06 +0200)] 
detect: set event if max inspect buffers exceeded

If a parser exceeds 1024 buffers we stop processing them and
set a detect event instead. This is to avoid parser bugs as well as
crafted bad traffic leading to resources starvation due to excessive
loops.

(cherry picked from commit e611adf3dc5b531a9d0ef9b861b4dbe0e150eae6)

4 years agodoc: update sphinx api to use add_css_file
Philippe Antoine [Mon, 17 May 2021 14:27:49 +0000 (16:27 +0200)] 
doc: update sphinx api to use add_css_file

instead of deprecated add_stylesheet

(cherry picked from commit 95f225e8fbd5d352a8ca86cd317f908034966ed4)

4 years agomodbus: fix memory leak in signature parsing 6223/head
Philippe Antoine [Tue, 22 Jun 2021 06:16:40 +0000 (08:16 +0200)] 
modbus: fix memory leak in signature parsing

Bug: #4538.

4 years agorules/decoder-events: fix duplicate sid
Corey Thomas [Tue, 2 Mar 2021 16:16:21 +0000 (11:16 -0500)] 
rules/decoder-events: fix duplicate sid

4 years agoftp: completely parses pasv and epsv responses 6174/head
Philippe Antoine [Tue, 27 Apr 2021 07:03:45 +0000 (09:03 +0200)] 
ftp: completely parses pasv and epsv responses

(cherry picked from commit ca6e434e0b84dc8478763dc0a8716c5e3686a99a)

4 years agounix-socket: reset to ready state on startup
Jason Ish [Thu, 25 Feb 2021 17:16:28 +0000 (11:16 -0600)] 
unix-socket: reset to ready state on startup

As part of commit ea15282f47c6ff781533e3a063f9c903dd6f1afb,
some initialization was moved to happen even in unix socket mode,
however, this initialization does setup some loggers that can only have
one instance enabled (anomaly, drop, file-store).

This will cause these loggers to error out on the first pcap, but work
on subsequent runs of the pcap as some deinitialization is done after
each pcap.

This fix just runs the post pcap-file deinitialization routine to
reset some of the initialization done on startup, like is done after
running each pcap in unix socket mode.

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

Additionally this prevents alerts from being logged two times
on the first run of a pcap through the unix socket:

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

(cherry picked from commit 488d5fb34284f7e5be760edeca7607209cfa4b5e)

4 years agodetect/prefilter: fix null ptr deref on invalid rule 6100/head
Victor Julien [Wed, 3 Mar 2021 12:41:26 +0000 (13:41 +0100)] 
detect/prefilter: fix null ptr deref on invalid rule

A bad rule 'icode:<0; prefilter;' would trigger a null ptr deref
in ApplyToU8Hash.

Bug #4375.

(cherry picked from commit 7d6835958bbb6ddf2931c9e20f409eadfc8ca068)

4 years agoeve/drop: use highest priority drop
Victor Julien [Fri, 12 Mar 2021 09:22:01 +0000 (10:22 +0100)] 
eve/drop: use highest priority drop

When adding the alert to a drop record make sure the add the highest
priority.

It would until now add all drops from high to low prio, effectively
overwriting the record each time.

Ticket #4397

(cherry picked from commit 398ebf934509a8d27a1c8b858eae061b89d5c44a)

4 years agodetect/alert: apply pd only actions to flow
Victor Julien [Wed, 10 Mar 2021 12:25:55 +0000 (13:25 +0100)] 
detect/alert: apply pd only actions to flow

Ticket #4394

(cherry picked from commit 6cf44fc839e8f1da820095928b5b25e7fc0a8521)

4 years agodetect/alert: minor code refactor
Victor Julien [Tue, 9 Mar 2021 19:56:14 +0000 (20:56 +0100)] 
detect/alert: minor code refactor

Use a simpler reject check and move logic into util func.

(cherry picked from commit 6c594d29db55bb0d6f28f0a5fa758c3e00a86ca1)

4 years agodetect/iponly: don't check & set flow flags twice
Victor Julien [Tue, 9 Mar 2021 15:25:14 +0000 (16:25 +0100)] 
detect/iponly: don't check & set flow flags twice

Per flow IP-only flags are checked and set by IP-only engine, so
no need to set/check them per alert.

(cherry picked from commit fbcdd2ec267d49040ca178f8562767d8fb00aa73)

4 years agokerberos: fix probing parser tag condition
Philippe Antoine [Thu, 11 Mar 2021 15:12:36 +0000 (16:12 +0100)] 
kerberos: fix probing parser tag condition

according to the comment

(cherry picked from commit cb150e97d09baea09a738388426eafad3cccff2a)

4 years agogeneral: Typo cleanup
Jeff Lucovsky [Mon, 29 Mar 2021 12:33:02 +0000 (08:33 -0400)] 
general: Typo cleanup

(cherry picked from commit 2893b04ab014c4dcc0bfc4c6f9dbf83fd44717a1)

4 years agodetect/threshold: Improve threshold.config perf
Jeff Lucovsky [Mon, 29 Mar 2021 12:30:59 +0000 (08:30 -0400)] 
detect/threshold: Improve threshold.config perf

This commit improves performance when parsing threshold.config by
removing a loop-invariant to create a one-time object with the parsed
address(es).

Then, as needed, copies of this object are made as the suppression
rule(s) are processed.

(cherry picked from commit 02ceac8b8d4473de5f373a4785a1c143778b06e1)

4 years agodetect/threshold: Function to deep-copy thresh obj
Jeff Lucovsky [Mon, 29 Mar 2021 12:28:50 +0000 (08:28 -0400)] 
detect/threshold: Function to deep-copy thresh obj

This commit adds a function to make a deep copy of a DetectThresholdData
object.

The function is used when parsing threshold.config items to make a
one-time object and then add copies as needed.

(cherry picked from commit e873632a2811be4cd370336d43fcc5619bcd28e2)

4 years agodetect/address: Expose DetectAddressCopy function
Jeff Lucovsky [Mon, 29 Mar 2021 12:26:40 +0000 (08:26 -0400)] 
detect/address: Expose DetectAddressCopy function

(cherry picked from commit 11f9cc6524958d11b6d9ab1f0785bfe16237096f)

4 years agoflow/bypass: Properly set the ICMP emergency-bypassed value
Luke Coughlan [Mon, 26 Apr 2021 12:05:15 +0000 (13:05 +0100)] 
flow/bypass: Properly set the ICMP emergency-bypassed value

Currently the ICMP emergency-bypassed value defined in suricata.conf is
overwriting the UDP value rather than correctly setting it for ICMP.
This commit corrects this bug so that the ICMP value can be set as
expected.

(cherry picked from commit 7fb56a9075a97cd9781d08efd0f949b0bfca2719)

4 years agoftp: fixes leak with duplicate expectation
Philippe Antoine [Thu, 8 Apr 2021 15:44:01 +0000 (17:44 +0200)] 
ftp: fixes leak with duplicate expectation

(cherry picked from commit 68d6922e3cc47c2608e1ac3614c6bd3a48185a12)

4 years agorelease: 5.0.6; update changelog; require htp 0.5.37 suricata-5.0.6
Victor Julien [Mon, 1 Mar 2021 13:30:41 +0000 (14:30 +0100)] 
release: 5.0.6; update changelog; require htp 0.5.37

4 years agoapp-layer: fix transaction cleanup
Victor Julien [Mon, 1 Feb 2021 21:23:47 +0000 (22:23 +0100)] 
app-layer: fix transaction cleanup

Fix a 'skipped' transaction early in the list leading to all further
transactions getting skipped, even if they were fully processed and
ready to be cleaned up.

(cherry picked from commit 8baef60d600c5254662633d8275f321a6dafb82c)

4 years agodetect/prefilter: fix handling of prefilter as fast_pattern alias
Victor Julien [Sat, 20 Feb 2021 14:53:51 +0000 (15:53 +0100)] 
detect/prefilter: fix handling of prefilter as fast_pattern alias

(cherry picked from commit 0dd5921bc9791ac733c8d264212d69e661309df1)

4 years agoclassification: sync and update
Victor Julien [Wed, 24 Feb 2021 15:30:13 +0000 (16:30 +0100)] 
classification: sync and update

Sync to latest ET open and introduce inappropriate as a classification
to replace something some find inappropriate.

(cherry picked from commit f037f6f4ff08ed0442b3bbc1623dfb7ecb23c716)

4 years agosmb: relax probing parser to handle first NBSS message
Philippe Antoine [Wed, 17 Feb 2021 14:36:12 +0000 (15:36 +0100)] 
smb: relax probing parser to handle first NBSS message

cf dcerpc-udp S-V test :
First message is Message Type: Session request (0x81)
Second message is SMB

(cherry picked from commit 83070102557d2755b9ffc67bb14b9b4d48b039e9)

4 years agodetect: fix overflows in SetupU8Hash
Philippe Antoine [Wed, 17 Feb 2021 16:02:35 +0000 (17:02 +0100)] 
detect: fix overflows in SetupU8Hash

For instance ">255" resulted in overflow

(cherry picked from commit 2d765d6c686449e78e29759b07c4852ebab3c46e)

4 years agomodbus: stop allocating transactions when flooded
Philippe Antoine [Thu, 17 Dec 2020 20:48:54 +0000 (21:48 +0100)] 
modbus: stop allocating transactions when flooded

cf #4224

(cherry picked from commit 89030d3e59e23d4850ac9a7db5763c3d4d4fd537)

4 years agossl: reset state when breaking out of SSLV3_HANDSHAKE_PROTOCOL
Philippe Antoine [Fri, 18 Dec 2020 21:12:23 +0000 (22:12 +0100)] 
ssl: reset state when breaking out of SSLV3_HANDSHAKE_PROTOCOL

So that we cannot resumt it with corrupted values

(cherry picked from commit eb460cf78dadc874633a57571245acf2911a6b6e)

4 years agodetect: forbids unsupported prefilters
Philippe Antoine [Sun, 7 Feb 2021 20:34:12 +0000 (21:34 +0100)] 
detect: forbids unsupported prefilters

(cherry picked from commit b7fd01c86e0d0f3c341031d62ec89e305859aa0b)

4 years agodecode: limits the number of decoded layers
Philippe Antoine [Thu, 28 Jan 2021 16:48:48 +0000 (17:48 +0100)] 
decode: limits the number of decoded layers

so as to avoid overrecursion leading to stack exhaustion

(cherry picked from commit 7500c29300dcef8716d87461842e7d7c3e5101ac)

4 years agofilestore: fix global counter init in unix socket mode
Jason Ish [Fri, 18 Dec 2020 17:34:30 +0000 (11:34 -0600)] 
filestore: fix global counter init in unix socket mode

Move initialization of filestore global counter to PreRunInit,
so they get registered during program initialization, or as
required in unix-socket mode, initialized for each file run.

Fixes Redmine issue:
https://redmine.openinfosecfoundation.org/issues/4216

(cherry picked from commit 0aed5e188b214d56107e66ea8e38dfb7d5a13758)

4 years agogithub-ci: use suricata-update master-1.1.x branch
Jason Ish [Wed, 24 Feb 2021 22:53:06 +0000 (16:53 -0600)] 
github-ci: use suricata-update master-1.1.x branch

Suricata 5.0.x tracks the Suricata-Update 1.1.x branch.

4 years agostream/tcp: fix stream side after direction change 5912/head
Ilya Bakhtin [Tue, 28 Jul 2020 14:33:23 +0000 (16:33 +0200)] 
stream/tcp: fix stream side after direction change

(cherry picked from commit 1ecea0f44c0050feb57c6b26a5a94c8ad8f1b85d)

4 years agohttp: makes decompression time limit configurable
Philippe Antoine [Wed, 17 Feb 2021 08:37:57 +0000 (09:37 +0100)] 
http: makes decompression time limit configurable

(cherry picked from commit a04b5566a62d9d6967587f83dfaca89b5c33eb66)

4 years agoprotodetect: improve midstream handling 5895/head
Ilya Bakhtin [Mon, 15 Feb 2021 17:36:46 +0000 (18:36 +0100)] 
protodetect: improve midstream handling

Set "done flag" only if parsers for both directions are not found in a
case of midstream parsers from other direction are tried if nothing is found
for the initial one. "done flag" must be set if nothing is found in both
directions. Otherwise processing of incomplete data is terminated at the very
first try.

(cherry picked from commit 5285163d8f31dc89a4ab96b0842099f9792e29be)

4 years agotcp: remove debug asserts about large windows 5890/head
Philippe Antoine [Wed, 17 Feb 2021 14:43:17 +0000 (15:43 +0100)] 
tcp: remove debug asserts about large windows

Completes 00d7c9034be7470177c01e8805831c258b016d0e

(cherry picked from commit 7264f58f2cbf266ba44efd32c5031b692b57967d)

4 years agodetct/pcre: Correct capture group count check 5887/head
Jeff Lucovsky [Mon, 8 Feb 2021 13:05:41 +0000 (08:05 -0500)] 
detct/pcre: Correct capture group count check

This commit corrects the validation check between the number of
variables used and the number of specified capture groups.

(cherry picked from commit 469d5bb214195d8939be467c66ef1e6d25ad3e1f)

4 years agoalert/syslog: fix minor compile warning 5867/head
Victor Julien [Thu, 22 Oct 2020 14:10:14 +0000 (16:10 +0200)] 
alert/syslog: fix minor compile warning

(cherry picked from commit 62cc0c7acf2270d63e0e164d9e39f47b811e1fb3)

4 years agoproto/names: add SCTP if not defined in system
Victor Julien [Mon, 18 Jan 2021 12:56:32 +0000 (13:56 +0100)] 
proto/names: add SCTP if not defined in system

If SCTP is missing from /etc/protocols, add it manually.

(cherry picked from commit bf00285d0acf87c794f6569eb51d1f7d1247a0da)

4 years agohost: improve compare logic
Victor Julien [Sat, 13 Feb 2021 16:10:15 +0000 (17:10 +0100)] 
host: improve compare logic

The old compare macro would compare all bytes of an address, even
when for IPv4 addresses the additional bytes were not in use. This
made the logic vulnerable to mistakes like in issue #4280.

(cherry picked from commit 6bfc5afa2301cc416e2fced23ec1accdfdea0daf)

4 years agodetect/iprep: fix loading of mixed ipv4/ipv6 lists 5864/head
Victor Julien [Sat, 13 Feb 2021 15:54:56 +0000 (16:54 +0100)] 
detect/iprep: fix loading of mixed ipv4/ipv6 lists

Improper reuse of the address data structure between loading
different lines in the iprep file would lead to the host using
a malformed address.

(cherry picked from commit 7b03e6837e5a7366f546e7a2b681d2921ded1ab1)

4 years agosuricata: avoid at exit crash in nfq mode
Eric Leblond [Sun, 24 Jan 2021 21:40:02 +0000 (22:40 +0100)] 
suricata: avoid at exit crash in nfq mode

When Suricata was build with ebpf support and when it was started
in NFQ mode, it was crashing at exit because it was trying to free
the device extension.

This patch fixes the issue by only trigger the eBPF related code
when Suricata is running in AFP_PACKET mode.

(cherry picked from commit 85327890f5bb3b9521a2dfb8268ace6645d02f72)

4 years agodataset: fix dataset string lookup
Eric Leblond [Wed, 20 Jan 2021 20:17:04 +0000 (21:17 +0100)] 
dataset: fix dataset string lookup

The data was unlocked but the use_cnt was not decreased resulting
in the data entry not being removable.

(cherry picked from commit 64f994f753b9109c8f788e3a6dbe4c72f6e69d94)

4 years agodetect-fast-pattern: Mark as OPTIONAL_OPT, instead of NOOPT 5861/head
Gianni Tedesco [Sun, 13 Dec 2020 14:50:23 +0000 (23:50 +0900)] 
detect-fast-pattern: Mark as OPTIONAL_OPT, instead of NOOPT

Also update the erroneous comment about it.

(cherry picked from commit cebe15c23b48e92df5181b3f0b0e6ac7195d717b)

4 years agodetect: Validate that NOOPT options don't have optvals
Gianni Tedesco [Sun, 13 Dec 2020 14:54:13 +0000 (23:54 +0900)] 
detect: Validate that NOOPT options don't have optvals

Without this, a simple typo between : and ; is able to hide actual bugs
in rules.

I discovered 2 bugs in ET open ruleset this way.

(cherry picked from commit 10ea60a237cf41ddd10f7a887e2824b4b8e1c419)

4 years agodns: initialize log flags as an unsigned long long
Jason Ish [Mon, 7 Dec 2020 21:31:34 +0000 (15:31 -0600)] 
dns: initialize log flags as an unsigned long long

On 64 bit all 64 bits were being initialized, but on 32 bit
only 32 bits were as it was being initialized as a long.

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

(cherry picked from commit f2ab5803fbd88ae613429a382f28e81841832d0d)

4 years agogithub-ci: use python3 in debian builds
Jason Ish [Fri, 8 Jan 2021 16:32:47 +0000 (10:32 -0600)] 
github-ci: use python3 in debian builds

(cherry picked from commit 18a1fd22c2dfd0613b190a656574077c1230e309)

4 years agogithub-ci/macos: use brew to install Python 3
Jason Ish [Fri, 8 Jan 2021 15:39:19 +0000 (09:39 -0600)] 
github-ci/macos: use brew to install Python 3

The default Python on MacOS is Python 2. Suricata-Verify now
depends on Python 3, so install it with Brew.

(cherry picked from commit 7904ef82d0b2478694025ca0d9043f2ae98be73a)

4 years agorust/json: Rework scope for short-lived vars 5733/head
Jeff Lucovsky [Sat, 16 Jan 2021 14:34:20 +0000 (09:34 -0500)] 
rust/json: Rework scope for short-lived vars

This commit corrects scope issues identified during CI with
FC32/strict-rust:
"this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
"

4 years agorust: lock major versions of crates 5732/head
Victor Julien [Sat, 16 Jan 2021 09:17:35 +0000 (10:17 +0100)] 
rust: lock major versions of crates

4 years agorust: lock to byteorder ~1.3.4 to avoid MSRV bump
Victor Julien [Sat, 16 Jan 2021 08:59:31 +0000 (09:59 +0100)] 
rust: lock to byteorder ~1.3.4 to avoid MSRV bump

4 years agosignature: Fix leak in urilen parsing 5729/head
Philippe Antoine [Thu, 7 Jan 2021 08:46:02 +0000 (09:46 +0100)] 
signature: Fix leak in urilen parsing

cf #4254

(cherry picked from commit 47dd9a5ebc26dac25b63b5ca37062e7a63cd5335)

4 years agodetect/file.name: register inspect engine for ftp-data
Victor Julien [Mon, 11 Jan 2021 14:17:02 +0000 (15:17 +0100)] 
detect/file.name: register inspect engine for ftp-data

(cherry picked from commit 45eddde573ab2e807a5fa44170d544288a60ea12)

4 years agodecode/tcp: Improved handling of TFO options
Jeff Lucovsky [Tue, 5 Jan 2021 14:31:11 +0000 (09:31 -0500)] 
decode/tcp: Improved handling of TFO options

This commit improves handling of TCP fast open options
- Option length must be in [6, 18]
- Option length must be an even value

(cherry picked from commit f8fef0dd05e87c3bf25e4e5c0bcf136e94c98393)

4 years agostream/midstream: handle packet loss after SYN/ACK
Victor Julien [Tue, 29 Dec 2020 19:36:26 +0000 (20:36 +0100)] 
stream/midstream: handle packet loss after SYN/ACK

(cherry picked from commit db2dbaaf40a911200849b235d8408788fa379276)

4 years agostream/tcp: fix invalid ack events in timewait state
Victor Julien [Mon, 28 Dec 2020 18:18:08 +0000 (19:18 +0100)] 
stream/tcp: fix invalid ack events in timewait state

(cherry picked from commit 895938080f52db464faf8d971fd5b06bc139ad0a)

4 years agomime: postpone md5 calculation to parse complete
Jason Ish [Wed, 30 Dec 2020 19:32:53 +0000 (13:32 -0600)] 
mime: postpone md5 calculation to parse complete

Instead of calculating the MD5 at the end of every part, only
compute it when parsing is complete.

With libnss, the hash never updates after the first HASH_End, so
the md5 of only the first part of the body is logged, rather than
the md5 of all the parts.

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

4 years agoflow/timeout: fix TCP seq/ack for reversed flows 5680/head
Victor Julien [Wed, 23 Dec 2020 14:55:19 +0000 (15:55 +0100)] 
flow/timeout: fix TCP seq/ack for reversed flows

When a flow is swapped it also swaps the stream trackers, so it does
not make sense to reverse them during pseudo packet creation.

(cherry picked from commit 49bd1f85b99e8bd473ae28c6eb93510b2b3c7668)

4 years agodetect/stream: fix async stream inspection
Victor Julien [Thu, 17 Dec 2020 20:04:13 +0000 (21:04 +0100)] 
detect/stream: fix async stream inspection

Move raw progress forward only if detect uses stream data, indicated
by the PKT_DETECT_HAS_STREAMDATA flag.

(cherry picked from commit 3c7c361b603653a4c0bb30a4261babc45988d163)

4 years agostream/tcp: fix async mode ACK validation
Victor Julien [Thu, 17 Dec 2020 09:54:05 +0000 (10:54 +0100)] 
stream/tcp: fix async mode ACK validation

(cherry picked from commit 8aa02c6d15f013f9ce934e440ee073701d3ea502)

4 years agoversion: branch is going towards 5.0.6
Victor Julien [Tue, 15 Dec 2020 12:15:03 +0000 (13:15 +0100)] 
version: branch is going towards 5.0.6

4 years agoci: buildbot is decommissioned, so remove prscript refs 5663/head
Victor Julien [Fri, 11 Dec 2020 09:19:41 +0000 (10:19 +0100)] 
ci: buildbot is decommissioned, so remove prscript refs

(cherry picked from commit 372fc26739b414684ad0a7e25f444ceceb379173)

4 years agodoc: build all manpages
Sascha Steinbiss [Wed, 9 Dec 2020 17:34:49 +0000 (18:34 +0100)] 
doc: build all manpages

4 years agogithub-ci: fix centos 8 build
Jason Ish [Tue, 8 Dec 2020 15:34:52 +0000 (09:34 -0600)] 
github-ci: fix centos 8 build

The "PowerTools" repo that we need to enable has been renamed
to "powertools".

4 years agogithub-ci: use a unique id for the commit check cargo cache 5652/head
Jason Ish [Thu, 10 Dec 2020 15:48:06 +0000 (09:48 -0600)] 
github-ci: use a unique id for the commit check cargo cache

All builds have been using the same cache id for ~/.cargo which
could lead us to conflict situations which is what I think we are
seeing with the commit-check job.

(cherry picked from commit 49ca070446cdca49afc42d71aaedaa9a1b458897)

4 years agogithub-ci: Master CI improvements re: Travis CI 5631/head
Jason Ish [Wed, 12 Aug 2020 15:06:23 +0000 (09:06 -0600)] 
github-ci: Master CI improvements re: Travis CI

This is a squashed commit of the following items:

github-ci: Fedora 32 builder with asan enabled

Also enables -Wshadow and rust-strict to cover those cases
from Travis.

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

(cherry picked from commit c91b43a3fdf2e072f354c2082247b20804629b67)

github-ci: ubuntu 20.04 build without nss/nspr

Adds a test that builds and tests Suricata without nss/nspr
to replace the similar test on Travis-CI.

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

(cherry picked from commit 7ea2187f9191225cdab40d8fde49439c94824023)

github-ci: Ubuntu 20.4 build with -NDEBUG

To cover Travis-CI test that builds with -NDEBUG.

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

(cherry picked from commit 0dc6434e61e6a37c38f0ccda59ae56d714a2b268)

github-ci: enable debug on Fedora 32 build

(cherry picked from commit db0be04988d238d89c1a27cdc35dfcd1b0ab4a14)

github-ci: update debian 9 test to use known Rust version

Choose Rust 1.39.0 as a known version of Rust that we build against
to see in CI if we build with this version, but fail with latest.

This is to cover a similar test from Travis CI.

(cherry picked from commit 94ac702159f263bad6e480498ed894d8cb91be4a)

github-ci: add test build without jansson

This is to cover a test from Travis CI where we make sure
that ./configure fails if libjansson is not available.

(cherry picked from commit a35756e140bc48302cea55399a0cb09158d9cbc7)

github-ci: apply default CFLAGS to all builds

(cherry picked from commit b3a55a4cd5b291c66a79b6a56a49571152e5ba7f)

github-ci: Fixups for parity with master

rust: add doc target to build rust docs

Uses "cargo doc --no-deps" to build the documentation just for
our Suricata package. Without --no-deps, documentation will be
build for all our dependencies as well.

The generated documentation will end up in target/doc as HTML.

(cherry picked from commit 7ca24041b666bc9c9190a3c78d03d66b6ebebac6)

github-ci: CentOS 6 is EOL

(cherry picked from commit 3ea33f5e4756c9bdb5b9f0535b1acf46e392202b)

4 years agorelease: 5.0.5; update changelog; require htp 0.5.36 suricata-5.0.5
Victor Julien [Fri, 4 Dec 2020 07:00:40 +0000 (08:00 +0100)] 
release: 5.0.5; update changelog; require htp 0.5.36

4 years agoapp-layer: Remove errant validation BUG
Jeff Lucovsky [Wed, 2 Dec 2020 13:58:03 +0000 (08:58 -0500)] 
app-layer: Remove errant validation BUG

This commit removes an errant validation debug check brought into 5.0.x
mistakenly.

4 years agodnp3: regenerate dnp3 object decoders
Jason Ish [Thu, 3 Dec 2020 21:51:42 +0000 (15:51 -0600)] 
dnp3: regenerate dnp3 object decoders

4 years agoscript/dnp3-gen: update generator to reflect in tree changes
Jason Ish [Fri, 10 Jul 2020 19:19:35 +0000 (13:19 -0600)] 
script/dnp3-gen: update generator to reflect in tree changes

Some changes were made to the generated files instead of the
generator script. Update the script to generate what is
in the current state of the in-tree generated files.

(cherry picked from commit 4976afd96abf7b8dd49b444ee81df8091668f75e)

4 years agossl: upgarde to uint32 for bytes_processed
Philippe Antoine [Thu, 15 Oct 2020 19:32:27 +0000 (21:32 +0200)] 
ssl: upgarde to uint32 for bytes_processed

as it can overflow, and is compared with uint32 such as
message_length and message_start and