]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
3 years agohttp2: null check during upgrade 6465/head
Philippe Antoine [Mon, 23 Aug 2021 13:03:51 +0000 (15:03 +0200)] 
http2: null check during upgrade

(cherry picked from commit fa4c7626bde98f20700172984f7bd07c285406ba)

3 years agodnp3: regenerate object decoding code 6462/head
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 agossh: fix match on ssh banner
Shivani Bhardwaj [Fri, 8 Oct 2021 00:35:29 +0000 (06:05 +0530)] 
ssh: fix match on ssh banner

Default detection handling of SSH should not be to pass in case the
direction was not a match but to treat it like it was meant to server.

3 years agodetect: suppress error message for pcre only rules 6457/head
Victor Julien [Fri, 19 Feb 2021 10:45:00 +0000 (11:45 +0100)] 
detect: suppress error message for pcre only rules

(cherry picked from commit 9dd1444f4431731bf4917488e0abec0d9a46fdcc)

3 years agohttp2: better rust lifetimes 6453/head
Philippe Antoine [Tue, 7 Sep 2021 12:44:25 +0000 (14:44 +0200)] 
http2: better rust lifetimes

so that borrow check gets happy

(cherry picked from commit 56fae072b225d1c175116efe117c264afbdbf4a3)

3 years agohttp2: better rust style
Philippe Antoine [Fri, 4 Jun 2021 13:18:32 +0000 (15:18 +0200)] 
http2: better rust style

(cherry picked from commit 596a4a9d6edf43c73de85356b2e0cec3cb91e471)

3 years agohttp2: concatenate one headers multiple values
Philippe Antoine [Mon, 31 May 2021 14:17:22 +0000 (16:17 +0200)] 
http2: concatenate one headers multiple values

For detection, as is done with HTTP1

(cherry picked from commit 48ed874ddad4bbe7321191712263086f4567a5ab)

3 years agohttp2: generic http2_header_blocks
Philippe Antoine [Mon, 31 May 2021 09:40:42 +0000 (11:40 +0200)] 
http2: generic http2_header_blocks

so as not to forget continuation and push promise
when iterating over headers

(cherry picked from commit e3ff0e7731e8d652ee7f22945311674e65455a74)

3 years agohttp2: http.header keyword now works for HTTP2
Philippe Antoine [Mon, 31 May 2021 08:50:38 +0000 (10:50 +0200)] 
http2: http.header keyword now works for HTTP2

As well as http.header.raw

(cherry picked from commit 0b0649d98e07eb7dc8da60100c80fbcfe6cdd9e8)

3 years agohttp2: http.header_names keyword now works for HTTP2
Philippe Antoine [Mon, 31 May 2021 08:11:27 +0000 (10:11 +0200)] 
http2: http.header_names keyword now works for HTTP2

(cherry picked from commit 9b9f909d7db9ba4485bf50577868fa7072998487)

3 years agohttp2: http.host normalized keyword now works for HTTP2
Philippe Antoine [Wed, 26 May 2021 19:45:30 +0000 (21:45 +0200)] 
http2: http.host normalized keyword now works for HTTP2

(cherry picked from commit 547e9f4ab42fb4a67dc67f85fa58e0c9a7e4c634)

3 years agohttp2: turn Host header into authority during upgrade
Philippe Antoine [Wed, 26 May 2021 18:54:01 +0000 (20:54 +0200)] 
http2: turn Host header into authority during upgrade

HTTP1 uses Host, but HTTP2 uses rather :authority cf HPACK

(cherry picked from commit 75f75e1eb09c208a42e58b2babbc55027cd79e28)

3 years agogithub-ci: pin macos build to 10.15 6450/head
Jason Ish [Tue, 5 Oct 2021 16:44:03 +0000 (10:44 -0600)] 
github-ci: pin macos build to 10.15

There is currently a build failure with macos-latest (recently updated)
to 11 in the libhtp test suite code. Not sure if there are other
build issues in libhtp or Suricata at this time.

