]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
16 months agorust: add MSRV as rust-version 10674/head
Victor Julien [Wed, 20 Mar 2024 09:34:05 +0000 (10:34 +0100)] 
rust: add MSRV as rust-version

Update github-actions to use it for the MSRV check.

16 months agoversion: start development towards 6.0.18 10672/head
Shivani Bhardwaj [Wed, 20 Mar 2024 07:58:51 +0000 (13:28 +0530)] 
version: start development towards 6.0.18

16 months agorelease: 6.0.17; update changelog suricata-6.0.17
Shivani Bhardwaj [Tue, 19 Mar 2024 10:13:17 +0000 (15:43 +0530)] 
release: 6.0.17; update changelog

16 months agossh: limit length for banner logs
Philippe Antoine [Mon, 19 Feb 2024 15:57:55 +0000 (16:57 +0100)] 
ssh: limit length for banner logs

Ticket: 6770
(cherry picked from commit c4b8fb7aca482d1a1555e27072ca26896b52a480)

16 months agossh: avoid quadratic complexity from long banner
Philippe Antoine [Thu, 22 Feb 2024 09:14:36 +0000 (10:14 +0100)] 
ssh: avoid quadratic complexity from long banner

Ticket: 6799

When we find an overlong banner, we get into the state just
waiting for end of line, and we just want to skip the bytes
until then.
Returning AppLayerResult::incomplete made TCP engine retain
the bytes and grow the buffer that we parsed again and again...

(cherry picked from commit 271ed2008bb7392ca2803ab6dac8952491616151)

16 months agoci: update ubuntu22.04 builds with clang14+asan
Jason Ish [Mon, 18 Mar 2024 17:54:20 +0000 (11:54 -0600)] 
ci: update ubuntu22.04 builds with clang14+asan

using a workround about ASLR

Backport of 632e52ca2b72f8a3462b22896cb5d25d9d724f9c but not a cherry
pick.

16 months agodetect: update packet action on protocol change
Philippe Antoine [Tue, 3 Oct 2023 10:39:13 +0000 (12:39 +0200)] 
detect: update packet action on protocol change

Ticket: #6305

When running FlowWorkerStreamTCPUpdate, one of the dequeued packet
may set the flow action to drop, without updating the not-pseudo
packet action, as is done usually with a previous call to
FlowHandlePacketUpdate

(cherry picked from commit 4c4f7ff1a2324bff9e4e09dd8354878b2455ac34)

16 months agoyaml: remove newline from error message
Victor Julien [Mon, 20 Nov 2023 08:31:40 +0000 (09:31 +0100)] 
yaml: remove newline from error message

(cherry picked from commit f53c4ab1494acad333e73965f13cde67cf663b1c)

17 months agoutil/mime: fix memory leak 10455/head
Alexey Simakov [Wed, 7 Feb 2024 14:51:00 +0000 (17:51 +0300)] 
util/mime: fix memory leak

Fix memory leak at util-decode-mime:MimeDecInitParser, which
root cause is not-freeing allocated memory for mimeMsg

Bug: #6745
(cherry picked from commit 231c892befe25c23d5d3b54e48077c8446940eb5)

17 months agomulti-tenant: fix loader dead lock
Victor Julien [Sun, 11 Feb 2024 08:29:38 +0000 (09:29 +0100)] 
multi-tenant: fix loader dead lock

A dead lock could occur at start up, where a loader thread would
get stuck on it's condition variable, while the main thread was
polling the loaders task results.

The vector to the dead lock is as follows:

main                         loader
DetectEngineMultiTenantSetup
-DetectLoaderSetupLoadTenant
--DetectLoaderQueueTask
---lock loader
---add task
---unlock loader
                        lock loader
                        check/exec tasks
                        unlock loader
---wake up threads
                        lock ctrl mutx
                        cond wait ctrl
                        unlock ctrl
-DetectLoadersSync
--lock loader
--check tasks
--unlock loader

Between the main thread unlocking the loader and waking up the
threads, it is possible that the loader has already moved ahead
but not yet entered its conditional wait. The main thread sends
its condition signal, but since the loader isn't yet waiting on
it the signal is ignored. Then when the loader does enter its
conditional wait, the signal is not sent again.

This patch updates the logic to send signals much more often.
It also makes sure that the signal is sent under lock, as the
API requires.

Bug: #6767.

Co-authored-by: Shivani Bhardwaj <shivani@oisf.net>
17 months agonapatech: update docs to remove hba reference
Ralph Eastwood [Thu, 5 Oct 2023 08:02:19 +0000 (08:02 +0000)] 
napatech: update docs to remove hba reference

(cherry picked from commit 9865164e75decf58a3ab1da2ff3a161e639dd8b6)

17 months agonapatech: remove deprecated hba support
Ralph Eastwood [Thu, 28 Sep 2023 17:19:10 +0000 (19:19 +0200)] 
napatech: remove deprecated hba support

(cherry picked from commit 7b0a5dae6049cc49fee8f04a245a309aed7eaff3)

17 months agoversion: start development towards 6.0.17 10343/head 10362/head
Shivani Bhardwaj [Fri, 9 Feb 2024 04:39:29 +0000 (10:09 +0530)] 
version: start development towards 6.0.17

17 months agorelease: 6.0.16; update changelog suricata-6.0.16
Shivani Bhardwaj [Thu, 8 Feb 2024 09:06:43 +0000 (14:36 +0530)] 
release: 6.0.16; update changelog

17 months agohttp2: limit number of concurrent transactions
Philippe Antoine [Thu, 9 Nov 2023 15:15:36 +0000 (16:15 +0100)] 
http2: limit number of concurrent transactions

