]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
13 months agochangelog: update 6.0.20 CVEs and titles master-6.0.x 11386/head 11390/head
Shivani Bhardwaj [Fri, 28 Jun 2024 07:33:43 +0000 (13:03 +0530)] 
changelog: update 6.0.20 CVEs and titles

13 months agoversion: start development towards 6.0.21
Shivani Bhardwaj [Fri, 28 Jun 2024 07:29:58 +0000 (12:59 +0530)] 
version: start development towards 6.0.21

13 months agorelease: 6.0.20; update changelog suricata-6.0.20
Shivani Bhardwaj [Wed, 26 Jun 2024 07:10:02 +0000 (12:40 +0530)] 
release: 6.0.20; update changelog

13 months agohttp2: do not expand duplicate headers
Philippe Antoine [Mon, 17 Jun 2024 14:30:49 +0000 (16:30 +0200)] 
http2: do not expand duplicate headers

Ticket: 7104

As this can cause a big mamory allocation due to the quadratic
nature of the HPACK compression.

(cherry picked from commit 5bd17934df321b88f502d48afdd6cc8bad4787a7)

13 months agodefrag: don't use completed tracker
Victor Julien [Tue, 4 Jun 2024 12:43:22 +0000 (14:43 +0200)] 
defrag: don't use completed tracker

When a Tracker is set up for a IPID, frags come in for it and it's
reassembled and complete, the `DefragTracker::remove` flag is set. This
is mean to tell the hash cleanup code to recyle the tracker and to let
the lookup code skip the tracker during lookup.

A logic error lead to the following scenario:

1. there are sufficient frag trackers to make sure the hash table is
   filled with trackers
2. frags for a Packet with IPID X are processed correctly (X1)
3. frags for a new Packet that also has IPID X come in quickly after the
   first (X2).
4. during the lookup, the frag for X2 hashes to a hash row that holds
   more than one tracker
5. as the trackers in hash row are evaluated, it finds the tracker for
   X1, but since the `remove` bit is not checked, it is returned as the
   tracker for X2.
6. reassembly fails, as the tracker is already complete

The logic error is that only for the first tracker in a row the `remove`
bit was checked, leading to reuse to a closed tracker if there were more
trackers in the hash row.

Ticket: #7042.

14 months agoci: fix macos build 11138/head 11140/head
Philippe Antoine [Tue, 23 Apr 2024 21:29:19 +0000 (23:29 +0200)] 
ci: fix macos build

use brew instead of pip
limit the number of jobs for make
set a prefix where we can install
use brew flags for library finding

(cherry picked from commit 47a1502dbb0d9ef43a820c956d0396c83b488e07)

14 months agorust/probing: safety check for null input
Philippe Antoine [Tue, 7 May 2024 14:33:00 +0000 (16:33 +0200)] 
rust/probing: safety check for null input

Ticket: 7013

Done consistently for all protocols

This may change some protocols behaviors which failed early
if they found there was not enough data...

(cherry picked from commit 37a9003736413b0bc9704099e189fd402922df43)

14 months agorust: return empty slice without using from_raw_parts
Philippe Antoine [Thu, 23 May 2024 12:05:08 +0000 (14:05 +0200)] 
rust: return empty slice without using from_raw_parts

As this triggers rustc 1.78
unsafe precondition(s) violated: slice::from_raw_parts requires
the pointer to be aligned and non-null,
and the total size of the slice not to exceed `isize::MAX`

Ticket: 7013
inspired from commit 5dc8dea8695786daec491a6655f99c0791e47f5c

15 months agorust: fix compilation error on MSRV 11019/head
Victor Julien [Sat, 4 May 2024 14:57:33 +0000 (16:57 +0200)] 
rust: fix compilation error on MSRV

Caused by:
  failed to parse manifest at `/builds/inliniac/suricata-ci/suricata/rust/vendor/num-traits/Cargo.toml`

Caused by:
  failed to parse the `edition` key

Caused by:
  supported edition values are `2015` or `2018`, but `2021` is unknown

Lock to last working version 0.2.18.

Ticket: #7007.

15 months agodetect/alert: Drop packet if rule is pkt only 10963/head
Jeff Lucovsky [Thu, 7 Sep 2023 14:49:23 +0000 (10:49 -0400)] 
detect/alert: Drop packet if rule is pkt only

This commit modifies the logic used to determine the disposition of a
flow/packet.

If the rule doesn't require a stream and only contains properties for
packet matching, then the alert is not marked as applying to the
flow and hence, the flow won't be dropped.

Issue: 5578

15 months agoversion: start development towards 6.0.20 10932/head 10945/head
Shivani Bhardwaj [Tue, 23 Apr 2024 13:03:18 +0000 (18:33 +0530)] 
version: start development towards 6.0.20

15 months agorelease: 6.0.19; update changelog suricata-6.0.19
Shivani Bhardwaj [Tue, 23 Apr 2024 05:16:16 +0000 (10:46 +0530)] 
release: 6.0.19; update changelog