(cherry picked from commit 8b9721b2652790354e619c77622cf84c766915a3)

3 years agohttp2: do not try to upgrade if http2 is disabled in config 6443/head
Philippe Antoine [Wed, 15 Sep 2021 14:22:00 +0000 (16:22 +0200)] 
http2: do not try to upgrade if http2 is disabled in config

(cherry picked from commit 8536048443a30907ec4c96958374d782d7e656c6)

3 years agohttp2: flatten code style
Philippe Antoine [Wed, 15 Sep 2021 14:20:56 +0000 (16:20 +0200)] 
http2: flatten code style

(cherry picked from commit 42ba421ca975920bd753cbbf44a5bf9d118d4a3b)

3 years agoprotodetect: handle all gaps, even when depth is reached
Philippe Antoine [Mon, 23 Aug 2021 14:31:42 +0000 (16:31 +0200)] 
protodetect: handle all gaps, even when depth is reached

(cherry picked from commit 527415dba08f6f2af7fb93fdef19e3029cef88bd)

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 agoipv6: simpler generic overlap condition
Philippe Antoine [Fri, 10 Sep 2021 12:16:57 +0000 (14:16 +0200)] 
ipv6: simpler generic overlap condition

This also changes the behavior, as the condition is checked in
every case cf ipv6-malformed-fragments-8

(cherry picked from commit 3a230c2208046d001b386979663a6c565691794b)

3 years agoflow: free spare pool more aggressively
Victor Julien [Mon, 4 Oct 2021 14:01:47 +0000 (16:01 +0200)] 
flow: free spare pool more aggressively

The flows exceeding the spare pools config setting would be freed
per at max 100 flows a second. After a high speed test this would
lead to excessive memory use for a long time.

This patch updates the logic to free 10% of the excess flows per
run, freeing multiple blocks of flows as needed.

Bug: #4731.
(cherry picked from commit fa72a5add8d9ebdcc4da5e05a8cd4259ede572d7)

3 years agothreading: force break loop on flow inject
Victor Julien [Mon, 4 Oct 2021 07:24:51 +0000 (09:24 +0200)] 
threading: force break loop on flow inject

Track availability of break loop callback to avoid overhead.

(cherry picked from commit ff97d7c15da0a8a7b8ea1a0d461f4f56ca2052d6)

3 years agoflow: process evicted flows on low/no traffic
Victor Julien [Fri, 1 Oct 2021 11:20:02 +0000 (13:20 +0200)] 
flow: process evicted flows on low/no traffic

In a scenario where there was suddenly no more traffic flowing, flows
in a threads `flow_queue` would not be processed. The easiest way to
see this would be in a traffic replay scenario. After the replay is done
no more packets come in and these evicted flows got stuck.

In workers mode, the capture part handles timeout this was updated to
take the `ThreadVars::flow_queue` into account.

The autofp mode the logic that puts a flow into a threads `flow_queue`
would already wake a thread up, but the `flow_queue` was then ignored.
This has been updated to take the `flow_queue` into account.

In both cases a "capture timeout" packet is pushed through the pipeline
to "flush" the queues.

Bug: #4722.
(cherry picked from commit b788d3345cd4e4c467672bb6bfb90d2b8620e068)

3 years agothreading: minor cleanups
Victor Julien [Sun, 3 Oct 2021 12:54:17 +0000 (14:54 +0200)] 
threading: minor cleanups

(cherry picked from commit 31977170a8a44290fd8f501ef1018b7696644040)

3 years agodetect: track prefilter by progress, not engine 6416/head
Victor Julien [Tue, 14 Sep 2021 08:35:18 +0000 (10:35 +0200)] 
detect: track prefilter by progress, not engine

Fix FNs in case of too many prefilter engines. A transaction was tracking
which engines have run using a u64 bit array. The engines 'local_id' was
used to set and check this bit. However the bit checking code didn't
handle int types correctly, leading to an incorrect left shift result of
a u32 to a u64 bit value.

