]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
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

2 years agoutil/mime: skip over any invalid char 9289/head
Shivani Bhardwaj [Tue, 11 Jul 2023 09:12:05 +0000 (14:42 +0530)] 
util/mime: skip over any invalid char

For certain edge case handling for spaces, spaces were handled
particularly in the remainder processing functions. Make sure that now
that as per RFC 2045, util-base64 would skip over any invalid char, the
edge cases in MIME processor also be handled the same way.

This completes the work done in e46b033.

Ticket 6135
Ticket 6207

(cherry picked from commit 789353bc1e1aa23d075f16af25df84df00c68682)

2 years agoutil/base64: fix tests for RFC2045
Shivani Bhardwaj [Thu, 30 Mar 2023 08:11:08 +0000 (13:41 +0530)] 
util/base64: fix tests for RFC2045

(cherry picked from commit 49ad38329a3a96ba22e73da38b4594ebf8759ec9)

2 years agoutil/base64: update test macro to use user data
Shivani Bhardwaj [Thu, 30 Mar 2023 07:49:31 +0000 (13:19 +0530)] 
util/base64: update test macro to use user data

(cherry picked from commit c2ae87eecfafe6d46180c207c35c038035fe9c16)

2 years agoutil/base64: check dest buf size to hold 3Bytes
Shivani Bhardwaj [Thu, 30 Mar 2023 07:43:08 +0000 (13:13 +0530)] 
util/base64: check dest buf size to hold 3Bytes

The destination buffer should be able to hold at least 3 Bytes during
the processing of the last block of data. If it cannot hold at least 3
Bytes, then that may lead to dynamic buffer overflow while decoding.

(cherry picked from commit 62d782156caddec0b4ca795d7236c6483d02efff)

2 years agoutil/base64: check for dest buf size in last block
Shivani Bhardwaj [Thu, 30 Mar 2023 07:41:12 +0000 (13:11 +0530)] 
util/base64: check for dest buf size in last block

Just like the check for destination buffer size done previously for
complete data, it should also be done for the trailing data to avoid
goind out of bounds.

(cherry picked from commit 0e8b451699218b3f3430d7614f76cffed7ba991c)

2 years agoutil/base64: fix padding bytes for trailing data
Shivani Bhardwaj [Thu, 30 Mar 2023 07:24:29 +0000 (12:54 +0530)] 
util/base64: fix padding bytes for trailing data

Padding bytes for the last remainder data should be as follows:

Case   |    Remainder bytes     |    Padding
----------------------------------------------
  I    |              1         |      3
  II   |              2         |      2
  III  |              3         |      1

However, we calculate the decoded_bytes with the formula:
decoded_bytes = ASCII_BLOCK - padding

this means for Case I when padding is 3 bytes, the decoded_bytes would
be 0. This is incorrect for any trailing data. In any of the above
cases, if the parsing was successful, there should at least be 1 decoded
byte.

(cherry picked from commit 095c335c72befec2cfcd43390f86d116926bcd17)

2 years agoutil/base64: skip any invalid char for RFC2045
Shivani Bhardwaj [Fri, 17 Mar 2023 12:18:35 +0000 (17:48 +0530)] 
util/base64: skip any invalid char for RFC2045

RFC 2045 states that any invalid character should be skipped over, this
is the RFC used by mime handler in Suricata code to deal with base64
encoded data.
So far, only spaces were skipped as a part of implementation of this
RFC, extend it to also skip over any other invalid character. Add
corresponding test.

(cherry picked from commit e46b0337e50897424d05371aa26d5f20e172f749)

2 years agoutil/base64: add test for long string w RFC4648
Shivani Bhardwaj [Fri, 17 Mar 2023 12:15:32 +0000 (17:45 +0530)] 
util/base64: add test for long string w RFC4648

(cherry picked from commit 85ae1d25e4998d19cb1f7fd714027b3da1c8aa4e)

2 years agodecode: fix offset for DCE layer 9278/head
Philippe Antoine [Fri, 30 Jun 2023 08:45:37 +0000 (10:45 +0200)] 
decode: fix offset for DCE layer

Fixes: 136d351e403b ("decode: single network layer entrypoint")
Ticket: #3637
(cherry picked from commit fdf9cdf40068f00147bb07dd3f41a7556b8de823)

2 years agorust: fix compiler warnings 9277/head
Shivani Bhardwaj [Fri, 21 Jul 2023 12:23:49 +0000 (17:53 +0530)] 
rust: fix compiler warnings

2 years agodetect/multi-tenant: Make tenant_id 32 bits everywhere
Jeff Lucovsky [Wed, 21 Jun 2023 13:09:45 +0000 (09:09 -0400)] 
detect/multi-tenant: Make tenant_id 32 bits everywhere

Issue: 6047