Ticket: 6481

Instead of just setting the old transactions to a drop state so
that they get later cleaned up by Suricata, fail creating new ones.

This is because one call to app-layer parsing can create many
transactions, and quadratic complexity could happen in one
single app-layer parsing because of find_or_create_tx

(cherry picked from commit 80abc22f6475b6a87a33166729a871203f34d578)

17 months agosmtp: avoid creating empty transaction
Philippe Antoine [Tue, 14 Nov 2023 20:51:37 +0000 (21:51 +0100)] 
smtp: avoid creating empty transaction

Ticket: 6477

So as to avoid ending up with too many empty transactions.

This happens when Suricata sees a DATA command in the current
transaction but did not have a confirmation response for it.
Then, if Suricata receives another DATA command, it will
create another new transaction, even if the previous one
is empty. And so, a malicious client can create many empty
transactions by just sending a repeated amount of DATA commands
without having a confirmation code for them.

Suricata cannot use state->current_command == SMTP_COMMAND_DATA
to prevent this attack and needs to resort to a new boolean
is_data because the malicious client may send another dummy command
after each DATA command.

This patch leaves only one call to SMTPTransactionCreate

(cherry picked from commit 61f2e4e1e5b34dfd8ae44d1c15253e2da65f6e6a)

17 months agosmtp: config limit maximum number of live transactions
Philippe Antoine [Thu, 9 Nov 2023 11:27:59 +0000 (12:27 +0100)] 
smtp: config limit maximum number of live transactions

Unlike the original commit, this fix just sets a limit but does not
expose it as a configurable option.

Ticket: #6477

(cherry picked from commit 8f73a0ac5588cb5e5c501b3c7a07cb5d35b99d92)

17 months agohttp1: configurable max number of live tx per flow
Philippe Antoine [Tue, 17 Oct 2023 13:28:53 +0000 (15:28 +0200)] 
http1: configurable max number of live tx per flow

Unlike the original commit, this commit just enforces a maximum limit,
but does not expose the configuration of it.

Ticket: #5921

(cherry picked from commit 4175680a8a1c0dfaa491ee63d6e36c011d498473)

17 months agohttp1: remove transactions from their list
Philippe Antoine [Fri, 7 Apr 2023 14:02:41 +0000 (16:02 +0200)] 
http1: remove transactions from their list

instead of keeping a NULL pointer in an array

Ticket: #5921

(cherry picked from commit 8f63a8f3bffbbaf8fae4985ee5f974ab326b08c0)

17 months agohttp2: handle reassembly for continuation frames
Philippe Antoine [Thu, 25 Jan 2024 15:01:14 +0000 (16:01 +0100)] 
http2: handle reassembly for continuation frames

Ticket: 5926

HTTP2 continuation frames are defined in RFC 9113.
They allow header blocks to be split over multiple HTTP2 frames.
For Suricata to process correctly these header blocks, it
must do the reassembly of the payload of these HTTP2 frames.
Otherwise, we get incomplete decoding for headers names and/or
values while decoding a single frame.

Design is to add a field to the HTTP2 state, as the RFC states that
these continuation frames form a discrete unit :
> Field blocks MUST be transmitted as a contiguous sequence of frames,
> with no interleaved frames of any other type or from any other stream.
So, we do not have to duplicate this reassembly field per stream id.

Another design choice is to wait for the reassembly to be complete
before doing any decoding, to avoid quadratic complexity on partially
decoding of the data.

(cherry picked from commit aff54f29f8c3f583ae0524a661aa90dc7a2d3f92)

18 months agorules: use primary default-rule-path if set on command line 10313/head 10323/head
Jason Ish [Wed, 4 May 2022 19:18:09 +0000 (13:18 -0600)] 
rules: use primary default-rule-path if set on command line

When reloading rules, respect `--set default-rule-path=...` from the
command line if set.

Previously the rule reload would always take the default-rule-path from
the configuration file, even if overrided on the command line.

Issue: #1911
(cherry picked from commit 3ea6572e22d9ffcb26d9d408a91a3c0a5291c847)

18 months agompm: allocate StateQueue on the heap 10311/head
Philippe Antoine [Mon, 20 Mar 2023 12:21:34 +0000 (13:21 +0100)] 
mpm: allocate StateQueue on the heap

So that we can have multi-tenant on MacOS without stack
overflows because of the size of the structure...

Ticket: #6263.
(cherry picked from commit 92fce2fdc069324e6060ce046ca80da6a351573c)

18 months agodetect: fix path creation in Windows
Victor Julien [Thu, 10 Aug 2023 08:08:37 +0000 (10:08 +0200)] 
detect: fix path creation in Windows

Fixes file loading for rule files and Lua scripts.

Bug: #6095.
(cherry picked from commit 04aee5f0995c6ba08d35ee5e363c4e0b9f82b5ca)

18 months agodetect: free all tenant detect engines
Victor Julien [Tue, 8 Aug 2023 13:50:53 +0000 (15:50 +0200)] 
detect: free all tenant detect engines

Free all tenants registered in the master.

(cherry picked from commit a4d80bc7c4910170aba950db0a497124712b330a)

18 months agorequirements: use libhtp 0.5.x 10247/head 10254/head
Jason Ish [Wed, 24 Jan 2024 20:41:47 +0000 (14:41 -0600)] 
requirements: use libhtp 0.5.x

Move to libhtp to the 0.5.x branch instead of 0.5.45.

(cherry picked from commit c3b3c11e30e1afdbde5c196a0692ee5e2c379cb1)