This commit addresses that by fixing the int handling, but also by
changing how the engines are tracked.

To avoid wasting prefilter engine tracking bit space, track what
ran by the progress they are registered at, instead of the individual
engine id's. While we can have many engines, the protocols use far
fewer unique progress values. So instead of tracking for dozens of
prefilter id's, we track for the handful of progress values.

To allow for this the engine array is sorted by tx_min_progress, then
app_proto and finally local_id. A new field is added to "know" when
the last relevant engine for a progress value is reached, so that we
can set the prefilter bit then.

A consquence is that the progress values have a ceiling now that
needs to fit in a 64 bit bitarray. The values used by parsers currently
does not exceed 5, so that seems to be ok.

Bug: #4685.
(cherry picked from commit 932cf0b6a6ad1d34fffe8dd92c14b5bc32c9f6fe)

3 years agodetect: unify alert handling; fix bugs
Victor Julien [Fri, 3 Sep 2021 15:04:02 +0000 (17:04 +0200)] 
detect: unify alert handling; fix bugs

Unify handling of signature matches between various rule types and
between noalert and regular rules.

"noalert" sigs are added to the alert queue initially, but removed
from it after handling their actions. This way all actions are applied
from a single place.

Make sure flow drop and pass are mutually exclusive.

The above addresses issue with pass and drops not getting applied
correctly in various cases.

Bug: #4663
Bug: #4670

(cherry picked from commit aa93984b7e58d3d8c1323f86bdaff937f8b8bd1e)

3 years agodetect: remove dead code
Victor Julien [Fri, 10 Sep 2021 08:19:50 +0000 (10:19 +0200)] 
detect: remove dead code

(cherry picked from commit ae89874b066c91675b809e8cf992d780331efb1c)

3 years agodns: improve probing parser 6411/head
Philippe Antoine [Tue, 9 Mar 2021 20:00:36 +0000 (21:00 +0100)] 
dns: improve probing parser

Checks opcode is valid
Checks additional_rr do not exceed message length
Better logic for incomplete cases

(cherry picked from commit 9e7ea631b2a067609c500539cd3a7a139f39c3e4)

3 years agonfs: improve probing parser
Philippe Antoine [Tue, 16 Mar 2021 12:07:16 +0000 (13:07 +0100)] 
nfs: improve probing parser

Checks credentials flavor is known

(cherry picked from commit b3c1f2ab489c22494900476426fd5cad9ba08cd1)

3 years agoenip: improve probing parser
Philippe Antoine [Tue, 9 Mar 2021 14:54:16 +0000 (15:54 +0100)] 
enip: improve probing parser

Strict length for register sessions
NOP command must have options=0

(cherry picked from commit 0c948142b93a2de0ede0a65e6ddb650f2a2239bc)

3 years agoutil/lua-common: use lua_pushnumber for SCFileInfo
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 6403/head
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 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 agohttp2: better file tracking 6392/head
Philippe Antoine [Thu, 2 Sep 2021 14:31:20 +0000 (16:31 +0200)] 
http2: better file tracking

If an HTTP2 file was within only ont DATA frame, the filetracker
would open it and close it in the same call, preventing the
firther call to incr_files_opened

Also includes rustfmt again for all HTTP2 files

(cherry picked from commit bb98a18b3d6d104d11a105aea3886d3daa5956cf)

3 years agoftp: support per-tx file accounting 6379/head
Victor Julien [Thu, 18 Mar 2021 12:47:26 +0000 (13:47 +0100)] 
ftp: support per-tx file accounting

(cherry picked from commit 04ba6dc1384410517a8450a47221e72d22fbc801)

3 years agosmb: add debug validation on file counts
Victor Julien [Thu, 18 Mar 2021 12:06:22 +0000 (13:06 +0100)] 
smb: add debug validation on file counts

(cherry picked from commit c9cee7af4985d569b34dc080be615b19eb5180a9)

