]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
27 hours agoci: use debian 12 for xdp main-7.0.x 13687/head
Philippe Antoine [Wed, 23 Jul 2025 08:37:41 +0000 (10:37 +0200)] 
ci: use debian 12 for xdp

As bullseye is EOL so it is being removed from the mirrors

https://lists.debian.org/debian-backports/2024/07/msg00003.html

[Edit by JI: Add xdp to distcheck build as well.]

(cherry picked from commit 6bbba953dfe599d268c91f485a17dc9f5c88a7fd)

27 hours agohtp/test: fix test to pass with UBSAN
Philippe Antoine [Fri, 18 Jul 2025 09:00:52 +0000 (11:00 +0200)] 
htp/test: fix test to pass with UBSAN

Ticket: 6934

Avoids a call to memcpy with NULL ptr and 0 length

27 hours agogithub-ci/builds: don't run if only doc changes
Jason Ish [Tue, 25 Jun 2024 18:51:33 +0000 (12:51 -0600)] 
github-ci/builds: don't run if only doc changes

A new workflow, "docs" has been created for only doc changes.

Factor out prepare-deps into a reusable action.

(cherry picked from commit a0cb7b21f4f52494f8000f48f8690f28e6b74d8c)

27 hours agodoc: document krb5 event type
Philippe Antoine [Tue, 17 Jun 2025 12:01:42 +0000 (14:01 +0200)] 
doc: document krb5 event type

Ticket: 6566
(cherry picked from commit 4d4eb84eca29ff0f7083cc17e862a284502a745b)

27 hours agodoc: do not have bittorrent in the middle of SMB events
Philippe Antoine [Tue, 17 Jun 2025 11:42:39 +0000 (13:42 +0200)] 
doc: do not have bittorrent in the middle of SMB events

(cherry picked from commit f907216e1ac7d3334114dff37fb8b6169fb0ffa7)

2 weeks agogithub-ci: remove debian:10 build, it is EOL 13603/head 13612/head
Jason Ish [Mon, 14 Jul 2025 14:43:37 +0000 (08:43 -0600)] 
github-ci: remove debian:10 build, it is EOL

(cherry picked from commit 2e69e0d5c16c35ea05497c378fa03908824fe5e4)

3 weeks agoversion: start development towards 7.0.12 13576/head 13586/head
Shivani Bhardwaj [Wed, 9 Jul 2025 05:56:05 +0000 (11:26 +0530)] 
version: start development towards 7.0.12

4 weeks agorelease: 7.0.11; update changelog suricata-7.0.11
Shivani Bhardwaj [Tue, 8 Jul 2025 07:07:25 +0000 (12:37 +0530)] 
release: 7.0.11; update changelog

4 weeks agohttp2: do not set file flags for global txs
Philippe Antoine [Tue, 15 Apr 2025 10:38:34 +0000 (12:38 +0200)] 
http2: do not set file flags for global txs

Global txs means here txs with stream id 0, used for connection control
messages.

(cherry picked from commit fa8d3a4ccb17f84ccc577069a941a589b6e3906c)

4 weeks agohttp2: mark old txs as updated
Philippe Antoine [Tue, 15 Apr 2025 10:36:47 +0000 (12:36 +0200)] 
http2: mark old txs as updated

As is done in the other case a few lines below

(cherry picked from commit 349c21af2c04494e374aeeea2b8bc1feafea12ff)

4 weeks agohttp2: forbid data on stream 0
Philippe Antoine [Tue, 15 Apr 2025 10:34:37 +0000 (12:34 +0200)] 
http2: forbid data on stream 0

Ticket: 7658

Suricata will not handle well if we open a file for this tx,
do not close it, but set the transaction state to completed.

RFC 9113 section 6.1 states:

If a DATA frame is received whose Stream Identifier field is 0x00,
the recipient MUST respond with a connection error (Section 5.4.1)
 of type PROTOCOL_ERROR.

(cherry picked from commit 1d6d331752e933c46aca0ae7a9679b27462246e3)

5 weeks agorust/smb: fix manual_unwrap_or_default 13540/head 13544/head
Philippe Antoine [Fri, 27 Jun 2025 07:42:59 +0000 (09:42 +0200)] 
rust/smb: fix manual_unwrap_or_default

warning: match can be simplified with `.unwrap_or_default()`
   --> src/smb/smb2.rs:682:41
    |
682 |                           let _guid_vec = match state.ssn2vec_map.remove(&guid_key) {
    |  _________________________________________^
683 | |                             Some(p) => p,
684 | |                             None => {
685 | |                                 SCLogDebug!("SMBv2 response: GUID NOT FOUND");
686 | |                                 Vec::new()
687 | |                             },
688 | |                         };
    | |_________________________^ help: replace it with: `state.ssn2vec_map.remove(&guid_key).unwrap_or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
    = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default

5 weeks agorust: allow collapsible_else_if for debug logs
Philippe Antoine [Fri, 27 Jun 2025 07:20:56 +0000 (09:20 +0200)] 
rust: allow collapsible_else_if for debug logs

see https://github.com/rust-lang/rust-clippy/issues/15158

5 weeks agorust: make cargo clippy clean
Philippe Antoine [Tue, 16 Jan 2024 10:47:30 +0000 (11:47 +0100)] 
rust: make cargo clippy clean

Fixing single_match and manual_find intertwined with SCLogDebug

(cherry picked from commit 38db51b8789e9f930ff093f592b5763edb190f43)

5 weeks agorust/dns: fix clippy char_indices_as_byte_indices
Philippe Antoine [Fri, 27 Jun 2025 07:31:24 +0000 (09:31 +0200)] 
rust/dns: fix clippy char_indices_as_byte_indices

error: indexing into a string with a character position where a byte index is expected
  --> src/dns/detect.rs:45:39
   |
45 |                 let code: u8 = opcode[i..].parse().map_err(|_| ())?;
   |                                       ^
   |
   = note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
  --> src/dns/detect.rs:36:10
   |
36 |     for (i, c) in opcode.chars().enumerate() {
   |          ^                       ^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#char_indices_as_byte_indices
   = note: `#[deny(clippy::char_indices_as_byte_indices)]` on by default