18 months agogithub-ci: only specify major version for alma 10213/head
Victor Julien [Sun, 21 Jan 2024 13:26:42 +0000 (14:26 +0100)] 
github-ci: only specify major version for alma

18 months agogithub-ci: add eBPF to the builds workflow
Lukas Sismis [Mon, 11 Dec 2023 10:29:28 +0000 (11:29 +0100)] 
github-ci: add eBPF to the builds workflow

Ticket: #6602

18 months agodoc: fix byte_test examples 10139/head
Philippe Antoine [Wed, 6 Dec 2023 19:32:50 +0000 (20:32 +0100)] 
doc: fix byte_test examples

As this keyword has 4 mandatory arguments, and some examples
had only three...

Ticket: 6629
(cherry picked from commit 4933b817aacc649edc52409426500a9ec271ccc6)

19 months agodoc: update userguide installation instructions 10022/head
Lukas Sismis [Fri, 8 Sep 2023 11:02:14 +0000 (13:02 +0200)] 
doc: update userguide installation instructions

The commit updates obsolete installation instructions
from the userguide and reformats certain parts for
improved clarity.

Ticket: #5988

19 months agoconfigure: fix llc detection on recent Debian
Eric Leblond [Tue, 5 Jan 2021 20:40:33 +0000 (21:40 +0100)] 
configure: fix llc detection on recent Debian

Where clang --version was returning:

clang version 9.0.1-15+b1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Newer version like clang-10 on Debian are returning:

Debian clang version 10.0.1-8+b1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

As a result the parsing was failing to determine which llc was
available on the system.

Ticket: #6598

(cherry picked from commit 37b1595c20959353ec438860dc5a49bcae227aa8)

20 months agodetect/analysis: Move globals to engine ctx 9927/head
Jeff Lucovsky [Thu, 3 Aug 2023 14:06:47 +0000 (10:06 -0400)] 
detect/analysis: Move globals to engine ctx

Issue: 6239

This commit moves the global variables associated with engine analysis
into the detect engine context. Doing so provides encapsulation of the
analysis components as well as thread-safe operation in a multi-tenant
(context) deployment.

(cherry picked from commit c8615bcd4798a1c53323b4591e787cbf0358811c)

20 months agogithub-ci: cancel previous builds workflow for branch 9889/head
Jason Ish [Wed, 15 Nov 2023 20:48:40 +0000 (14:48 -0600)] 
github-ci: cancel previous builds workflow for branch

On a push of the same branch, cancel the previous running builds.yml
workflow.

(cherry picked from commit 2b9603d94ddb0ff1c103ce964f22d8bc63f4392c)

20 months agogithub-ci: remove Fedora 36, 37; add Fedora 39
Jason Ish [Fri, 24 Nov 2023 16:39:21 +0000 (10:39 -0600)] 
github-ci: remove Fedora 36, 37; add Fedora 39

Fedora 36 is EOL and some mirrors have been removed. Fedora 37 security
updates stop in in December 2023.

20 months agodoc: update file.data keyword documentation
jason taylor [Thu, 16 Nov 2023 13:49:50 +0000 (13:49 +0000)] 
doc: update file.data keyword documentation

Signed-off-by: jason taylor <jtfas90@gmail.com>
20 months agouserguide: update tls not_after/not_before mentions 9856/head
Juliana Fajardini [Thu, 16 Nov 2023 17:37:32 +0000 (14:37 -0300)] 
userguide: update tls not_after/not_before mentions

Our tls fields not_after and not_before are actually logged as
`notafter` and `notbefore`, but were documented with the underscore.

Update the documentation, since updating the log format itself would be
a breaking change.

Task #5494

(cherry picked from commit a649a92afd4ed71b264ee1df408875322d9dfaf9)

20 months agohttp2: app-layer event for userinfo in uri 9828/head
Philippe Antoine [Tue, 7 Nov 2023 16:23:23 +0000 (17:23 +0100)] 
http2: app-layer event for userinfo in uri

Ticket: #6426

as per RFC 9113
":authority" MUST NOT include the deprecated userinfo subcomponent
for "http" or "https" schemed URIs.

(cherry picked from commit e3cd0d073f18a9d760e332852d53bce080ea96f0)

20 months agodoc: add tcp flags documentation 9806/head
Travis Green [Thu, 29 Aug 2019 04:16:28 +0000 (22:16 -0600)] 
doc: add tcp flags documentation

Signed-off-by: jason taylor <jtfas90@gmail.com>
(cherry picked from commit 96a0e7016fd36458db52b1fca81b9f4a61e24105)

20 months agohost/iprep: run all timeout logic 9782/head 9788/head
Victor Julien [Mon, 11 Sep 2023 05:05:48 +0000 (07:05 +0200)] 
host/iprep: run all timeout logic

Run all timeout logic if iprep is in use as well.

Minor code cleanups.

Bug: #6436.
(cherry picked from commit 6307a4d4b93d000d4c5e19434a6dd3958946dcd8)

20 months agohttp2: event on mismatch between authority and host 9770/head 9771/head
Philippe Antoine [Mon, 6 Nov 2023 15:38:27 +0000 (16:38 +0100)] 
http2: event on mismatch between authority and host

Ticket: #6425
(cherry picked from commit 46a46e5b1f4909446e6f727f41b2eaeb3cb34bbd)

21 months agodns/eve: use default formats if formats is empty 9719/head 9730/head
Jason Ish [Fri, 27 Oct 2023 16:19:31 +0000 (10:19 -0600)] 
dns/eve: use default formats if formats is empty

If the configuration field "formats" is empty, DNS response records do
not have any relevant information other than that there was a
response, but not much about the response.