3 years agosmb: count files in tx
Victor Julien [Thu, 18 Mar 2021 07:37:08 +0000 (08:37 +0100)] 
smb: count files in tx

(cherry picked from commit 114d3ba7307db7ab449bffae2c2dcb48e6b8f08d)

3 years agohttp2: support per-tx file accounting
Victor Julien [Thu, 18 Mar 2021 07:36:22 +0000 (08:36 +0100)] 
http2: support per-tx file accounting

(cherry picked from commit c1dfb619c4313f66322f89969e54c4ea01bbb9dc)

3 years agonfs: add debug validation on file counts
Victor Julien [Thu, 18 Mar 2021 12:06:34 +0000 (13:06 +0100)] 
nfs: add debug validation on file counts

(cherry picked from commit 1b3c3225cdc9d834d3a96aa239fb76b228859492)

3 years agonfs: support per-tx file accounting
Victor Julien [Thu, 18 Mar 2021 10:09:01 +0000 (11:09 +0100)] 
nfs: support per-tx file accounting

(cherry picked from commit 1d48601c258e944c1c3f9510b2707a6a2415a671)

3 years agonfs: don't reuse file transactions
Victor Julien [Thu, 18 Mar 2021 10:05:35 +0000 (11:05 +0100)] 
nfs: don't reuse file transactions

After a file has been closed (CLOSE, COMMIT command or EOF/SYNC part of
READ/WRITE data block) mark it as such so that new file commands on that
file do not reuse the transaction.

When a file transfer is completed it will be flagged as such and not be
found anymore by the NFSState::get_file_tx_by_handle() method. This forces
a new transaction to be created.

(cherry picked from commit 67759795c6405e449a80b282d290f84dc0fcd778)

3 years agohttp: support per-tx file accounting
Victor Julien [Thu, 18 Mar 2021 09:57:48 +0000 (10:57 +0100)] 
http: support per-tx file accounting

(cherry picked from commit d74c18ee28fbda3a5b6d2ddb157cae90b70da0bf)

3 years agofilestore: store chunks in packet direction
Victor Julien [Thu, 18 Mar 2021 13:38:33 +0000 (14:38 +0100)] 
filestore: store chunks in packet direction

Storing too early can lead to files being considered TRUNCATED if the
TCP state is not yet CLOSED when logging is triggered. This has been
observed with FTP-DATA and might also be an issue with simple HTTP.

(cherry picked from commit ca124b033ef408501897e0517eaf79d2196c68d9)

3 years agofilestore: track files getting stored per tx
Victor Julien [Tue, 23 Mar 2021 10:08:33 +0000 (11:08 +0100)] 
filestore: track files getting stored per tx

Avoid evicting a tx before the filedata logger has decided it is
done.

(cherry picked from commit 56d3e28a3a122178270e81b73783e0f126486232)

3 years agoapp-layer/transactions: track files opens and logs
Victor Julien [Thu, 18 Mar 2021 09:55:50 +0000 (10:55 +0100)] 
app-layer/transactions: track files opens and logs

To make sure a transaction is not evicted before all file logging is complete.

(cherry picked from commit c78f5ac3169e8b4539c49fde9d9aa8fa8465f40e)

3 years agoeve/files: log in packet direction only
Victor Julien [Thu, 18 Mar 2021 09:52:44 +0000 (10:52 +0100)] 
eve/files: log in packet direction only

Bug: #3703.

Don't log files too soon.

(cherry picked from commit 45dc4cdeece538c6f383b6658deca7dc1e825181)

3 years agorules: add newer rule files to makefile for release tarball 6363/head
Andreas Herz [Tue, 6 Apr 2021 15:29:03 +0000 (17:29 +0200)] 
rules: add newer rule files to makefile for release tarball

(cherry picked from commit c93073c246cfabb091270dba8eb55b0c6e17d67a)

3 years agostream: update memcaps in code to match config
Victor Julien [Thu, 1 Jul 2021 14:31:35 +0000 (16:31 +0200)] 
stream: update memcaps in code to match config