help: consider using `.char_indices()` instead
   |
36 -     for (i, c) in opcode.chars().enumerate() {
36 +     for (i, c) in opcode.char_indices() {

5 weeks agothreading: fix shutdown of IPS autofp modes 13538/head
Victor Julien [Tue, 10 Jun 2025 09:33:03 +0000 (11:33 +0200)] 
threading: fix shutdown of IPS autofp modes

For IPS modes with a verdict thread in autofp there was an issue with
the verdict thread not shutting down, leading to a long shutdown time
until an error condition was reached.

The problem was that when the packet threads, of which the verdict
thread is one, were told to enter their flow timeout loop the verdict
thread got stuck as it immediately progressed to THV_RUNNING_DONE
instead of the expected THV_FLOW_LOOP.

This patch updates the shutdown logic to only apply the flow timeout
logic to the relevant threads, and skip the verdict thread(s).

Add TM_FLAG_VERDICT_TM to indicate a thread has a verdict module to more
explicitly shut it down.

Fixes: 12f8f03532e5 ("threads: fix autofp shutdown race condition")
Bug: #7681.
(cherry picked from commit bdac028fc7ea97f0e50fbd0a24d995bced81c490)

5 weeks agoflow: fix unittests for ThreadVars requirement
Victor Julien [Tue, 6 May 2025 17:42:48 +0000 (19:42 +0200)] 
flow: fix unittests for ThreadVars requirement

(cherry picked from commit ee59d9a894ba6d396e98becc7aa7a8484f7f0f60)

5 weeks agoflow: fix time handling for non-TCP
Victor Julien [Tue, 6 May 2025 13:30:30 +0000 (15:30 +0200)] 
flow: fix time handling for non-TCP

Track per flow thread id for UDP and other non-TCP protocols. This
improves the timeout handling as the per thread timestamp is used in
offline mode.

Fixes: ada2bfe00966 ("flow/worker: improve flow timeout time accuracy")
Fixes: ef396f7509cc ("flow/manager: in offline mode, use owning threads time")
Bug #7687.

(cherry picked from commit c648abad0d7393135de0d547b0a8f03ce5af2693)

5 weeks agothreads: fix autofp shutdown race condition
Victor Julien [Wed, 30 Apr 2025 08:20:10 +0000 (10:20 +0200)] 
threads: fix autofp shutdown race condition

Sometimes a single flow pcap would log 2 flows. It turns out FlowWorkToDoCleanup
ran before all the packet threads had processed their "wire" packets. It then
removed a flow that a wire packet would still have needed, leading to the worker
thread creating a new flow for it.

This could happen due to the logic in TmThreadDisableReceiveThreads which calls
TmThreadDrainPacketThreads to made sure it only returns when all autofp-workers
have processed all the packets the autofp-capture thread fed to them.

However, the way it checked this is by checking the size of the autofp-worker's
input queue. If 0, it assumes it is done.

What this missed, is that a worker thread could have just taken the last packet
from the input queue, but it is not yet done processing it. If then the
FlowWorkToDoCleanup is ran as well, it would race the worker thread to the flow
handling logic. When it won, the flow was evicted and the packet thread
created a new flow.

This patch improves the shutdown logic to force the worker threads to
enter a "flow loop" (THV_FLOW_LOOP) state before moving on to the
FlowWorkToDoCleanup step. This makes sure that any in progress packets
in the worker threads have been processed.

Bug: #7681.
(cherry picked from commit 12f8f03532e57fe8168c40d6a14b34b8954bd3e5)

5 weeks agothreads: pktacq loop cleanup
Victor Julien [Fri, 20 Jun 2025 09:03:07 +0000 (11:03 +0200)] 
threads: pktacq loop cleanup

Manual backport of relevant bits from:
35d7d77ddb05 ("threads: refactor TmThreadsSlotPktAcqLoop for user threads")

5 weeks agothreads: remove unused flag
Victor Julien [Wed, 30 Apr 2025 07:10:32 +0000 (09:10 +0200)] 
threads: remove unused flag

(cherry picked from commit b42eea67d5effe5bc6194877d23c9fdf060214eb)

5 weeks agopcap-file: document capture method options
Lukas Sismis [Sun, 27 Apr 2025 13:04:29 +0000 (15:04 +0200)] 
pcap-file: document capture method options

(cherry picked from commit eb52e337da3a7d123a76a1a17f54337a5c76d88d)

5 weeks agodoc: update available options in the example config
Lukas Sismis [Sun, 27 Apr 2025 11:32:33 +0000 (13:32 +0200)] 
doc: update available options in the example config

(cherry picked from commit e780a20f82896effeb56556af1642a1db1530500)

5 weeks agoflow-manager: move time check after RUNNNING state change
Lukas Sismis [Sun, 27 Apr 2025 10:56:02 +0000 (12:56 +0200)] 
flow-manager: move time check after RUNNNING state change

When running in pcap-file mode and with a continous directory
reading, the provided directory can be empty.
By having no packets and being in offline mode, the initial packet timestamp
is never set. However, Flow Manager waited until the timestamp was set
to proceed with transferring its state to "RUNNING".
Other pcap-related threads (RX / workers) are set in RUNNING state while
waiting for the PCAP to appear in the directory.

As a result, the main Suricata-Main thread timed out after the default
60 seconds budget for threads to turn from INIT_DONE to RUNNING state.

Ticket: 7661
(cherry picked from commit 58df9703913201c8eecaea5c3b9bd6fb79eb7128)

6 weeks agodpdk: use default iface-copy value if not specified 13524/head
Lukas Sismis [Tue, 4 Feb 2025 09:17:46 +0000 (10:17 +0100)] 
dpdk: use default iface-copy value if not specified

Ticket: 7375
(cherry picked from commit 31fbfc322c32e9932288862eb607012558e36c30)

6 weeks agoutil/mpm: grow state queue on demand 13489/head 13490/head
Philippe Antoine [Tue, 17 Jun 2025 13:06:27 +0000 (15:06 +0200)] 
util/mpm: grow state queue on demand

Ticket: 7678
(cherry picked from commit 9f83662f2035eb1090e804acf8995b17d08bf1d1)

6 weeks agoutil/mpm: factorize code
Philippe Antoine [Tue, 17 Jun 2025 13:06:08 +0000 (15:06 +0200)] 
util/mpm: factorize code

(cherry picked from commit 679bd23cb70a7299f1b7f56275a334d7f1b15d78)

6 weeks agompm: allocate StateQueue on the heap for ks
Philippe Antoine [Tue, 17 Jun 2025 08:35:55 +0000 (10:35 +0200)] 
mpm: allocate StateQueue on the heap for ks

Completes commit 92fce2fdc069324e6060ce046ca80da6a351573c

Ticket: 6264
(cherry picked from commit 330cff94e86ee3be8ced0ad4ed7bde3999f795e9)

7 weeks agodetect/content: account for distance variables 13440/head
Jeff Lucovsky [Tue, 17 Dec 2024 12:56:42 +0000 (07:56 -0500)] 
detect/content: account for distance variables

Under some cases (below), the depth and offset values are used
twice. This commit disregards the distance variable (if any), when
computing the final depth.

These rules are logically equivalent::
1. alert tcp any any -> any 8080 (msg:"distance name"; flow:to_server; content:"Authorization:"; content:"5f71ycy"; distance:0; byte_extract:1,0,option_len,string,relative; content:!"|38|"; distance:option_len; within:1; content:"|37|"; distance:-1; within:1; content:"|49|"; distance:option_len; within:1; sid:1;)
2. alert tcp any any -> any 8080 (msg:"distance number"; flow:to_server; content:"Authorization:"; content:"5f71ycy"; distance:0; byte_extract:1,0,option_len,string,relative; content:!"|38|"; distance:7; within:1; content:"|37|"; distance:-1; within:1; content:"|49|"; distance:option_len; within:1; sid:2;)

The differences:
Rule 1: content:!"|38|"; distance:option_len; within:1; //option_len == 7

Rule 2: content:!"|38|"; distance:7; within:1;

Without this commit, rule 2 triggers an alert but rule 1 doesn't.

Issue: 7390
(cherry picked from commit ace0d3763674a8dc624ad1f1744ea7442cd86d43)

7 weeks agorust: update brotli crate to latest version 13438/head
Philippe Antoine [Tue, 3 Jun 2025 18:33:52 +0000 (20:33 +0200)] 
rust: update brotli crate to latest version

Ticket: 7735

New version has a fix for an integer underflow

(cherry picked from commit 97591230a9de763084a166783a0dc6d89792a02d)

2 months agodcerpc: use wrapping to prevent u16 overflow 13371/head
Philippe Antoine [Mon, 2 Jun 2025 20:31:19 +0000 (22:31 +0200)] 
dcerpc: use wrapping to prevent u16 overflow

Otherwise, rust with debug assertion may trigger a panic

Ticket: 7730

(cherry picked from commit 261d2ad63bb3bdd00b9ce40086adc9b1bf73156a)

2 months agosnmp: probing parser returns unknown if not enough data 13299/head
Philippe Antoine [Wed, 21 May 2025 12:48:15 +0000 (14:48 +0200)] 
snmp: probing parser returns unknown if not enough data

Ticket: 7019
(cherry picked from commit 54a3a18a9e0af5e08cbe012ee23d6225dd6ae9cd)

2 months agoscripts: clang-format can use a different base than master 13296/head
Philippe Antoine [Tue, 20 May 2025 13:12:15 +0000 (15:12 +0200)] 
scripts: clang-format can use a different base than master

useful for git hook running on main-7.0.x branches so that
not every commit gets its format checked again.

Ticket: 7292
(cherry picked from commit cca169f307126cb2b85ac27b0c9b0e3b17daa418)

2 months agodatasets: fix set with ip sets 13270/head 13280/head
Eric Leblond [Tue, 6 May 2025 16:17:08 +0000 (18:17 +0200)] 
datasets: fix set with ip sets

It can get an IPv6 or an IPv4 so we need to handle both length.

Ticket: #7689
(cherry picked from commit e499a98ba995ac25b40c5957faeff11c88410e93)

2 months agogithub-ci: use current directory for unit test logging 13229/head
Jason Ish [Fri, 9 May 2025 16:26:00 +0000 (10:26 -0600)] 
github-ci: use current directory for unit test logging

/tmp appears to exist when you make it, but doesn't appear to actually
exist after msys translation, so just use "."

(cherry picked from commit 11cef2980be3626153c82ebe3a2ca7485651dcd2)

2 months agodetect: don't set conflicting packet/flow actions 13222/head
Victor Julien [Tue, 13 May 2025 09:26:46 +0000 (11:26 +0200)] 
detect: don't set conflicting packet/flow actions

If for the same a packet a drop rule and a pass rule would match,
the applying of actions could be contradictionary:

- the drop would be applied to the packet
- the pass rule would also be considered, not overriding the drop,
  but still setting the flow pass flag.

This would lead to the packet being dropped, but the rest of the
flow getting passed, including retransmissions of the dropped
packet.

This patch only sets drop/pass actions if no conflicting action
has been set on the packet before. It respects the action-order.

Bug: #7653.

Fix based on:
57b17fb3b2fb ("detect: don't set conflicting packet/flow actions")

3 months agodetect: do not bug on tx data being NULL 13102/head 13110/head
Philippe Antoine [Mon, 28 Apr 2025 08:56:54 +0000 (10:56 +0200)] 
detect: do not bug on tx data being NULL

Ticket: 7610

As this can happen for HTTP1 in Suricata 7

This was fixed in Suricata 8 by f301cd370205af7e069680c286252304ab128214
and 833a738dd1429f63c79d95edf25bb86fcc15b51a from ticket 5739

3 months agodnp3: mark tx as updated when creating it 13066/head 13082/head
Philippe Antoine [Sat, 19 Apr 2025 19:28:16 +0000 (21:28 +0200)] 
dnp3: mark tx as updated when creating it

Ticket: 7668

We should set updated_tx when allocating a dnp3 tx

(cherry picked from commit e41c28f7c93c5a447b82abc7f93f1187ede92a43)

3 months agoftp: mark tx as updated when creating it
Philippe Antoine [Sat, 19 Apr 2025 19:27:01 +0000 (21:27 +0200)] 
ftp: mark tx as updated when creating it

Ticket: 7668

We should set updated_tx when allocating a ftp tx

Was already done right for updated_tc

(cherry picked from commit f24d3ffb74055b1bd1bc6eed0feeb0261a5cad78)

3 months agohttp1: always mark tx as updated on request/response start
Philippe Antoine [Sat, 19 Apr 2025 19:21:31 +0000 (21:21 +0200)] 
http1: always mark tx as updated on request/response start

Ticket: 7668

We should set updated_tx when allocating HtpTxUserData

(cherry picked from commit a5b987266b2180e074d8fe5cf444739d9a5bdc91)

3 months agorust: fix clippy warning manual_contains 13012/head 13030/head
Philippe Antoine [Thu, 3 Apr 2025 11:43:29 +0000 (13:43 +0200)] 
rust: fix clippy warning manual_contains

warning: using `contains()` instead of `iter().any()` is more efficient
   --> src/http2/http2.rs:267:20
    |
267 |                 if block.value.iter().any(|&x| x == b'@') {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `block.value.contains(&b'@')`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_contains
    = note: `#[warn(clippy::manual_contains)]` on by default

(cherry picked from commit 0f3932afb78680c8af167f2089f52e0342431b1f)

3 months agorust: fix rustdoc indentation in lists 12999/head 13002/head
Jason Ish [Wed, 9 Apr 2025 16:53:50 +0000 (10:53 -0600)] 
rust: fix rustdoc indentation in lists

Ticket: #7652

3 months agorust: fix clippy warnings for unspecified extern ABI
Jason Ish [Wed, 9 Apr 2025 16:45:50 +0000 (10:45 -0600)] 
rust: fix clippy warnings for unspecified extern ABI

Fix done by clippy --fix.

Ticket: #7652

3 months agoversion: start development towards 7.0.11
Jason Ish [Wed, 9 Apr 2025 16:44:10 +0000 (10:44 -0600)] 
version: start development towards 7.0.11

4 months agofuzz: set flow flags as in Suricata 12864/head 12868/head
Philippe Antoine [Mon, 24 Mar 2025 15:11:44 +0000 (16:11 +0100)] 
fuzz: set flow flags as in Suricata

Fixes: d8ddef4c1485 ("detect: delay tx cleanup in some edge case")
(cherry picked from commit 09aed7e243127741721bd3e490c73d344234b17a)

4 months agogithub-ci: don't run builds on PR if only docs changed 12834/head
Jason Ish [Sun, 9 Mar 2025 09:27:18 +0000 (10:27 +0100)] 
github-ci: don't run builds on PR if only docs changed

(cherry picked from commit 3658d502fff9fb981d670aa79956a0f26e3cab2c)

4 months agogithub-ci: update Fedora non-root build to Fedora 41
Jason Ish [Thu, 6 Mar 2025 13:48:09 +0000 (14:48 +0100)] 
github-ci: update Fedora non-root build to Fedora 41

(cherry picked from commit 65b863b087d8f6d7c0800700f89ca33f06ad861f)

4 months agogithub-ci: remove fedora 40 builds where 41 exists
Jason Ish [Thu, 6 Mar 2025 13:46:48 +0000 (14:46 +0100)] 
github-ci: remove fedora 40 builds where 41 exists

Remove Fedora 40 builds where there is a Fedora 41 equivalent.

(cherry picked from commit 70d5bae160250457e040b138d9c399491561eb3a)

4 months agogithub-ci: update Fedora 39 jobs to 41
Victor Julien [Mon, 6 Jan 2025 13:42:31 +0000 (14:42 +0100)] 
github-ci: update Fedora 39 jobs to 41

(cherry picked from commit c56b741088cd95c46ab5840588c4ef37bb2f89f3)

4 months agogithub-ci: bump known rust ver to 1.85.1
Victor Julien [Wed, 26 Mar 2025 13:48:14 +0000 (14:48 +0100)] 
github-ci: bump known rust ver to 1.85.1

4 months agorelease: 7.0.10; update changelog suricata-7.0.10
Shivani Bhardwaj [Tue, 25 Mar 2025 02:03:48 +0000 (07:33 +0530)] 
release: 7.0.10; update changelog

4 months agodetect: add padding to suppress scan-build warning 12793/head 12806/head
Victor Julien [Wed, 19 Mar 2025 19:35:36 +0000 (20:35 +0100)] 
detect: add padding to suppress scan-build warning

Add to DetectEngineCtx to avoid:

./detect.h:840:16: warning: Excessive padding in 'struct DetectEngineCtx_' (32 padding bytes, where 0 is optimal). Optimal fields order: sig_list, srepCIDR_ctx, sig_array, sc_sig_order_funcs, sgh_hash_table, mpm_hash_table, pattern_hash_table, dup_sig_hash_table, spm_global_thread_ctx, mpm_ctx_factory_container, sgh_array, decoder_event_sgh, rule_file, sigerror, keyword_hash, next, dport_hash_table, tcp_whitelist, udp_whitelist, address_table, metadata_table, buffer_type_hash_name, buffer_type_hash_id, app_mpms_list, app_inspect_engines, pkt_inspect_engines, pkt_mpms_list, frame_inspect_engines, frame_mpms_list, prefilter_hash_table, fp_support_smlist_list, class_conf_ht, class_conf_regex, class_conf_regex_match, reference_conf_ht, reference_conf_regex, reference_conf_regex_match, ea, tenant_path, requirements, last_reload, sig_stat, ths_ctx, io_ctx, flow_gh, tenant_id, sig_cnt, srep_version, sig_array_size, sig_array_len, signum, non_pf_store_cnt_max, inspection_recursion_limit, filemagic_thread_ctx_id, max_fb_id, sgh_array_cnt, sgh_array_size, sgh_mpm_context_proto_tcp_packet, sgh_mpm_context_proto_udp_packet, sgh_mpm_context_proto_other_packet, sgh_mpm_context_stream, byte_extract_max_local_id, version, rule_line, keyword_id, type, ref_cnt, loader_id, prefilter_setting, buffer_type_id, app_mpms_list_cnt, pkt_mpms_list_cnt, frame_mpms_list_cnt, prefilter_id, filedata_config, max_uniq_toclient_groups, max_uniq_toserver_groups, base64_decode_max_len, filestore_cnt, failure_fatal, flags, mpm_matcher, spm_matcher, guess_applayer, sigerror_silent, sigerror_ok, sigerror_requires, filedata_config_initialized, sgh_mpm_ctx_cnf, config_prefix, sm_types_prefilter, sm_types_silent_error, consider reordering the fields or adding explicit padding members [optin.performance.Padding]
  840 | typedef struct DetectEngineCtx_ {
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~
  841 |     bool failure_fatal;
      |     ~~~~~~~~~~~~~~~~~~~
  842 |     uint8_t flags;       /**< only DE_QUIET */
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  843 |     uint8_t mpm_matcher; /**< mpm matcher this ctx uses */
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  844 |     uint8_t spm_matcher; /**< spm matcher this ctx uses */
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  845 |
  846 |     uint32_t tenant_id;
      |     ~~~~~~~~~~~~~~~~~~~
  847 |
  848 |     Signature *sig_list;
      |     ~~~~~~~~~~~~~~~~~~~~
  849 |     uint32_t sig_cnt;
      |     ~~~~~~~~~~~~~~~~~
  850 |
  851 |     /* version of the srep data */
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  852 |     uint32_t srep_version;
      |     ~~~~~~~~~~~~~~~~~~~~~~
  853 |
  854 |     /* reputation for netblocks */
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  855 |     SRepCIDRTree *srepCIDR_ctx;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

4 months agoaf-packet: use actual snaplen in bpf 12786/head
Victor Julien [Wed, 19 Mar 2025 06:03:01 +0000 (07:03 +0100)] 
af-packet: use actual snaplen in bpf

Avoids setting a 0 snaplen in BPF, leading to an error.

Fixes: b8b6ed550a6f ("af-packet: delay setting default-packet-size for af-packet")
Ticket: #7618.
(cherry picked from commit 749ffbd06a9034bfa0dec2ea6899d9cb9f8833f9)

4 months agodatasets: work around scan-build warning
Victor Julien [Tue, 18 Mar 2025 21:26:53 +0000 (22:26 +0100)] 
datasets: work around scan-build warning

datasets.c:493:27: warning: Dereference of null pointer [core.NullDereference]
  493 |     DEBUG_VALIDATE_BUG_ON(set->hash->config.hash_size != hashsize);
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-validate.h:95:44: note: expanded from macro 'DEBUG_VALIDATE_BUG_ON'
   95 | #define DEBUG_VALIDATE_BUG_ON(exp) BUG_ON((exp))
      |                                            ^~~
./suricata-common.h:307:36: note: expanded from macro 'BUG_ON'
  307 |         #define BUG_ON(x) assert(!(x))
      |                                    ^
/usr/include/assert.h:109:7: note: expanded from macro 'assert'
  109 |     ((expr)                                                             \
      |       ^~~~
1 warning generated.

(cherry picked from commit c6fdf99cec1ba7067b20e68ea4e812cb4c043881)

4 months agoversion: start development towards 7.0.10 12781/head
Shivani Bhardwaj [Wed, 19 Mar 2025 04:37:24 +0000 (10:07 +0530)] 
version: start development towards 7.0.10

4 months agorelease: 7.0.9; update changelog suricata-7.0.9
Shivani Bhardwaj [Tue, 18 Mar 2025 12:19:32 +0000 (17:49 +0530)] 
release: 7.0.9; update changelog

4 months agoupgrade: list inspection recursion default limit
Juliana Fajardini [Mon, 17 Mar 2025 15:54:49 +0000 (08:54 -0700)] 
upgrade: list inspection recursion default limit

As the yaml indicated before that if no value was specified there were
no limits, and now there will be one.

(cherry picked from commit 3985b24e1b985653e9abd6367bdf621616abc85f)

4 months agodatasets: set higher hashsize limits
Victor Julien [Mon, 17 Mar 2025 20:19:13 +0000 (21:19 +0100)] 
datasets: set higher hashsize limits

To avoid possible upgrade issues, allow higher defaults than in the
master branch. Add some upgrade guidance and a note that defaults will
probably be further reduced.

4 months agodetect: add configurable limits for datasets
Philippe Antoine [Tue, 18 Mar 2025 09:55:39 +0000 (10:55 +0100)] 
detect: add configurable limits for datasets

Ticket: 7615

Avoids signatures setting extreme hash sizes, which would lead to very
high memory use.

Default to allowing:
- 65536 per dataset
16777216 total

To override these built-in defaults:

```yaml
datasets:
  # Limits for per rule dataset instances to avoid rules using too many
  # resources.
  limits:
    # Max value for per dataset `hashsize` setting
    #single-hashsize: 65536
    # Max combined hashsize values for all datasets.
    #total-hashsizes: 16777216
```

(cherry picked from commit a7713db709b8a0be5fc5e5809ab58e9b14a16e85)

4 months agodatasets: improve default hashsize handling
Victor Julien [Tue, 18 Mar 2025 09:55:39 +0000 (10:55 +0100)] 
datasets: improve default hashsize handling

Make hashsize default local to dataset code, instead of relying on the
thash code.

Use the same default value as before.

(cherry picked from commit d32a39ca4b53d7f659f4f0a2a5c162ef97dc4797)

4 months agodoc/userguide: af-packet upgrade notes
Jason Ish [Mon, 17 Mar 2025 15:35:16 +0000 (09:35 -0600)] 
doc/userguide: af-packet upgrade notes

Add note about increased block size and how to change it back to old
defaults if needed.

Ticket: #7458
(cherry picked from commit c6d18fc871ed5466f519a4109d81ca193c92fc7e)

4 months agoaf-packet: delay setting default-packet-size for af-packet
Jason Ish [Mon, 17 Mar 2025 16:35:57 +0000 (10:35 -0600)] 
af-packet: delay setting default-packet-size for af-packet

AF_PACKET needs more information about its configuration before we can
set the default packet size, so on startup, leave unset in suricata.c
if in AF_PACKET mode.

If defrag is enabled, use a default packet size of 9k for tpacket-v2.
This can still lead to truncation events, then the user can increase
their 'default-packet-size'.

Tpacket-v3 does not need an increased packet size as it will handle
any size of packet that is smaller than the configured block size
which now has a default of 128k.

9k for the snap is somewhat arbitrary but is large enough for the
common 9000 jumbo frame plus some extra headers including tpacket
headers.

Ticket: #7458
(cherry picked from commit b8b6ed550a6f10150f5ecf154e7b60c6dc2f84fe)

4 months agoaf-packet: warn that tpacket-v3 is better for non-inline usage
Jason Ish [Thu, 13 Mar 2025 18:14:26 +0000 (12:14 -0600)] 
af-packet: warn that tpacket-v3 is better for non-inline usage

Ticket: #7458
(cherry picked from commit 8c7ac89791db16893673e7e5dc1001f802b9a641)

4 months agoaf-packet: add event for packets truncated by af-packet
Jason Ish [Thu, 13 Mar 2025 16:36:08 +0000 (10:36 -0600)] 
af-packet: add event for packets truncated by af-packet

Ticket: #7458
(cherry picked from commit d78f2c9a4e2b59f44daeddff098915084493d08d)

4 months agoaf-packet: warn if v3 block size is not large enough for defrag
Jason Ish [Wed, 12 Mar 2025 22:20:38 +0000 (16:20 -0600)] 
af-packet: warn if v3 block size is not large enough for defrag

If using tpacket-v3 and defrag, warn if the block size is not large
enough for a fully defragmented packet.

Ticket: #7458
(cherry picked from commit 9f96975d556bbff999482d83c331b96566461cd1)

4 months agoaf-packet: warn if v2 block size not large enough for defrag
Jason Ish [Wed, 12 Mar 2025 22:13:40 +0000 (16:13 -0600)] 
af-packet: warn if v2 block size not large enough for defrag

If using tpacket-v2, defrag and a user provided v2-block-size, warn if
the block size is not large enough to hold one fully defragmented
packet.

Ticket: #7458
(cherry picked from commit 320ef7b61721a8d32d52c40fcc09592f0907bde6)

4 months agoaf-packet: make tpacket-v2 block size configurable
Jason Ish [Wed, 12 Mar 2025 21:58:43 +0000 (15:58 -0600)] 
af-packet: make tpacket-v2 block size configurable

With the change of the default tpacket-v2 block size from 32k to 128k,
allow it to be configurable for users who may want to make it larger,
or revert it back to the pre 7.0.9 default of 32k.

Ticket: #7458
(cherry picked from commit 5871c6458c6696516425f19e8c840663767bf917)

4 months agoaf-packet: increase default block size
Jason Ish [Wed, 12 Mar 2025 21:56:40 +0000 (15:56 -0600)] 
af-packet: increase default block size

Increase the default block size from 32k to 128k. This allows for a
fully defragmented packet to fit in the buffer.

Ticket: #7458
(cherry picked from commit c342b054f40630521253666d3ca0192250a59ad2)

4 months agoaf-packet: warn if defrag not suitable for mode
Jason Ish [Wed, 12 Mar 2025 18:34:31 +0000 (12:34 -0600)] 
af-packet: warn if defrag not suitable for mode

AF_PACKET defrag should not be used for inline modes. Its possible that
a packet received could be larger than can be set when defrag is
enabled, so warn if disabled for inline use.

Likewise, warn if defrag is disabled for IDS use, or non-inline mode.

Ticket: #7458
(cherry picked from commit 808502d5cac0681e17859ed1aef9be8f508c4b13)

4 months agoaf-packet: check defrag value even if cluster-type not set
Jason Ish [Wed, 12 Mar 2025 18:31:08 +0000 (12:31 -0600)] 
af-packet: check defrag value even if cluster-type not set

If cluster-type was not set we default to "cluster_flow" with defrag
always on. Instead check for defrag value and disable defrag if disabled
by the user.

Ticket: #7458
(cherry picked from commit 25d0fba91274e8d26e804f278c281a5c9f5309e9)

4 months agodetect: limit base64_decode `bytes` to 64KiB
Philippe Antoine [Tue, 17 Dec 2024 14:06:25 +0000 (15:06 +0100)] 
detect: limit base64_decode `bytes` to 64KiB

Ticket: 7613

Avoids potential large per-thread memory allocation. A buffer with the
size of the largest decode_base64 buffer size setting would be allocated
per thread. As this was a u32, it could mean a per-thread 4GiB memory
allocation.

64KiB was already the built-in default for cases where bytes size wasn't
specified.

(cherry picked from commit 32d0bd2bbb4d486623dec85a94952fde2515f2f0)

4 months agodetect: non infinite default value for inspection-recursion-limit
Philippe Antoine [Thu, 20 Feb 2025 22:40:08 +0000 (23:40 +0100)] 
detect: non infinite default value for inspection-recursion-limit

So that empty config are protected by this setting as was intended.

Set to unlimited for fuzz testing.

(cherry picked from commit b9b797f1f4fcea02da5b051281e6f7d8d7786260)

4 months agodetect/pcre: avoid infinite loop after negated pcre
Philippe Antoine [Tue, 28 Jan 2025 14:02:45 +0000 (15:02 +0100)] 
detect/pcre: avoid infinite loop after negated pcre

Ticket: 7526

The usage of negated pcre, followed by other relative payload
content keywords could lead to an infinite loop.

This is because regular (not negated) pcre can test multiple
occurences, but negated pcre should be tried only once.

(cherry picked from commit b14c67cbdf25fa6c7ffe0d04ddf3ebe67b12b50b)

4 months agostream: RST no longer acks all data 12756/head 12761/head
Victor Julien [Fri, 29 Nov 2024 13:37:08 +0000 (14:37 +0100)] 
stream: RST no longer acks all data

Since forever (1578ef1e3e8a24d0cc615430c4e6bec1fefdad28) a valid RST
would update the internal `last_ack` representation to include all
unack'd data. This was originally done to make sure the unACK'd data was
inspected/processed at flow timeout.

It was observed however, that if GAPs existed in this unACK'd data, a
GAP could be reported in the stats and a GAP event would be raised. This
doesn't make sense, as missing segments in the unACK'd part of the
stream are completely normal. Segments simply do not all arrive in
order.

It turns out that the original behavior of updating `last_ack` to
include all unACK'd data is no longer needed.

For raw stream inspection, the detection engine will already include the
unACK'd data on flow end.

For app-layer updates the unACK'd data is often harmful, as the data
often has GAPs. Parser like the http parser would report these GAPs and
could also get confused about the post-GAP data being a new transaction
including a file. This lead to many reported errors and fantom txs and
files.

Since the GAP detection uses `last_ack` to determine GAPs, not moving
`last_ack` addresses the GAP false positives.

Ticket: #7422.
(cherry picked from commit bd1b9f62299422767056651f8f66d2bbd4e0bb14)

4 months agodetect: delay tx cleanup in some edge case 12751/head 12754/head
Philippe Antoine [Tue, 25 Feb 2025 09:54:13 +0000 (10:54 +0100)] 
detect: delay tx cleanup in some edge case

Ticket: 7552

f->sgh_toserver may be NULL but because FLOW_SGH_TOSERVER is unset
and thus, we want to delay cleanup until detection has really been
run with the right signature group head.

This may happen for a rule using
`alert tcp any any -> any any` and
a app-layer keyword to client
with a app-layer supporting both udp and tcp
with stream.midstream=true
and with the first packet of a flow being a server response

In this case, we swap the flow and reset its signature group heads

(cherry picked from commit d8ddef4c1485004cfb24d0e4b1c490f185bedc92)

Additional fix in rfb unit test which moved to SV in suricata 8

4 months agodetect: reset signature groups when reversing flow
Philippe Antoine [Tue, 25 Feb 2025 09:49:41 +0000 (10:49 +0100)] 
detect: reset signature groups when reversing flow

Ticket: 7552

When we use midstream, and the first packet we see of a flow is
a response from server, and we want to match on some signature
to client :
- we had first set sgh_toserver/FLOW_SGH_TOSERVER as we first
  thought this was a packet to server
- we then swap/reverse the flow, so sgh_toclient becomes sgh_toserver
  but it contains signatures to server and cannot match our
  to_client signature

The detect engine with DetectRunSetup will set again the
signatures group heads properly

(cherry picked from commit d74bc774b75bcca613e5f48d907a425c3b46056a)

5 months agofiles: append data on closing even with FILE_NOSTORE 12719/head 12725/head
Philippe Antoine [Tue, 4 Mar 2025 15:30:19 +0000 (16:30 +0100)] 
files: append data on closing even with FILE_NOSTORE

Ticket: 7577

When HTTP1 post multipart handles a small file, it will call
HTPFileClose with some data
This data needs to be appended to the streaming buffer for usage
by file.data keyword even if we do not end up storing the file

(cherry picked from commit f68e2f5537c95388858129aa1b076e976354584a)

5 months agoapp-layer: track modified/processed txs 12678/head
Philippe Antoine [Fri, 31 May 2024 08:39:16 +0000 (10:39 +0200)] 
app-layer: track modified/processed txs

To optimize detection, and logging, to avoid going through
all the live transactions when only a few were modified.

Two boolean fields are added to the tx data: updated_tc and ts
The app-layer parsers are now responsible to set these when
needed, and the logging and detection uses them to skip
transactions that were not updated.

There may some more optimization remaining by when we set
both updated_tc and updated_ts in functions returning
a mutable transaction, by checking if all the callers
are called in one direction only (request or response)

Ticket: 7087
(cherry picked from commit b02557ac7dd6b55187309cee93f849ee2917d0cb)

5 months agoquic: discard late retry packets 12661/head 12663/head
Philippe Antoine [Fri, 21 Feb 2025 09:38:06 +0000 (10:38 +0100)] 
quic: discard late retry packets

Ticket: 7556

See RFC 9000 section 17.2.5.2 :
After the client has received and processed an Initial
or Retry packet from the server,
it MUST discard any subsequent Retry packets that it receives.

(cherry picked from commit 726de5520f77e778cd2511bf262611079ae2528d)

5 months agoquic: decrypt only initial packets
Philippe Antoine [Wed, 19 Feb 2025 09:08:58 +0000 (10:08 +0100)] 
quic: decrypt only initial packets

Ticket: 7556

Avoids failed_decrypt events when the first packet seen is not
a Quic Initial packet

(cherry picked from commit d61f36c66fa6bb32d135e3891804081e16719cb4)

5 months agoquic: handle retry packets
Philippe Antoine [Wed, 19 Feb 2025 12:01:36 +0000 (13:01 +0100)] 
quic: handle retry packets

Ticket: 7556
(cherry picked from commit 6d8910d2455adcfd92c5970a3654d0bf90546489)

5 months agoquic: handle fragmented hello over multiple packets
Philippe Antoine [Mon, 17 Feb 2025 10:13:20 +0000 (11:13 +0100)] 
quic: handle fragmented hello over multiple packets

Ticket: 7556

To do so, we need to add 2 buffers (one for each direction)
to the QuicState structure, so that on parsing the second packet
with hello/crypto fragment, we still have the data of the first
hello/crypto fragment.

Use a hardcoded limit so that these buffers cannot grow indefinitely
and set an event when reaching the limit

(cherry picked from commit f295cc059d0fb9666ff48b5156235f1aa611d010)

5 months agoquic: parse ack frame number 3
Philippe Antoine [Mon, 17 Feb 2025 14:04:59 +0000 (15:04 +0100)] 
quic: parse ack frame number 3

cf rfc9000 section 19.3. ACK Frames

Ticket: 7556
(cherry picked from commit 68adc87bd20f0b09a95871ead88a558f4c94e788)

5 months agoquic: move all_consuming check to callee
Philippe Antoine [Mon, 17 Feb 2025 10:04:50 +0000 (11:04 +0100)] 
quic: move all_consuming check to callee

Will alow to have decode_frames accept one additional parameter
with past fragment data

(cherry picked from commit ee04d667b506ba6ab7f172c0e129e7b7cf617187)

5 months agorust: fixes for new clippy warnings 12651/head
Jason Ish [Thu, 20 Feb 2025 22:34:14 +0000 (16:34 -0600)] 
rust: fixes for new clippy warnings

Fixes provided by cargo clippy --fix.

5 months agodetect/krb5: avoid integer underflow with krb5.ticket_encryption
Philippe Antoine [Mon, 17 Feb 2025 08:08:54 +0000 (09:08 +0100)] 
detect/krb5: avoid integer underflow with krb5.ticket_encryption

Ticket: 7560

When passing INT32_MIN aka 0x80000000, we cannot compute -vali
as it does not fit into a i32

(cherry picked from commit 8ae5665767a1660cdb0eaa8134c5910852b1afad)

5 months agodns: refactor tests to avoid assert!(false) 12618/head 12630/head
Jason Ish [Tue, 18 Feb 2025 22:12:30 +0000 (16:12 -0600)] 
dns: refactor tests to avoid assert!(false)

Mostly just unwrap instead of match as unwrap provides good
context. And replace a few assert!(false) with a descriptive panic.

5 months agorust: allow clippy::unused_unit for tests that use the test macro
Jason Ish [Tue, 18 Feb 2025 21:57:22 +0000 (15:57 -0600)] 
rust: allow clippy::unused_unit for tests that use the test macro

The cause of the issue comes from the macro, which is provided by a
crate. Bust just to allow this for now.

5 months agodns: fix clippy lint warnings
Shivani Bhardwaj [Fri, 13 Dec 2024 07:03:08 +0000 (12:33 +0530)] 
dns: fix clippy lint warnings

Fix vector lint issues:
- same_item_push
- vec_init_then_push

(cherry picked from commit 2c0d3b83c442fc751f8418f3f4833d86cdd495d3)

5 months agorust: fix assertions_on_constants for assert!(true)
Philippe Antoine [Thu, 4 Jan 2024 10:48:32 +0000 (11:48 +0100)] 
rust: fix assertions_on_constants for assert!(true)

Which will be optimized away by the compiler

(cherry picked from commit c49463c86f4c54f3bd322eaead07ce9a2c0b1d56)

5 months agorust: fix single_binding
Philippe Antoine [Sat, 6 Jan 2024 21:15:11 +0000 (22:15 +0100)] 
rust: fix single_binding

error: this match could be written as a `let` statement
   --> src/nfs/nfs3_records.rs:747:9
    |
747 | /         match result {
748 | |             (r, request) => {
749 | |                 assert_eq!(r.len(), 0);
750 | |                 assert_eq!(request.handle, expected_handle);
751 | |                 assert_eq!(request.name_vec, br#"bln"#);
752 | |             }
753 | |         }
    | |_________^

(cherry picked from commit 259cdf169e20b580643117b8fa227e470a0377f8)

5 months agorust: fix assertions_on_constants for assert!(false)
Philippe Antoine [Thu, 4 Jan 2024 11:48:12 +0000 (12:48 +0100)] 
rust: fix assertions_on_constants for assert!(false)

using panic! instead with a string message

(cherry picked from commit a8199bf2ca16e8394b6bf5c41ba1bafe88f6ff53)

5 months agorust: allow vec_init_then_push in tests
Jason Ish [Tue, 18 Feb 2025 21:37:51 +0000 (15:37 -0600)] 
rust: allow vec_init_then_push in tests

To supress the clippy lint in tests.

5 months agomqtt: always use 0x notation for hex in tests
Jason Ish [Tue, 18 Feb 2025 21:32:42 +0000 (15:32 -0600)] 
mqtt: always use 0x notation for hex in tests

Fixes clippy lint for zero_prefixed_literal.

5 months agotls: more permissive empty data eof check 12607/head 12611/head
Victor Julien [Thu, 13 Feb 2025 13:30:39 +0000 (14:30 +0100)] 
tls: more permissive empty data eof check

If not all data is ACK'd during the FIN session shutdown, the last calls
to the parser can be with a non-NULL data pointer, but a input length of
0. This wasn't considered by the EOF check, which then lead to it being
seen as an error. No event was raised, but the tls error stats were
incremented.

Bug: #7554.
(cherry picked from commit 471bde442680cd22f4ca9493da7a824dfb8f8197)

5 months agogithub-ci: update actions/cache (deprecated) 12559/head 12566/head
Jason Ish [Tue, 11 Feb 2025 16:11:48 +0000 (10:11 -0600)] 
github-ci: update actions/cache (deprecated)

It appears dependabot is a little behind on updating actions/cache.

5 months agodoc/csum: Stream checksum validation change 12557/head
Jeff Lucovsky [Tue, 21 Jan 2025 14:21:24 +0000 (09:21 -0500)] 
doc/csum: Stream checksum validation change

Describe the change of behavior between the stream.checksum-validation
setting and checksum-based rule keywords.

(cherry picked from commit cfbf8fda94771461844b0fc805af5476f92328ce)

5 months agodetect/csum: rm interaction btw stream setting/csum
Jeff Lucovsky [Mon, 20 Jan 2025 13:46:39 +0000 (08:46 -0500)] 
detect/csum: rm interaction btw stream setting/csum

Issue: 7467

Stream checksum validation no longer has a side effect of setting
PKT_IGNORE_CHECKSUM and thus, no longer affects csum keyword checks.

(cherry picked from commit 758da982f087dce249012304de7d3077adf9bade)

5 months agosip/parser: enforce valid chars for sip version
Giuseppe Longo [Sat, 25 Nov 2023 08:39:54 +0000 (09:39 +0100)] 
sip/parser: enforce valid chars for sip version

The `is_version_char` function incorrectly allowed characters that are not
part of the valid SIP version "SIP/2.0".

For instance, 'HTTP/1.1' was mistakenly accepted as a valid SIP version,
although it's not.

This commit fixes the issue by updating the condition to strictly
check for the correct version string.

cherry-picked from commit 69f841c9981147f55ec9f76d44f7ac138e726304

5 months agosip/parser: accept valid chars
Giuseppe Longo [Tue, 1 Aug 2023 18:50:17 +0000 (20:50 +0200)] 
sip/parser: accept valid chars

Accepts valid characters as defined in RFC3261.

cherry-picked from commit 7e993d5081c35d62eada429bad43430417267e5a