15 months agohttp2: fix for rustc 1.41.1
Victor Julien [Mon, 22 Apr 2024 13:41:12 +0000 (15:41 +0200)] 
http2: fix for rustc 1.41.1

Co-authored-by: Philippe Antoine <pantoine@oisf.net>
15 months agohttp2: do not log duplicate headers
Philippe Antoine [Thu, 28 Mar 2024 10:15:51 +0000 (11:15 +0100)] 
http2: do not log duplicate headers

Ticket: 6900

And thus avoid DOS by logging a request using a compressed
header block repeated many times and having a long value...

(cherry picked from commit 03442c9071b8d863d26b609d54c6eacf4de9e340)

15 months agohttp2: use a reference counter for headers
Philippe Antoine [Wed, 27 Mar 2024 13:33:54 +0000 (14:33 +0100)] 
http2: use a reference counter for headers

Ticket: 6892

As HTTP hpack header compression allows one single byte to
express a previously seen arbitrary-size header block (name+value)
we should avoid to copy the vectors data, but just point
to the same data, while reamining memory safe, even in the case
of later headers eviction from the dybnamic table.

Rust std solution is Rc, and the use of clone, so long as the
data is accessed by only one thread.

(cherry picked from commit 390f09692eb99809c679d3f350c7cc185d163e1a)

15 months agodetect/parse: set limits for pcre2
Philippe Antoine [Sun, 24 Mar 2024 20:12:15 +0000 (21:12 +0100)] 
detect/parse: set limits for pcre2

Ticket: 6889

To avoid regexp dos with too much backtracking.
This is already done on pcre keyword, and pcrexform transform.
We use the same default limits for rules parsing.

(cherry picked from commit 316cc528f784c86339d05907a4d6084cbe4d44e6)

Using pcre1 in master6

15 months agoutil/base64: fix buffer overflow
Philippe Antoine [Thu, 28 Mar 2024 13:00:02 +0000 (14:00 +0100)] 
util/base64: fix buffer overflow

Ticket: 6902

In case the caller of DecodeBase64 does not supply a big enough
output buffer.

(cherry picked from commit fd47e67dc65f9111895c88fb406c938b1f857325)

15 months agodefrag: fix check for complete packet
Jason Ish [Fri, 12 Jan 2024 17:09:59 +0000 (11:09 -0600)] 
defrag: fix check for complete packet

The list of fragments may still contain overlaps, so adding up the
fragment lengths is flawed. Instead track the largest size of
contiguous data that can be re-assembled.

Bug: #6675
(cherry picked from commit d226d0a3fce8837936e1bdfaee496c80d417e0a5)

15 months agodefrag: fix subsequent overlap of start of original (bsd)
Jason Ish [Thu, 7 Dec 2023 22:44:56 +0000 (16:44 -0600)] 
defrag: fix subsequent overlap of start of original (bsd)

Fix the BSD policy case where a subsequent fragment starts before an
original fragment and overlaps the beginning of the original
fragment. In this case the overlapping data from the new fragment is
preferred.

Suricata was preferring the data from the original fragment, but it
should only do that when the original fragment has an offset <= to the
new fragment.

- Adds tests for this case

Bug: #6669
(cherry picked from commit f1709ea551124e1a64fdc509993ad022ab27aa77)

15 months agodefrag: check next fragment for overlap before stopping re-assembly
Jason Ish [Tue, 28 Nov 2023 18:35:26 +0000 (12:35 -0600)] 
defrag: check next fragment for overlap before stopping re-assembly

Instead of breaking the loop when the current fragment does not have
any more fragments, set a flag and continue to the next fragment as
the next fragment may have data that occurs before this fragment, but
overlaps it.

Then break if the next fragment does not overlap the previous.

Bug: #6668
(cherry picked from commit d0fd0782505d837e691ceef1b801776f0db82726)

15 months agodefrag: use uint8_t in unit tests
Jason Ish [Fri, 12 Jan 2024 15:26:22 +0000 (09:26 -0600)] 
defrag: use uint8_t in unit tests

(cherry picked from commit bdd17de73d6507a02729e069d31c590a760fb9b7)

15 months agodefrag: consistent unit test naming
Jason Ish [Mon, 27 Nov 2023 22:27:27 +0000 (16:27 -0600)] 
defrag: consistent unit test naming

Use a more consistent naming scheme between ipv4 and ipv6.

(cherry picked from commit 2f00b5870abc6053fca8271a0a827babc03d56f0)

15 months agodefrag: make tests more readable
Jason Ish [Mon, 27 Nov 2023 21:59:23 +0000 (15:59 -0600)] 
defrag: make tests more readable

Make tests more readable for comparing to the paper "Target-Based
Fragmentation Reassembly".

(cherry picked from commit 6339deadceaf84654b62d23f3292cb514d6587a5)