(cherry picked from commit b08a7b9a66d04f21241e8d1b75e0c6ff9ae69d8c)

3 years agohttp2: support deflate decompression 6348/head
Philippe Antoine [Mon, 5 Jul 2021 09:18:26 +0000 (11:18 +0200)] 
http2: support deflate decompression

cf #4556

(cherry picked from commit 1378b2f45144676d98f3430728dcca3e09540921)

3 years agohttp2: set Debug on structs
Victor Julien [Thu, 10 Jun 2021 19:03:31 +0000 (21:03 +0200)] 
http2: set Debug on structs

(cherry picked from commit 20e8f90981a1a0dca448b00c897c1c583513c25f)

3 years agohttp2: document HTTP1 keywords enabling 6344/head
Philippe Antoine [Mon, 5 Jul 2021 07:40:23 +0000 (09:40 +0200)] 
http2: document HTTP1 keywords enabling

For HTTP signatures to match on HTTP2 traffic if configure
option app-layer.protocols.http2.http1-rules is enabled

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)

3 years agorust: bump bitflags dependency version
Philippe Antoine [Sun, 28 Mar 2021 15:53:50 +0000 (17:53 +0200)] 
rust: bump bitflags dependency version

So that lexical-core, needed by nom, and using bitflags
is used with version 0.7.5 instead of version 0.7.0
which fixed the fact that BITS is now a reserved keyword
in nightly version

(cherry picked from commit 0105d4f017127f9696646e7d0176caec47a7c169)

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 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 agogithub-ci: enable hiredis on fedora 33 build
Jason Ish [Tue, 4 May 2021 21:47:53 +0000 (15:47 -0600)] 
github-ci: enable hiredis on fedora 33 build

(cherry picked from commit def636383ec2f917e3bdb20ee6619de226afca52)

3 years agoci: update known rust version
Simon Dugas [Mon, 1 Feb 2021 01:58:26 +0000 (20:58 -0500)] 
ci: update known rust version

Update RUST_VERSION_KNOWN to the latest stable known to succeed. Also
updates the documentation to avoid confusion around the use of this
variable.

(cherry picked from commit f629321de06043214e69a56d8259a1e781535293)

3 years agotravis: remove ci file as we switched to github-ci
Victor Julien [Tue, 4 May 2021 08:40:09 +0000 (10:40 +0200)] 
travis: remove ci file as we switched to github-ci

(cherry picked from commit 28548b072b8ebd3e40ec8e0c6b96ebb794522a96)

3 years agothreading: don't pass locked flow between threads
Victor Julien [Wed, 18 Aug 2021 18:14:48 +0000 (20:14 +0200)] 
threading: don't pass locked flow between threads

Previously the flow manager would share evicted flows with the workers
while keeping the flows mutex locked. This reduced the number of unlock/
lock cycles while there was guaranteed to be no contention.

This turns out to be undefined behavior. A lock is supposed to be locked
and unlocked from the same thread. It appears that FreeBSD is stricter on
this than Linux.

This patch addresses the issue by unlocking before handing a flow off
to another thread, and locking again from the new thread.

Issue was reported and largely analyzed by Bill Meeks.

Bug: #4478
(cherry picked from commit 9551cd05357925e8bec8e0030d5f98fd07f17839)

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 agomacset: adjust test to pass after fix
Victor Julien [Mon, 30 Aug 2021 19:56:24 +0000 (21:56 +0200)] 
macset: adjust test to pass after fix

(cherry picked from commit cd40fcdea710349bb998fbc4323c94394bf69c98)

3 years agomacset: fix memory size check
Eric Leblond [Fri, 20 Aug 2021 12:41:20 +0000 (14:41 +0200)] 
macset: fix memory size check

(cherry picked from commit 328bdf2c61a2b04ce1b3cde3063a07f170134717)