I'm pretty sure the intention here was to log the response details if
no formats were provided, which is what happens when the field is
commented out.

So if no formats are specified, use the default of all.

Bug: #6420
(cherry picked from commit a240a93b6931c94485d336cdc340e16929437a01)

21 months agodetect/bytejump: Improve end-of-buffer handling 9717/head
Jeff Lucovsky [Fri, 27 Oct 2023 13:10:47 +0000 (09:10 -0400)] 
detect/bytejump: Improve end-of-buffer handling

Issue: 4623

This commit addresses the issues reported in issue 4623 when the jump
value points at the last byte in the buffer.

(cherry picked from commit f363b99fd7592824dbcbec465f1968c6f615ccaa)

21 months agodocs: adjust readthedocs config to new options 9702/head 9728/head
Juliana Fajardini [Thu, 5 Oct 2023 16:13:27 +0000 (13:13 -0300)] 
docs: adjust readthedocs config to new options

Our documentation was failing to build, seems connected to the new way
of indicating build options (cf
https://readthedocs.org/projects/suricata/builds/22112658/,
https://docs.readthedocs.io/en/stable/config-file/v2.html#build,
and https://docs.readthedocs.io/en/stable/config-file/v2.html#build-os).

Added the build.os required new field, and adjusted the way python
version is passed.

For the new configuration style for read the docs, one of the ways to
pass extra configuration for python is having a requirements file.

(cherry picked from commit 1a132f454a64f699118dafcdfccb0687317b435e)

21 months agoversion: start development towards 6.0.16
Victor Julien [Thu, 19 Oct 2023 14:38:25 +0000 (16:38 +0200)] 
version: start development towards 6.0.16

21 months agorelease: 6.0.15; update changelog suricata-6.0.15
Shivani Bhardwaj [Wed, 18 Oct 2023 14:49:17 +0000 (20:19 +0530)] 
release: 6.0.15; update changelog

21 months agomime: avoid quadratic complexity in MimeDecAddEntity
Philippe Antoine [Mon, 11 Sep 2023 14:49:48 +0000 (16:49 +0200)] 
mime: avoid quadratic complexity in MimeDecAddEntity

Ticket: #6306

Keep a reference to last child, consume a bit more RAM to save CPU

(cherry picked from commit 737bc4f219ea36b4da4ffbebef15b0619dffbca1)

21 months agooutput/email: use SCCalloc for OutputJsonEmailCtx 9647/head 9648/head
Shivani Bhardwaj [Wed, 4 Oct 2023 07:44:41 +0000 (13:14 +0530)] 
output/email: use SCCalloc for OutputJsonEmailCtx

email_ctx->fields only gets populated when smtp.custom setting is on.
The fn EveEmailLogJSONCustom is called when either
1. smtp.extended setting is on or,
2. email_ctx->fields is populated which means smtp.custom setting is on

In case neither of these are set in suricata.yaml, no call should
ideally be made to the fn EveEmailLogJSONCustom.
However, it turns out that email_ctx->fields is unset and then set only
after the smtp config was found. This leads to email_ctx->fields
sometimes contain value even when no config was given to the smtp
section and can lead to unexpected output.

Fix this by using SCCalloc while initializing OutputJsonEmailCtx struct
instead of SCMalloc.

Bug 6380

(cherry picked from commit 7406ac0fa595658c70ed3f13cf79656f2b0d290a)

21 months agodetect: inspect all packets in multi-layer tunneling 9643/head
Victor Julien [Fri, 13 Oct 2023 11:47:05 +0000 (13:47 +0200)] 
detect: inspect all packets in multi-layer tunneling

When the decoders encounter multiple layers of tunneling, multiple tunnel
packets are created. These are then stored in ThreadVars::decode_pq, where
they are processed after the current thread "slot" is done. However, due
to a logic error, the tunnel packets after the first, where not called
for the correct position in the packet pipeline. This would lead to these
packets not going through the FlowWorker module, so skipping everything
from flow tracking, detection and logging.

This would only happen for single and workers, due to how the pipelines
are constructed.

The "slot" holding the decoder, would contain 2 packets in
ThreadVars::decode_pq. Then it would call the pipeline on the first
packet with the next slot of the pipeline through a indirect call to
TmThreadsSlotVarRun(), so it would be called for the FlowWorker.
However when that first (the most inner) packet was done, the call
to TmThreadsSlotVarRun() would again service the ThreadVars::decode_pq
and process it, again moving the slot pointer forward, so past the
FlowWorker.

This patch addresses the issue by making sure only a "decode" thread
slot will service the ThreadVars::decode_pq, thus never moving the
slot past the FlowWorker.

Bug: #6402.
(cherry picked from commit 15947f21736662ca5997dbc075b4ec9a7f5a304d)

21 months agothreads: cleanup decode_pq handling
Victor Julien [Tue, 16 May 2023 20:24:02 +0000 (22:24 +0200)] 
threads: cleanup decode_pq handling

(cherry picked from commit 25396dcd096ac36a45ccc162b8dfb01cdf34523d)

21 months agoflowworker: simplify pseudo packet use
Victor Julien [Mon, 15 May 2023 08:02:26 +0000 (10:02 +0200)] 
flowworker: simplify pseudo packet use

Pseudo packets originating in the flow worker do not need to leave the
flow worker. Putting those in the ThreadVars::decode_pq will make them
be evaluated by the next steps in the pipeline, but those will all
ignore pseudo packets.

Instead, this patch returns them to the packet pool, while still honoring
the IPS verdict logic.

(cherry picked from commit 3247e39f0c6824b0fde20cfa8f4bbb596217eed2)

21 months agorust: tilde version for byteorder 9615/head 9621/head
Philippe Antoine [Sat, 14 Oct 2023 14:12:28 +0000 (19:42 +0530)] 
rust: tilde version for byteorder

so that we get one compatible with MSRV

21 months agodetect/bytejump: Improve negative post_offset handling. 9613/head
Jeff Lucovsky [Fri, 8 Sep 2023 14:09:52 +0000 (10:09 -0400)] 
detect/bytejump: Improve negative post_offset handling.

Issue: 4624

Handle negative post_offset values that jump before the buffer as though
they refer to the buffer start.

(cherry picked from commit 2bf9d0fdf9778b48c3db8d39e51c6129e19213a3)

22 months agostats: Track stream reassembly drops 9521/head 9529/head
Jeff Lucovsky [Tue, 22 Aug 2023 14:17:24 +0000 (10:17 -0400)] 
stats: Track stream reassembly drops

Issue: 6235
(cherry picked from commit 904f0ddeeeb1bdb4a686f991cf090a47dd84249e)

22 months agoversion: start development towards 6.0.15
Victor Julien [Thu, 14 Sep 2023 12:18:28 +0000 (14:18 +0200)] 
version: start development towards 6.0.15

22 months agorelease: 6.0.14; update changelog suricata-6.0.14
Juliana Fajardini [Wed, 13 Sep 2023 14:18:31 +0000 (11:18 -0300)] 
release: 6.0.14; update changelog

22 months agosmtp: fix null deref with config option body md5
Philippe Antoine [Wed, 30 Aug 2023 19:35:08 +0000 (21:35 +0200)] 
smtp: fix null deref with config option body md5

Ticket: #6279

If we have the smtp body beginning without headers, we need to
create the md5 context and right away and supply data to it.
Otherwise, on the next line being processed, md5_ctx will be
NULL but body_begin will have been reset to 0

(cherry picked from commit c6afee64d510daa9f383b160f3abd194ee74a15b)

Adapted to use hash functions from master6

22 months agospm/hs: don't exit on bad patterns
Victor Julien [Tue, 5 Sep 2023 12:49:34 +0000 (14:49 +0200)] 
spm/hs: don't exit on bad patterns

A bad pattern in a rule that hyperscan would fail to compile would
exit Suricata. This could happen during a rule reload as well.

In case of a untrusted ruleset, this could potentially be used to
shut down the sensor.

Commit 7d0851b0c2 already blocks the only know case, but this patch
is more defensive.

Ticket: #6195.
(cherry picked from commit 00e00254eae205bad5d4cfbf6c9e69f944faaf69)

22 months agobpf: close fp in all error paths 9461/head 9472/head
Victor Julien [Thu, 7 Sep 2023 12:32:59 +0000 (14:32 +0200)] 
bpf: close fp in all error paths

22 months agopath: new funcs to merge paths
Victor Julien [Thu, 10 Aug 2023 08:07:22 +0000 (10:07 +0200)] 
path: new funcs to merge paths

Take windows directory separators into account.

Path is not checked or "resolved".

(cherry picked from commit 228caa640b3f961fd13ca8744cbbee789116bd30)

22 months agostat: add wrappers to isolate OS_WIN32 specifics
Victor Julien [Wed, 9 Aug 2023 06:00:09 +0000 (08:00 +0200)] 
stat: add wrappers to isolate OS_WIN32 specifics

(cherry picked from commit 269f751d36e8c485b6a31bd40242749056f49bc5)

22 months agodetect/filemagic: fix thread ctx registration; reloads
Victor Julien [Wed, 12 Jul 2023 06:25:28 +0000 (08:25 +0200)] 
detect/filemagic: fix thread ctx registration; reloads

Make sure thread ctx registration happens and id remains correct
in case of reloads.

To do so, move id var into the detect ctx.

(cherry picked from commit 2cac440f7d062aa54dbff54712087eecce5c7437)

22 months agovar-names: reimplement var name handling
Victor Julien [Wed, 2 Aug 2023 06:37:45 +0000 (08:37 +0200)] 
var-names: reimplement var name handling

Implement a new design for handling var name id's. The old logic
was aware of detection engine versions and generally didn't work
well for multi-tenancy cases. Other than memory leaks and crashes,
logging of var names worked or failed based on which tenant was
loaded last.

This patch implements a new approach, where there is a global store
of vars and their id's for the lifetime of the program.

Overall Design:

Base Store: "base"

Used during keyword registration. Operates under lock. Base is shared
between all detect engines, detect engine versions and tenants.
Each variable name is ref counted.

During the freeing of a detect engine / tenant, unregistration decreases
the ref cnt.

Base has both a string to id and a id to string hash table. String to
id is used during parsing/registration. id to string during unregistration.

Active Store Pointer (atomic)

The "active" store atomic pointer points to the active lookup store. The call
to `VarNameStoreActivate` will build a new lookup store and hot swap
the pointer.

Ensuring memory safety. During the hot swap, the pointer is replaced, so
any new call to the lookup functions will automatically use the new store.
This leaves the case of any lookup happening concurrently with the pointer
swap. For this case we add the old store to a free list. It gets a timestamp
before which it cannot be freed.

Free List

The free list contains old stores that are waiting to get removed. They
contain a timestamp that is checked before they are freed.

Bug: #6044.
Bug: #6201.
(cherry picked from commit b130234b2639842619da4c156ce5164a652202ec)

23 months agocommunity-id: Fix IPv6 address sorting not respecting byte order 9460/head
Arne Welzel [Sun, 20 Aug 2023 15:32:47 +0000 (17:32 +0200)] 
community-id: Fix IPv6 address sorting not respecting byte order

When comparing IPv6 addresses based on uint32_t chunks, one needs to
apply ntohl() conversion to the individual parts, otherwise on little
endian systems individual bytes are compared in the wrong order.
Avoid this all and leverage memcmp(), it'll short circuit on the first
differing byte and its return values tells us which address sorts lower.

Bug: #6276
(cherry picked from commit 0ddc44f4c116945e0a8fa846d4f2c5ba5a7d8b63)

23 months agoreadthedocs: pin theme to sphinx_rtd_theme 9450/head
Jason Ish [Wed, 6 Sep 2023 14:51:49 +0000 (08:51 -0600)] 
readthedocs: pin theme to sphinx_rtd_theme

ReadTheDocs changed the default theme.

23 months agodns/eve: add 'HTTPS' type logging 9440/head
Haleema Khan [Sat, 15 Oct 2022 04:17:42 +0000 (09:17 +0500)] 
dns/eve: add 'HTTPS' type logging

Add a new DNS record type to represent HTTPS
Ticket: #4751

(cherry picked from commit 8d5c5f24a184ed412d1d78f1c0346b205f80fe6b)

23 months agoaf-packet: terminate on same interface & copyiface 9391/head
Shivani Bhardwaj [Thu, 10 Aug 2023 12:17:35 +0000 (17:47 +0530)] 
af-packet: terminate on same interface & copyiface

If the interface and copy-iface are same for an af-packet IPS device
setting then fataly exit else it leads to a segfault in later stages.

Bug 5870

(cherry picked from commit d4dd53c95f5fe30a0b2a1e71ab185c06c71a1afe)

23 months agodetect/file: correct registration for HTTP 9362/head
Victor Julien [Sat, 5 Aug 2023 09:46:20 +0000 (11:46 +0200)] 
detect/file: correct registration for HTTP

Register file.name and file.magic at correct progress values.
In HTTP1, the files are (part of) the body, so make sure the file
detection logic only runs when the parser has started processing
the body.

23 months agodetect/file: use util to turn keyword to nocase
Victor Julien [Fri, 4 Aug 2023 15:08:06 +0000 (17:08 +0200)] 
detect/file: use util to turn keyword to nocase

This changes the way the pattern is stored by making it lowercase.

(cherry picked from commit c5d83d081e9cd77e49d1477b26e276c979e29dab)

23 months agodetect/content: cleanup nocase conversion
Victor Julien [Fri, 4 Aug 2023 12:18:20 +0000 (14:18 +0200)] 
detect/content: cleanup nocase conversion

(cherry picked from commit ef936acdba0cda1da09ff4b7ea35281bd8f18429)

23 months agodetect/fileext: reimplement based on file.name
Victor Julien [Thu, 29 Jun 2023 19:05:36 +0000 (21:05 +0200)] 
detect/fileext: reimplement based on file.name

Ticket: #6194.
(cherry picked from commit 9b09b29350f846e917dab5a3a8351ef7988362b1)

23 months agodetect/filename: switch to file.name implementation
Victor Julien [Thu, 29 Jun 2023 18:09:12 +0000 (20:09 +0200)] 
detect/filename: switch to file.name implementation

Ticket: #6194.
(cherry picked from commit 74f095c915044f31a48967655a0f758cf8b56ba6)

23 months agodetect/filemagic: switch to file.magic implementation
Victor Julien [Fri, 16 Jun 2023 13:07:13 +0000 (15:07 +0200)] 
detect/filemagic: switch to file.magic implementation

Replace implementation of the legacy `filemagic` keyword by the
implementation for the `file.magic` variant. This leads to better
performance and hooks the rules into the detection engine better.

Remove unittests that depended on the old logic.

Ticket: #6194.
(cherry picked from commit 1f22b5184887f5e965e06a6b799bb9ac23b9bc30)

23 months agodetect/tls: minor fingerprint cleanup
Victor Julien [Fri, 16 Jun 2023 12:59:40 +0000 (14:59 +0200)] 
detect/tls: minor fingerprint cleanup

(cherry picked from commit ee6894746032629edbcfdf9a010bb1da1f3a52ed)

23 months agouserguide: add details about tcp flow pass 9361/head
jason taylor [Thu, 15 Jun 2023 18:17:24 +0000 (18:17 +0000)] 
userguide: add details about tcp flow pass

Signed-off-by: jason taylor <jtfas90@gmail.com>
23 months agodoc: hyperscan information updated
jason taylor [Tue, 28 Feb 2023 22:46:32 +0000 (22:46 +0000)] 
doc: hyperscan information updated

Signed-off-by: jason taylor <jtfas90@gmail.com>
23 months agodoc: update file.name keyword information
jason taylor [Mon, 17 Jul 2023 16:36:58 +0000 (16:36 +0000)] 
doc: update file.name keyword information

Signed-off-by: jason taylor <jtfas90@gmail.com>
23 months agodoc: update fileext keyword information
jason taylor [Tue, 18 Jul 2023 21:17:31 +0000 (21:17 +0000)] 
doc: update fileext keyword information

Signed-off-by: jason taylor <jtfas90@gmail.com>
23 months agodoc: update file.magic information
jason taylor [Tue, 1 Aug 2023 15:34:08 +0000 (15:34 +0000)] 
doc: update file.magic information

Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years agostream: special handling for RST data 9347/head
Victor Julien [Tue, 1 Aug 2023 06:44:53 +0000 (08:44 +0200)] 
stream: special handling for RST data

Data on RST packets is not invalid, but also shouldn't be used
in reassembly.

RFC 1122:

  4.2.2.12  RST Segment: RFC-793 Section 3.4

    A TCP SHOULD allow a received RST segment to include data.

    DISCUSSION
        It has been suggested that a RST segment could contain
        ASCII text that encoded and explained the cause of the
        RST.  No standard has yet been established for such
        data.

RST data will be presented to the detection engine per packet,
but will not be part of stream reassembly.

Bug: #6244.
(cherry picked from commit b63374bf5f8c85c42056ad3c4cce12bce3d1a6bd)

2 years agostream: add stream.rst_with_data event for RST with data
Victor Julien [Tue, 1 Aug 2023 05:48:04 +0000 (07:48 +0200)] 
stream: add stream.rst_with_data event for RST with data

(cherry picked from commit 9ba55b8a282eca795c21ff53dd54937492bb8cf1)

2 years agouserguide/install: add info on ubuntu ppa installs 9345/head
Juliana Fajardini [Tue, 1 Aug 2023 21:42:08 +0000 (18:42 -0300)] 
userguide/install: add info on ubuntu ppa installs

Bringing info that was only in our Redmine wiki to our documentation,
and update package to Suricata-6.0, now that the stable points to
Suricata 7.

Task #6231

(cherry picked from commit 4fd3205bf06a00ccda8affe6631985defec9f56c)

2 years agouserguide/eve: format and reorganize alert section 9318/head 9323/head
Juliana Fajardini [Thu, 22 Dec 2022 23:47:24 +0000 (20:47 -0300)] 
userguide/eve: format and reorganize alert section

The `field action` portion seemed to be comprised of a more generic
section that followed it. Also formatted the section for lines to be
within the character limit.

(cherry picked from commit 9900bdc162cc876151e680ea088f89b54edb038f)

2 years agooutput/drop: add verdict field
Juliana Fajardini [Fri, 28 Jul 2023 18:42:35 +0000 (15:42 -0300)] 
output/drop: add verdict field

Related to
Bug #5464

(cherry picked from commit 0437173848d98812f74a28f283c327178bf500dd)

2 years agooutput/alert: add verdict field
Juliana Fajardini [Wed, 5 Jul 2023 15:52:53 +0000 (12:52 -0300)] 
output/alert: add verdict field

Related to
Bug #5464

(cherry picked from commit 53b8defd793f0f8fe2ca5459822d0e11f3d69929)

2 years agodcerpc: accept ALTER_CONTEXT as a valid request 9304/head
Shivani Bhardwaj [Wed, 26 Jul 2023 09:41:59 +0000 (15:11 +0530)] 
dcerpc: accept ALTER_CONTEXT as a valid request

So far, if only the starting request was a DCERPC request, it would be
considered DCERPC traffic. Since ALTER_CONTEXT is a valid request type,
it should be accepted too.

Reported and patch proposed in the following Redmine ticket by
InterNALXz.

Bug 6191

(cherry picked from commit 8770431986598f195d57e570287c40ee3dec0cfa)

2 years agoexception: fix use of master switch with default
Juliana Fajardini [Wed, 21 Jun 2023 20:54:41 +0000 (17:54 -0300)] 
exception: fix use of master switch with default

If an exception policy wasn't set up individually, use the GetDefault
function to pick one. This will check for the master switch option and
handle 'auto' cases.

Instead of deciding what the auto value should be when we are parsing
the master switch, leave that for when some of the other policies is to
be set via the master switch, when since this can change for specific
exception policies - like for midstream, for instance.

Update exceptions policies documentation to clarify that the default
configuration in IPS when midstream is enabled is `ignore`, not
`drop-flow`.

Bug #6169

(cherry picked from commit e306bc6ecc9f526d02d178c5715e40e493fa8cb6)

2 years agoexception: fix 'auto' for master switch in IDS
Juliana Fajardini [Wed, 14 Jun 2023 23:58:44 +0000 (20:58 -0300)] 
exception: fix 'auto' for master switch in IDS

If the master exception policy was set to 'auto' in IDS mode, instead of
just setting the master switch to the default in this case, which is
'ignore', the engine would switch a warning saying that auto wasn't a
valid config and then set the policy to ignore.

This makes 'auto' work for the master switch in IDS, removes function
for setting IPS option and handles the valid IDS options directly from
the function that parses the master policy, as this was the only place
where the function was still called.

Bug #6149

(cherry picked from commit feb47f9a896b049694f7b5ab40365fab8bbe9d51)

2 years agoexception/policy: minor code cleanup
Victor Julien [Tue, 13 Jun 2023 07:51:48 +0000 (09:51 +0200)] 
exception/policy: minor code cleanup

(cherry picked from commit 479fa609fa03719936d147342551d97797c92623)

2 years agostream/tcp: re-enable midstream-policy usage
Juliana Fajardini [Tue, 30 May 2023 13:41:49 +0000 (10:41 -0300)] 
stream/tcp: re-enable midstream-policy usage

We were always setting it to ignore, due to bug 5825.

The engine will now issue an initialization error if an invalid value
is passed in the configuration file for midstream exception policy.

'pass-packet' or 'drop-packet' are never valid, as the midstream policy
concerns the whole flow, not making sense for just a packet.

If midstream is enabled, only two actual config values are allowed:
'ignore' and 'pass-flow', both in IDS and in IPS mode. In default mode
('auto' or if no policy is defined), midstream-policy is set to
'ignore'. All other values will lead to initialization error.

In IDS mode, 'drop-flow' will also lead to initialization error.

Part of
Bug #5825

(cherry picked from commit 69d3750aaf29940c87797eb49ceef7c385e06f43)

2 years agoexception: extract 'auto' check to function
Juliana Fajardini [Thu, 1 Jun 2023 01:52:48 +0000 (22:52 -0300)] 
exception: extract 'auto' check to function

Part of
Bug #5825

(cherry picked from commit e849afbda14aae690ab7b2b8c0734aaeba490ec9)

2 years agoexception: use mix of logconfig/info/warning
Juliana Fajardini [Thu, 1 Jun 2023 23:33:18 +0000 (20:33 -0300)] 
exception: use mix of logconfig/info/warning

Use a mix of SCLogConfig, Warning and Info.
This mix works as follows: when something unnexpected for the user
happens - for instance, the engine ignoring an invalid config value, we
use warning. For indicating the value for the master switch, which
happens only once, we use Info. For all the other cases, we use
SCLogConfig.

It is possible that SCLogConfig isn't showing at the moment, this is a
possible bug to investigate further.

Related to
Bug #5825

(cherry picked from commit 69311ab02f33c8396babfe810ac5a066c900d31e)

2 years agoexception: parse config values, don't post process
Juliana Fajardini [Wed, 31 May 2023 14:56:43 +0000 (11:56 -0300)] 
exception: parse config values, don't post process

Get the enum values from the config file. Update the new extracted
functions. Post-process the config values based on runmode and policy.
Also handle 'auto' enum value in these.

Related to
Bug #5825

(cherry picked from commit 7f8536b81c59205032676efda62a0b18ff0de224)

2 years agoexception/midstream: parse midstream policy alone
Juliana Fajardini [Mon, 29 May 2023 19:55:00 +0000 (16:55 -0300)] 
exception/midstream: parse midstream policy alone

As the midstream exception policy has its own specific scenarios, have a
dedicated function to parse and process its config values, and check for
midstream enabled when needed.

Related to
Bug #5825

(cherry picked from commit f97af0c0b1916ada6cf860b429e2ccfb5b4a3da2)

2 years agoexception: refactor exception policy parse fn
Juliana Fajardini [Mon, 29 May 2023 18:26:22 +0000 (15:26 -0300)] 
exception: refactor exception policy parse fn

Split up ExceptionPolicyParse to try to improve readability.

Related to
Bug #5825

(cherry picked from commit bf22129a0fc133b3f4f18997fc0d384c4f9d3751)

2 years agouserguide: update exception policy behaviors table
Juliana Fajardini [Mon, 24 Apr 2023 19:42:34 +0000 (16:42 -0300)] 
userguide: update exception policy behaviors table

Some exception policies can only be applied to the triggering packet or
only make sense considering the whole flow. Highlight such cases in the
table showing each exception policy.

Related to
Bug #5825

(cherry picked from commit c0db25d055e095a099d8a23fd2c2023e4af761c4)

2 years agodoc: add midstream scenarios for exception policy
Juliana Fajardini [Tue, 18 Apr 2023 23:09:16 +0000 (20:09 -0300)] 
doc: add midstream scenarios for exception policy

The different interactions between midstream pick-up sessions and the
exception policy can be quite difficult to visualize. Add a section for
that in the userguide.

Related to
Bug #5825

(cherry picked from commit 0c2922f02efe3e785d6ede01581891683007a6f2)

2 years agomisc: fix typos, doc, update copyright years
Juliana Fajardini [Fri, 17 Feb 2023 20:34:09 +0000 (17:34 -0300)] 
misc: fix typos, doc, update copyright years

Updated FlowGetNew documentation, where it said NULL was only returned
in case of error.

(cherry picked from commit f511a4ae3f954a3c55b57a0fdffc0ae22a965dd5)

2 years agodefrag: clean up existing stats counters
Juliana Fajardini [Thu, 30 Mar 2023 13:40:46 +0000 (10:40 -0300)] 
defrag: clean up existing stats counters

7a044a99ee14101fbc removed the lines that incremented these defrag
counters, but kept the entities themselves. This commit removes counters
that we judge too complex to maintain, given the current state of the
code, and re-adds incrementing max_hit (memcap related).

Related to
Task #5816

(cherry picked from commit a37a88dcd5950344fc0b4529f1731c3dab9f0888)

2 years agoexception: in ids mode, only REJECT the packet
Juliana Fajardini [Mon, 5 Jun 2023 16:02:26 +0000 (13:02 -0300)] 
exception: in ids mode, only REJECT the packet

In case of 'EXCEPTION_POLICY_REJECT', we were applying the same behavior
regardless of being in IDS or IPS mode.
This meant that (at least) the 'flow.action' was changed to drop when we
hit an exception policy in IDS mode.

Bug #6109

(cherry picked from commit 8f324e3b3d4137b1092b877e8f0dab42e7c824fd)

2 years agoexceptions: add master switch config option
Juliana Fajardini [Tue, 6 Dec 2022 21:29:34 +0000 (18:29 -0300)] 
exceptions: add master switch config option

This allows all traffic Exception Policies to be set from one
configuration point. All exception policy options are available in IPS
mode. Bypass, pass and auto (disabled) are also available in iDS mode

Exception Policies set up individually will overwrite this setup for the
given traffic exception.

Task #5219

(cherry picked from commit 0d9289014bd8f65c7100e7173f24f5c5ff9de0ac)

2 years agoworkflows: use debug-failed for s-v run 9292/head 9299/head
Shivani Bhardwaj [Wed, 26 Jul 2023 10:02:29 +0000 (15:32 +0530)] 
workflows: use debug-failed for s-v run