15 months agodefrag: minor cleanups
Jason Ish [Fri, 8 Dec 2023 22:27:12 +0000 (16:27 -0600)] 
defrag: minor cleanups

- typo in comment
- remove debug function that is not used and no longer valid

(cherry picked from commit 276d3d6541327891b027bd5e3ee7994c58ea3fb3)

15 months agodetect/iponly: fix compile warning 10895/head
Victor Julien [Wed, 17 Apr 2024 22:28:50 +0000 (00:28 +0200)] 
detect/iponly: fix compile warning

When --enable-unittests w/o --enable-debug is used.

15 months agodetect/http: fix compile warning in body tests
Victor Julien [Thu, 28 Mar 2024 09:43:46 +0000 (10:43 +0100)] 
detect/http: fix compile warning in body tests

When --enable-unittests w/o --enable-debug is used.

(cherry picked from commit e651cf922a02f5882593a23bd2ed9327a5e8d2cc)

15 months agopcap: support LINKTYPE_IPV6 (229)
Victor Julien [Fri, 12 Apr 2024 09:02:13 +0000 (11:02 +0200)] 
pcap: support LINKTYPE_IPV6 (229)

This is just another variant of DLT_RAW.

Ticket: #6943.
(cherry picked from commit 76322368ed3ef89c04082939c58535c7234d7173)

15 months agodefrag: fix wrong datalink being logged
Victor Julien [Sat, 23 Mar 2024 19:17:54 +0000 (20:17 +0100)] 
defrag: fix wrong datalink being logged

Eve's packet_info.linktype should correctly indicated what the `packet`
field contains. Until now it was using DLT_RAW even if Ethernet or other
L2+ headers were present.

This commit records the datalink of the packet creating the first
fragment, which can include the L2+ header data.

Bug: #6887.
(cherry picked from commit 49c67b2bb1baa84b7105bca82afe6909be890855)

15 months agodefrag: match up v4 and v6 packet setup
Victor Julien [Sun, 3 Dec 2023 20:15:36 +0000 (21:15 +0100)] 
defrag: match up v4 and v6 packet setup

v4 was doing redundant recursion level setup.

v6 was missing PKT_REBUILT_FRAGMENT flag.

(cherry picked from commit af97316f42c6616536dc8012577827fee9a56f11)

15 months agorust/mqtt: fix clippy 1.77 warning
Philippe Antoine [Thu, 21 Mar 2024 21:45:41 +0000 (22:45 +0100)] 
rust/mqtt: fix clippy 1.77 warning

error: creating a mutable reference to mutable static is discouraged
   --> src/mqtt/mqtt.rs:752:23
    |
752 |     let max_msg_len = &mut MAX_MSG_LEN;
    |                       ^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
    = note: this will be a hard error in the 2024 edition
    = note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior

15 months agorust: fix clippy 1.77 warning
Philippe Antoine [Thu, 21 Mar 2024 15:02:23 +0000 (16:02 +0100)] 
rust: fix clippy 1.77 warning

Ticket: 6883

error: field `0` is never read
  --> src/asn1/mod.rs:36:14
   |
36 |     BerError(Err<der_parser::error::BerError>),
   |     -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     field in this variant
   |

(cherry picked from commit 02f2fb88333af767ab3b171643357d607f4e86f6)

15 months agoconf: avoid quadratic complexity 10875/head
Philippe Antoine [Thu, 21 Mar 2024 08:38:25 +0000 (09:38 +0100)] 
conf: avoid quadratic complexity

Ticket: 6878

Follow up on 15649424a76d01eb332d85620ffc4956d4f3d9be

When adding many sequence nodes, either from start or scalar event

We add "sequence nodes" whose name is an integer cf sequence_node_name
and then run ConfNodeLookupChild to see if it had been already set
(from the command line cf comment in the code)
And ConfNodeLookupChild iterates the whole linked list...

1. We add node 1
2. To add node 2, we check if node 1 equals this new node
3. To add node 3, we check if nodes 1, or 2 equals this new node's name
And so on...

This commits avoids these checks ig the list is empty at the beginning

(cherry picked from commit 240e068b81275e287ffe6555d4c457a0b3916066)

16 months agoversion: start development towards 6.0.19 10699/head 10704/head
Shivani Bhardwaj [Fri, 22 Mar 2024 10:20:27 +0000 (15:50 +0530)] 
version: start development towards 6.0.19

16 months agorelease: 6.0.18; update changelog suricata-6.0.18
Shivani Bhardwaj [Thu, 21 Mar 2024 06:32:55 +0000 (12:02 +0530)] 
release: 6.0.18; update changelog

16 months agorust: fix build with MSRV 10679/head
Philippe Antoine [Wed, 20 Mar 2024 08:56:34 +0000 (09:56 +0100)] 
rust: fix build with MSRV

Ticket: 6876

Do not backport try_string_from_bytes as it uses try_reserve
And just use string_from_bytes instead

Fixes: b9963b3e2919 ("ssh: limit length for banner logs")
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)

22 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)

22 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)