3 years agoflow: be sure to check hash till the end
Eric Leblond [Fri, 20 Aug 2021 08:42:13 +0000 (10:42 +0200)] 
flow: be sure to check hash till the end

(cherry picked from commit d7468c55ca4a8375ca6ca12396a4c61af6465041)

3 years agoflow: add comment on flow handling
Eric Leblond [Thu, 19 Aug 2021 14:30:50 +0000 (16:30 +0200)] 
flow: add comment on flow handling

(cherry picked from commit e531530a67789f895360200fa9d5874d3dcd7511)

3 years agostream: increase memcap on memory errors
Eric Leblond [Thu, 19 Aug 2021 09:22:06 +0000 (11:22 +0200)] 
stream: increase memcap on memory errors

(cherry picked from commit c1bffa9545b8aa9d0fc64ac6511edd34919135d7)

3 years agoflow: fix a debug assert
Eric Leblond [Sun, 15 Aug 2021 10:17:23 +0000 (12:17 +0200)] 
flow: fix a debug assert

As the FlowBypassedTimeout function is interacting with the capture
method it is possible that the return changes between the call that
did trigger the timeout and the actual state (ie if packets arrive
in between the two calls). So we should not use the call to
FlowBypassedTimeout in the assert.

(cherry picked from commit cce7e4f4cb28485f2e43630b4baf7a77449af707)

3 years agoflow: more accurate flow counters
Eric Leblond [Sat, 14 Aug 2021 21:05:03 +0000 (23:05 +0200)] 
flow: more accurate flow counters

Don't increment the flow timeout counter for flows that are not
really timeout (as use_cnt is non zero). And also don't take into
account bypassed flows in the counter for flow timeout in use.

(cherry picked from commit 9a4ef6b8fc290a83ad0d17c036d8a93b5c02689c)

3 years agoflow/worker: handle timeout edge case
Victor Julien [Mon, 30 Aug 2021 08:53:49 +0000 (10:53 +0200)] 
flow/worker: handle timeout edge case

In the flow worker timeout path it is assumed that we can hand off
flows to the recycler after processing, implying that `Flow::use_cnt` is 0.
However, there was a case where this assumption was incorrect.

When during flow timeout handling the last processed data would trigger a
protocol upgrade, two additional pseudo packets would be created that were
then pushed all the way through the engine packet paths. This would mean
they both took a flow reference and would hold that until after the flow
was handed off to the recycler. Thread safety implementation would make
sure this didn't lead to crashes.

This patch handles this case returning these packets to the pool from
the timeout handling.

(cherry picked from commit c51042e0934fd328010d41d9405fd643855aba89)

3 years agoflow/worker: set proper end flag
Victor Julien [Fri, 30 Jul 2021 19:15:28 +0000 (21:15 +0200)] 
flow/worker: set proper end flag

(cherry picked from commit c5556b5dd9b9430bddd7a79917db6bc14642b090)

3 years agoflow/manager: set proper end flag
Victor Julien [Fri, 30 Jul 2021 18:12:05 +0000 (20:12 +0200)] 
flow/manager: set proper end flag

(cherry picked from commit 61f6fe037df2b1cabd1a763f099ca62714c6c3da)

3 years agodetect/analyzer: suggest modern keywords
Victor Julien [Fri, 5 Feb 2021 21:01:26 +0000 (22:01 +0100)] 
detect/analyzer: suggest modern keywords

(cherry picked from commit b55b327db1590ae7e8ccb1a9ada9ddaa29a900bb)

3 years agodetect/analyzer: fix json output for warnings/notes
Victor Julien [Fri, 5 Feb 2021 20:33:35 +0000 (21:33 +0100)] 
detect/analyzer: fix json output for warnings/notes

(cherry picked from commit 57f7612ffd6de650943607f2fb168015e45a39e1)

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

4 years agorust/ike: suppress some compile warnings when not debug
Jason Ish [Wed, 30 Jun 2021 16:03:35 +0000 (10:03 -0600)] 
rust/ike: suppress some compile warnings when not debug