This commit ensures that the tenant id is contained in a unsigned 32 bit
container.

(cherry picked from commit 9fd77c737f4f2d14f0e79df8958c21a3ccb3ed85)

2 years agodecode-ipv6: Set L4 proto on ipv6 incase of GRE decode error
Cole Dishington [Mon, 10 Jul 2023 02:02:18 +0000 (14:02 +1200)] 
decode-ipv6: Set L4 proto on ipv6 incase of GRE decode error

Set the L4 proto before decoding GRE in ipv6 decoding in case there is a
GRE header decoding error.

Bug: #6222
(cherry picked from commit 1b08c561f6f8f5ae3a1f29b68638f9884673fe58)

2 years agorust: lock proc-macro2 to maintain MSRV 9250/head
Victor Julien [Wed, 19 Jul 2023 05:15:46 +0000 (07:15 +0200)] 
rust: lock proc-macro2 to maintain MSRV

2 years agorfb: also set unimplemented auth types 9235/head 9249/head
Sascha Steinbiss [Fri, 30 Jun 2023 08:16:45 +0000 (10:16 +0200)] 
rfb: also set unimplemented auth types

(cherry picked from commit 1521b77edd04921a9b5f9419f84c62a812315e7a)

2 years agorfb: ensure logging of incompletely parsed txs
Sascha Steinbiss [Thu, 29 Jun 2023 22:20:12 +0000 (00:20 +0200)] 
rfb: ensure logging of incompletely parsed txs

(cherry picked from commit 1606aca881c5ba1c2cccbbe0de78530d47a4d8a1)

2 years agorfb: never return error on unknown traffic
Sascha Steinbiss [Fri, 9 Jun 2023 09:13:35 +0000 (11:13 +0200)] 
rfb: never return error on unknown traffic

We only try to parse a small subset of what is possible in
RFB. Currently we only understand some standard auth schemes
and stop parsing when the server-client handshake is complete.
Since in IPS mode returning an error from the parser causes
drops that are likely uncalled for, we do not want to return
errors when we simply do not understand what happens in the
traffic. This addresses Redmine #5912.

Bug: #5915.
(cherry picked from commit 1f8a5874fbc6816a7aeb59ba668ebd2bf7c206ed)

2 years agorfb: add myself as contributor
Sascha Steinbiss [Fri, 9 Jun 2023 09:12:24 +0000 (11:12 +0200)] 
rfb: add myself as contributor

(cherry picked from commit 836fff3679e6ea3b2ed75f87931ff3c7ec0ebd33)

2 years agorfb: be more strict parsing the version
Sascha Steinbiss [Fri, 9 Jun 2023 09:12:02 +0000 (11:12 +0200)] 
rfb: be more strict parsing the version

(cherry picked from commit bd1fbf392e04e0bfc4b8f7e680636ddee0a47c60)

2 years agorequirements: use libhtp 0.5.45
Victor Julien [Wed, 12 Jul 2023 17:31:00 +0000 (19:31 +0200)] 
requirements: use libhtp 0.5.45

(cherry picked from commit ce055111fe98d57d7e1c07e42abdd04a2f7d5319)

2 years agorequirements: suricata-update 1.2.8 9204/head
Jason Ish [Fri, 7 Jul 2023 18:05:43 +0000 (12:05 -0600)] 
requirements: suricata-update 1.2.8

2 years agodoc/devguide: language fix for sphinx
Jason Ish [Fri, 7 Jul 2023 18:34:48 +0000 (12:34 -0600)] 
doc/devguide: language fix for sphinx

Newer Sphinx does not allow a language of none, set to "en" like we do
for the user guide.

2 years agooutput/file: http2 metdata is logged in http object
Philippe Antoine [Fri, 16 Jun 2023 14:22:29 +0000 (16:22 +0200)] 
output/file: http2 metdata is logged in http object

as is done for http2 events and alerts.
The http.version integer can help to determine if this is HTTP2

Ticket: #6165
(cherry picked from commit 4f4651e360edf2916a648356db2e16ef1d560f7c)

2 years agoci: fix macos build with libhtp libiconv
Philippe Antoine [Thu, 6 Jul 2023 08:30:01 +0000 (10:30 +0200)] 
ci: fix macos build with libhtp libiconv

2 years agoci: update to macos latest
Philippe Antoine [Mon, 3 Jul 2023 13:23:19 +0000 (15:23 +0200)] 
ci: update to macos latest

(cherry picked from commit e1e03c25c9c4289e10bbcadd0fd86ab41a3e4003)

2 years agotls: update x509 crate to v0.8
Philippe Antoine [Fri, 30 Jun 2023 07:00:49 +0000 (09:00 +0200)] 
tls: update x509 crate to v0.8

Ticket: #5439

Fixes cetificate parsing without issuer, and do not require an
update to MSRV.