Due to ef5755338fa6404b60e7f90bfbaca039b2bfda1e, the variables
that are only used for debug output now emit unused variable
warnings when Suricata is not built with debug. Prefix these
variables with _ to suppress these warnings.

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 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 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 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 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 agomqtt: move sub/unsub limits into app-layer config
Victor Julien [Mon, 21 Jun 2021 19:10:55 +0000 (21:10 +0200)] 
mqtt: move sub/unsub limits into app-layer config

(cherry picked from commit 3c1cc1e345bc9f78988411efa8461351d24efe98)

4 years agodetect/mqtt: add topic inspection limit
Sascha Steinbiss [Mon, 10 May 2021 12:54:47 +0000 (14:54 +0200)] 
detect/mqtt: add topic inspection limit

We add a new 'mqtt.(un)subscribe-topic-match-limit' option
to allow a user to specify the maximum number of topics in
a MQTT SUBSCRIBE or UNSUBSCRIBE message to be evaluated
in detection.

(cherry picked from commit 4c0ef73bf21f5b07c5c34fd2dc5f6d9c166bc6da)

4 years agodetect: use u32 for InspectionBufferMultipleForList
Philippe Antoine [Thu, 6 May 2021 07:25:49 +0000 (09:25 +0200)] 
detect: use u32 for InspectionBufferMultipleForList

So that we do not have an endless loop casting index to
u16 and having more than 65536 buffers in one transaction

Changes for all protocols, even ones where it is impossible
to have such a pattern, so as to avoid bad pattern copy/paste
in the future

(cherry picked from commit 7d0a39412bb451443a4e19e6571ab86a0583214c)

4 years agodcerpc: handles bigger inputs than 2^16
Philippe Antoine [Mon, 12 Apr 2021 14:56:33 +0000 (16:56 +0200)] 
dcerpc: handles bigger inputs than 2^16

By comparing integers with the largest size

(cherry picked from commit 6f03ee2e47d331aa29524d81777c970415b817f1)

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: #4512.

4 years agodnp3: fixes use after realloc/free in output
Philippe Antoine [Tue, 9 Mar 2021 14:22:47 +0000 (15:22 +0100)] 
dnp3: fixes use after realloc/free in output

OutputJsonBuilderBuffer can realloc the buffer
So, we need to give it the right reference

4 years agodoc: update sphinx api to use add_css_file 6224/head
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 agorust/template: suppress unread variable warning 6222/head
Jason Ish [Mon, 21 Jun 2021 20:00:45 +0000 (14:00 -0600)] 
rust/template: suppress unread variable warning

Suppress the warning about an unused variable in the template
parser. As this is just a template I think this is OK, however
master should make sure this variable is used, if only to be
more self documenting.

4 years agorust: fix warnings with nightly
Sascha Steinbiss [Tue, 22 Jun 2021 07:33:24 +0000 (09:33 +0200)] 
rust: fix warnings with nightly

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

Bug: #4538.

4 years agoconfig: fix null dereference in MacSetRegisterFlowStorage 6212/head
Philippe Antoine [Fri, 11 Jun 2021 12:13:44 +0000 (14:13 +0200)] 
config: fix null dereference in MacSetRegisterFlowStorage

Crash happens with
--set outputs.eve-json.types.files.force-magic=yes

(cherry picked from commit 8bf653054025e6297f05ec211a0baa44cf795704)

4 years agohttp2: make http1 rules work on http2 traffic optional
Philippe Antoine [Wed, 26 May 2021 08:16:54 +0000 (10:16 +0200)] 
http2: make http1 rules work on http2 traffic optional

4 years agoproto: introduce signature protocol, as extension to flow protocol
Philippe Antoine [Mon, 7 Dec 2020 13:41:00 +0000 (14:41 +0100)] 
proto: introduce signature protocol, as extension to flow protocol

AppProtoEquals function allows to check if a flow protocol
matches a signature protocol

This allows HTTP1 keywords on HTTP2 traffic