]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
6 weeks agodoc: move upgrade note to correct section 13328/head
Shivani Bhardwaj [Tue, 27 May 2025 13:17:43 +0000 (18:47 +0530)] 
doc: move upgrade note to correct section

The PR for the behavior change of dealing with spaces in http URI and
protocol was started in 2019 and merged in 2024. When the PR was
created, it belonged to the correct upgrade section, however, by the
time it was merged, it was 8.0.x branch already.
Move it to upgrade notes from 7 to 8 for correctness.

6 weeks agodetect/vlan: fix leak with bad signature
Philippe Antoine [Tue, 27 May 2025 13:16:02 +0000 (15:16 +0200)] 
detect/vlan: fix leak with bad signature

6 weeks agodecode/sll2: Support PCAPs encoded with Linux SLL ver 2
Jeff Lucovsky [Sat, 24 May 2025 15:27:40 +0000 (11:27 -0400)] 
decode/sll2: Support PCAPs encoded with Linux SLL ver 2

Support Linux Cooked mode v2 -- DLT 276

6 weeks agoclang-format: don't reformat schema on rewrite-branch
Jason Ish [Fri, 23 May 2025 15:42:18 +0000 (09:42 -0600)] 
clang-format: don't reformat schema on rewrite-branch

Add --extensions c,h flag to git clang-format when reformatting
commits on a branch. This prevents clang-format from modifying
non-C files like JSON schemas.

The extensions is used elsewhere in this script, so I suspect it was
just an oversight.

Also, ./scripts/schema-order.py --in-place will consistently format the
schema, while sorting the keys.

6 weeks agorust: use bindgened Flow definition
Philippe Antoine [Thu, 22 May 2025 08:34:11 +0000 (10:34 +0200)] 
rust: use bindgened Flow definition

Ticket: 7667

6 weeks agorust: bindgen part of util-debug.h
Philippe Antoine [Thu, 22 May 2025 08:04:20 +0000 (10:04 +0200)] 
rust: bindgen part of util-debug.h

Ticket: 7667

Especially SCLogLevel whose enum redef is removed in rust

7 weeks agodetect/files: increment local_file_id even if buffer is NULL 13292/head
Philippe Antoine [Wed, 21 May 2025 13:34:26 +0000 (15:34 +0200)] 
detect/files: increment local_file_id even if buffer is NULL

Ticket: 7579

Otherwise, we will keep on calling again and again GetDataCallback
with the same local_file_id, and we will always get a NULL
buffer even if the next local_file_id would return a non-NULL buffer.

7 weeks agooutput: error on payload-buffer-size 0
Philippe Antoine [Wed, 21 May 2025 12:54:53 +0000 (14:54 +0200)] 
output: error on payload-buffer-size 0

Ticket: 7479

It makes no sense to ask for payload, but then want 0 bytes of it.

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

Ticket: 7019

7 weeks agoscripts: clang-format can use a different base than master
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

7 weeks agowebsocket: trigger raw stream inspection
Shivani Bhardwaj [Wed, 21 May 2025 07:18:48 +0000 (12:48 +0530)] 
websocket: trigger raw stream inspection

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

Websocket parser creates a new PDU per transaction in each direction. Appropriate
calls to trigger raw stream inspection have been added on succesful parsing of
each PDU.

Task 7026
Bug 7004

7 weeks agossh: trigger raw stream inspection
Shivani Bhardwaj [Wed, 21 May 2025 06:45:11 +0000 (12:15 +0530)] 
ssh: trigger raw stream inspection

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

SSH parser creates a new record per request or response. Appropriate calls
to trigger raw stream inspection have been added on succesful parsing of
each request and response.

Task 7026
Bug 7004

7 weeks agoapplayer: add bool status check fns
Shivani Bhardwaj [Wed, 21 May 2025 06:42:42 +0000 (12:12 +0530)] 
applayer: add bool status check fns

7 weeks agosip: trigger raw stream inspection
Shivani Bhardwaj [Mon, 19 May 2025 07:13:25 +0000 (12:43 +0530)] 
sip: trigger raw stream inspection

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

SIP parser creates a new transaction per request or response. Appropriate calls
to trigger raw stream inspection have been added on creation of each request and
response.

Task 7026
Bug 7004

7 weeks agorfb: trigger raw stream inspection
Shivani Bhardwaj [Mon, 19 May 2025 06:42:18 +0000 (12:12 +0530)] 
rfb: trigger raw stream inspection

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

RFB has several different types of requests and responses. Appropriate calls
to trigger raw stream inspection have been added on completion of each type of
request and response.

Task 7026
Bug 7004

7 weeks agordp: trigger raw stream inspection
Shivani Bhardwaj [Mon, 19 May 2025 06:24:12 +0000 (11:54 +0530)] 
rdp: trigger raw stream inspection

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

RDP parser creates a transaction per request or response. Appropriate calls
to trigger raw stream inspection have been added on completion of each request
and response.

Task 7026
Bug 7004

7 weeks agopop3: trigger raw stream inspection
Shivani Bhardwaj [Mon, 19 May 2025 05:33:49 +0000 (11:03 +0530)] 
pop3: trigger raw stream inspection

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

POP3 has a classic request response model where a request is mapped to
a response although not by any ID. Appropriate calls to trigger raw stream
inspection have been added on completion of each request and response.

Task 7026
Bug 7004

7 weeks agonfs: trigger raw stream inspection
Shivani Bhardwaj [Sat, 17 May 2025 08:11:32 +0000 (13:41 +0530)] 
nfs: trigger raw stream inspection

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

NFS has a classic request response model where each request is mapped to
a corresponding response. Additionally, there's also file tracking and
handling done as a part of these transactions. Appropriate calls to
trigger raw stream inspection have been added on completion of each
request and response.

Task 7026
Bug 7004

7 weeks agostream: rename TriggerRawStreamReassembly
Shivani Bhardwaj [Tue, 20 May 2025 13:53:24 +0000 (19:23 +0530)] 
stream: rename TriggerRawStreamReassembly

The functions around TriggerRawStreamReassembly are misnomers in the
current layout of the code. The functions were named appropriately when
they were created as per the structural and logical layout of the code
at the time.

These functions in today's code are being used to track, update and
trigger progress of inspection in the raw stream only. Hence, rename them
to TriggerRawStreamInspection.

7 weeks agodoc: update http.header_names normalization info 13283/head
jason taylor [Wed, 21 May 2025 00:34:47 +0000 (20:34 -0400)] 
doc: update http.header_names normalization info

7 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

7 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

7 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: 7568

7 weeks agofiles: remove legacy option force-md5
Philippe Antoine [Tue, 20 May 2025 13:04:58 +0000 (15:04 +0200)] 
files: remove legacy option force-md5

The modern option is force-hash: md5

Ticket: 7353

7 weeks agorust: bindgen SCSigMatchAppendSMToList
Philippe Antoine [Tue, 20 May 2025 11:33:10 +0000 (13:33 +0200)] 
rust: bindgen SCSigMatchAppendSMToList

Ticket: 7667

7 weeks agorust: bindgen SCDetectSignatureSetAppProto
Philippe Antoine [Tue, 20 May 2025 11:20:04 +0000 (13:20 +0200)] 
rust: bindgen SCDetectSignatureSetAppProto

Ticket: 7667

7 weeks agorust: bindgen detect-parse.h
Philippe Antoine [Tue, 20 May 2025 10:47:15 +0000 (12:47 +0200)] 
rust: bindgen detect-parse.h

Ticket: 7667

Currently no functions are exported.

DetectFile* struct are moved to detect-file-data.h where
they make more sense.

ifndef SURICATA_BINDGEN_H is used for bindgen to exclude
pcre2 related code

7 weeks agodetect/tls: fix -Wshorten-64-to-32 warnings
Philippe Antoine [Tue, 20 May 2025 09:01:08 +0000 (11:01 +0200)] 
detect/tls: fix -Wshorten-64-to-32 warnings

Ticket: #6186

7 weeks agodetect/frames: fix -Wshorten-64-to-32 warnings
Philippe Antoine [Tue, 20 May 2025 08:56:46 +0000 (10:56 +0200)] 
detect/frames: fix -Wshorten-64-to-32 warnings

Ticket: #6186

7 weeks agodetect/transforms: fix -Wshorten-64-to-32 warnings
Philippe Antoine [Tue, 20 May 2025 08:52:28 +0000 (10:52 +0200)] 
detect/transforms: fix -Wshorten-64-to-32 warnings

Ticket: #6186

7 weeks agodetect/ftp: fix -Wshorten-64-to-32 warnings
Philippe Antoine [Tue, 20 May 2025 08:49:17 +0000 (10:49 +0200)] 
detect/ftp: fix -Wshorten-64-to-32 warnings

Ticket: #6186

7 weeks agodoc/tls: Update Lua TLS functions 13269/head 13275/head
Jeff Lucovsky [Mon, 12 May 2025 12:27:52 +0000 (08:27 -0400)] 
doc/tls: Update Lua TLS functions

Issue: 7608

Update the documentation to reflect the new and expanded functions
available form the Lua TLS library

There are now "server" and "client" versions of most functions. The TLS
object getter is now "get_tx"

7 weeks agolua/tls: convert LUA functions to lib: suricata.tls
Jeff Lucovsky [Fri, 9 May 2025 18:14:14 +0000 (14:14 -0400)] 
lua/tls: convert LUA functions to lib: suricata.tls

Ticket: 7608

Convert the Lua functions to a library.

Modified the existing Lua functions to include client and server
versions as appropriate.

7 weeks agodoc/ftp: Document ftp.completion_code sticky buffer 13262/head
Jeff Lucovsky [Sat, 29 Mar 2025 17:48:38 +0000 (13:48 -0400)] 
doc/ftp: Document ftp.completion_code sticky buffer

This commit adds documentation for the ftp.completion_code sticky
buffer. This is a multi-buffer match.

Issue: 7507

7 weeks agodetect/ftp: Add ftp.completion_code keyword
Jeff Lucovsky [Sat, 29 Mar 2025 15:01:17 +0000 (11:01 -0400)] 
detect/ftp: Add ftp.completion_code keyword

Issue: 7507

Implement the ftp.completion_code sticky buffer. Multi-buffer as an FTP
command can produce multiple responses.

E.g., with the FTP command RETR
    RETR temp.txt
    150 Opening BINARY mode data connection for temp.txt (1164 bytes).
    226 Transfer complete.

7 weeks agopop3: fix incorrect direction matching 13260/head
Shivani Bhardwaj [Mon, 19 May 2025 05:58:23 +0000 (11:28 +0530)] 
pop3: fix incorrect direction matching

sawp crate has its own Direction enum as follows.

pub enum Direction {
    ToClient = 0,
    ToServer = 1,
    Unknown = 2,
}

While it is correct to send this Direction enum as argument to the
sawp_pop3 parser as it expects, it is not correct to use it where the
direction param is obtained from the internal API of Suricata.
The reason is that Suricata's definition of its Direction enum is as
follows.

pub enum Direction {
    ToServer = 0x04,
    ToClient = 0x08,
}

This can lead to issues like incorrect progress tracking of a transaction in
a direction which could cause inspection on incorrect data and buggy behavior.

7 weeks agogithub-ci: add check for schema property ordering 13259/head
Jason Ish [Sun, 18 May 2025 16:21:11 +0000 (10:21 -0600)] 
github-ci: add check for schema property ordering

7 weeks agoschema: add script to check or sort the schema
Jason Ish [Sun, 18 May 2025 16:18:03 +0000 (10:18 -0600)] 
schema: add script to check or sort the schema

7 weeks agoetc/schema: sort properties in alphabetic order
Jason Ish [Fri, 16 May 2025 18:58:20 +0000 (12:58 -0600)] 
etc/schema: sort properties in alphabetic order

Also:
- Place "additionalProperties" before "properties"
- Place "required" after "additionalProperties"
- Remove "additionalProperties where true, as that is the default

The order should help us spot duplicate keys, and make it easier to
add new keys in their proper place.

7 weeks agodoc: Document luaxform transform 13255/head
Jeff Lucovsky [Wed, 18 Sep 2024 12:18:07 +0000 (08:18 -0400)] 
doc: Document luaxform transform

Issue: 2290

7 weeks agodetect/luaxform: initial lua transform support
Jeff Lucovsky [Mon, 9 Sep 2024 15:06:32 +0000 (11:06 -0400)] 
detect/luaxform: initial lua transform support

Adds a new lua script capability to use a script as a buffer transform
keyword.

It uses a `transform` lua function that returns the input buffer after
modifying it.

Issue: 2290

7 weeks agodetect: make packet and tx_id available earlier
Victor Julien [Sat, 18 Jan 2025 10:58:57 +0000 (11:58 +0100)] 
detect: make packet and tx_id available earlier

So transforms can access them through DetectEngineThreadCtx

8 weeks agodoc/ftp: Document ftp.reply_received 13251/head
Jeff Lucovsky [Thu, 17 Apr 2025 12:32:15 +0000 (08:32 -0400)] 
doc/ftp: Document ftp.reply_received

Add documentation for the ftp.reply_received keyword.

8 weeks agodetect/ftp: Add ftp.received_reply
Jeff Lucovsky [Thu, 17 Apr 2025 12:30:50 +0000 (08:30 -0400)] 
detect/ftp: Add ftp.received_reply

Issue: 7506

Add a (non-sticky buffer) keyword for ftp.reply_received. This is not a
sticky buffer as the keyword relates to protocol state and not bytes
from the actual protocol exchange.

ftp.reply_received: yes|on|no|off

8 weeks agorust: bindgen SCDetectHelperBufferMpmRegister
Philippe Antoine [Wed, 14 May 2025 19:48:06 +0000 (21:48 +0200)] 
rust: bindgen SCDetectHelperBufferMpmRegister

Ticket: 7667

8 weeks agodetect/single-buf: new simple wrapper
Philippe Antoine [Mon, 28 Apr 2025 13:51:43 +0000 (15:51 +0200)] 
detect/single-buf: new simple wrapper

Introduce DetectGetSingleData which does the generic wrapping,
including the transforms, using a new callback prototype
DetectTxGetBufferPtr

The goal is to replace most InspectionBufferGetDataPtr.
For this commit, we do not change every callback to keep the
change relatively small.

Focus here is to remove DetectHelperGetData as its functionality is
provided more directly by the new DetectTxGetBufferPtr.

8 weeks agorust/derive: fix clippy collapsible_match warning
Philippe Antoine [Tue, 6 May 2025 13:16:53 +0000 (15:16 +0200)] 
rust/derive: fix clippy collapsible_match warning

And now deny warnings

8 weeks agoja4: check more ifdef HAVE_JA4
Philippe Antoine [Tue, 6 May 2025 11:43:14 +0000 (13:43 +0200)] 
ja4: check more ifdef HAVE_JA4

Avoids a unused macro warning

8 weeks agooutput/tls: Allow logging of sv-handshake params
Richard McConnell [Fri, 25 Apr 2025 09:03:41 +0000 (10:03 +0100)] 
output/tls: Allow logging of sv-handshake params

Ticket: 6695

"server_handshake" which logs the following:
1. TLS version used during handshake
2. The chosen cipher suite, excluding GREASE
3. TLS extensions, excluding GREASE

8 weeks agooutput/tls: Allow logging of cl-handshake params
Richard McConnell [Thu, 24 Apr 2025 10:46:47 +0000 (11:46 +0100)] 
output/tls: Allow logging of cl-handshake params

Ticket: 6695

Add new custom log fields:

"client_handshake" which logs the following:
1. TLS version used during handshake
2. TLS extensions, excluding GREASE, SNI and ALPN
3. All cipher suites, excluding GREASE
4. All signature algorithms, excluding GREASE

The use-case is for logging TLS handshake parameters in order to survey
them, and so that JA4 hashes can be computed offline (in the case that
they're not already computed for the purposes of rule matching).

8 weeks agotls: Move tls-versions to rust
Richard McConnell [Wed, 14 May 2025 15:54:00 +0000 (16:54 +0100)] 
tls: Move tls-versions to rust

This commit is designed in preparation of enabling the handshake object
to log it's own contents rather than being done on the C side.
Moving the tls versions functionality to rust has a couple of uses:
1. Allows both rust and C side to use these fields
2. Moves more of the tls related logic to rust
3. C side can still use these values because of cbindgen

8 weeks agotls: Integrate ALPNs into HandshakeParams object
Richard McConnell [Mon, 28 Apr 2025 11:02:04 +0000 (12:02 +0100)] 
tls: Integrate ALPNs into HandshakeParams object

Ticket: 6695

With the introduction of the HandshakeParams object we're able to
utilise the theory further by using it as the object to track the ALPNs.

The HandshakeParams object is now responsible for holding all ALPNS. The
user of this HandshakeParams object i.e. JA4, can use whichever fields
are needed. So only when we generate a JA4 hash do we use the first ALPN
and require to format it. Other users of HandshakeParams may opt to use
all ALPN's i.e. during TlsAlpnGetData().

8 weeks agotls: Introduce HandshakeParams object for tracking
Richard McConnell [Wed, 23 Apr 2025 14:44:09 +0000 (15:44 +0100)] 
tls: Introduce HandshakeParams object for tracking

Ticket: 6695

This introduction splits the use of the handshake parameters into their
own object, HandshakeParams, which is populated by the TLS decoder. The
JA4 object is now very simple. It's a simple String object (the JA4
Hash) which is generated during new().

This introduction is part of a larger idea, which is to enable
outputting these raw parameters without JA3/JA4. These handshake
parameters are the components used to generate the JA4 hash, thus it
makes sense for it to be a user of HandshakeParams.

8 weeks agodetect: fix some -Wshorten-64-to-32 warnings
Philippe Antoine [Wed, 14 May 2025 19:15:41 +0000 (21:15 +0200)] 
detect: fix some -Wshorten-64-to-32 warnings

Ticket: #6186

8 weeks agodetect/threshold: timeout handling precision improvement
Philippe Antoine [Wed, 14 May 2025 19:00:39 +0000 (21:00 +0200)] 
detect/threshold: timeout handling precision improvement

As found by -Wshorten-64-to-32 warnings

Ticket: #6186

Use SCTime_t instead of u32, which increases memory usage for
the structures changed here, while making it more correct.

8 weeks agodetect/tag: timeout handling precision improvement
Philippe Antoine [Wed, 14 May 2025 18:59:47 +0000 (20:59 +0200)] 
detect/tag: timeout handling precision improvement

As found by -Wshorten-64-to-32 warnings

Ticket: #6186

Use SCTime_t instead of u32, which increases memory usage for
the structures changed here, while making it more correct.

8 weeks agodetect/xbits: timeout handling precision improvement
Philippe Antoine [Wed, 14 May 2025 18:52:02 +0000 (20:52 +0200)] 
detect/xbits: timeout handling precision improvement

As found by -Wshorten-64-to-32 warnings

Ticket: #6186

Use SCTime_t instead of u32, which increases memory usage for
the structures changed here, while making it more correct.

8 weeks agorust/applayer: collapse nested if let to remove clippy warning 13244/head
Jason Ish [Fri, 16 May 2025 00:39:51 +0000 (18:39 -0600)] 
rust/applayer: collapse nested if let to remove clippy warning

   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
   = note: `#[warn(clippy::collapsible_match)]` on by default

8 weeks agorust/htp: suppress io_other_error lint
Jason Ish [Fri, 16 May 2025 00:36:58 +0000 (18:36 -0600)] 
rust/htp: suppress io_other_error lint

The fix for this lint requires Rust 1.74.

8 weeks agogithub-ci: use rust 1.85.0 for clippy check on templates
Jason Ish [Fri, 16 May 2025 00:21:06 +0000 (18:21 -0600)] 
github-ci: use rust 1.85.0 for clippy check on templates

Currently our CI clippy test is based on 1.85.0, but the clippy test for
the templates was using latest stable.  Unify the clippy checks to
1.85.0.

8 weeks agomqtt: trigger raw stream reassembly 13237/head
Shivani Bhardwaj [Thu, 8 May 2025 07:07:26 +0000 (12:37 +0530)] 
mqtt: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

MQTT creates a transaction per message per direction, so, a call to
trigger raw stream reassembly has been made on completion of each
transaction in the respective direction.

Optimization 7026
Bug 7004

8 weeks agomodbus: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:07:14 +0000 (12:37 +0530)] 
modbus: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

Modbus has a classic request response model, so, a call to trigger raw
stream reassembly is added on completion of each request and response.

Optimization 7026
Bug 7004

8 weeks agoldap: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:07:00 +0000 (12:37 +0530)] 
ldap: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

LDAP can have multiple responses corresponding to a request. The call to
trigger raw stream reassembly has been added on common call sites that
see the completion of a request or any of the responses.

Optimization 7026
Bug 7004

8 weeks agokrb: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:06:45 +0000 (12:36 +0530)] 
krb: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

KRB5 creates a transaction based on how each input is parsed. It could
be parsed as a request or response but that is the concern of the
parser. The call to trigger raw stream reassembly has been added after
successful parsing of the respective request/response.

Optimization 7026
Bug 7004

8 weeks agohttp2: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:06:15 +0000 (12:36 +0530)] 
http2: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

HTTP2 has a classic request response model, so, a call to trigger raw
stream reassembly is added on completion of each request and response.
HTTP2 parser has its own maximum reassembly setting. The call has been
added irrespective of this setting as it is prudent to make all data so
far available for inspection if maximum was reached until the maximum.

Optimization 7026
Bug 7004

8 weeks agoenip: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:05:58 +0000 (12:35 +0530)] 
enip: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

ENIP has a classic request response model, so, a call to trigger raw
stream reassembly is added on completion of each request and response.

Optimization 7026
Bug 7004

8 weeks agohttp1: use a tx iterator 13235/head
Philippe Antoine [Tue, 13 May 2025 13:11:57 +0000 (15:11 +0200)] 
http1: use a tx iterator

Better performance than the defaut iterator as we do not need to
read all first elements every time

8 weeks agohtp: move transactions list from BTree to VecDeque
Philippe Antoine [Tue, 13 May 2025 13:16:23 +0000 (15:16 +0200)] 
htp: move transactions list from BTree to VecDeque

As it is more efficient in our case of pipelining requests

8 weeks agohttp: simplify tx removal interface
Philippe Antoine [Tue, 13 May 2025 13:14:53 +0000 (15:14 +0200)] 
http: simplify tx removal interface

8 weeks agohtp: remove unused code
Philippe Antoine [Tue, 13 May 2025 07:50:36 +0000 (09:50 +0200)] 
htp: remove unused code

8 weeks agodetect/xform: Support transform identity data
Jeff Lucovsky [Sat, 5 Apr 2025 20:08:39 +0000 (16:08 -0400)] 
detect/xform: Support transform identity data

Transforms that support optional strings, like from_base64 and
pcrexform, should also support identity-strings to treat transforms with
like transform options as the same.

This commit adds transform identity data handling:
- When computing a hash, include identity data from the transform
- When comparing, include the identity data from the transforms
- Omitting the "options" ptr from the transform hash/compare
- Modify xor, pcrexform and from_base64 to supply identification data for
  disambiguation in the compare/hash logic.

8 weeks agodetect/ftp: Set buffer desc for ftp.dynamic_port 13231/head
Jeff Lucovsky [Sun, 27 Apr 2025 12:53:34 +0000 (08:53 -0400)] 
detect/ftp: Set buffer desc for ftp.dynamic_port

Ensure that the buffer description is set for the ftp.dynamic_port
keyword.

8 weeks agodoc/ftp: Document ftp.mode keyword
Jeff Lucovsky [Sat, 26 Apr 2025 13:35:50 +0000 (09:35 -0400)] 
doc/ftp: Document ftp.mode keyword

Document the ftp.mode keyword
Fixup a typo in the ftp.reply keyword section.

Issue: 7505

8 weeks agodetect/ftp: Add ftp.mode command
Jeff Lucovsky [Fri, 25 Apr 2025 14:47:47 +0000 (10:47 -0400)] 
detect/ftp: Add ftp.mode command

Issue: 7505

This commit adds support for the ftp.mode keyword.

ftp.mode: active|passive

8 weeks agodetect/ftp: Add parser for ftp.mode keyword
Jeff Lucovsky [Thu, 8 May 2025 12:19:46 +0000 (08:19 -0400)] 
detect/ftp: Add parser for ftp.mode keyword

Issue: 7505

Add a parser for the ftp.mode command that returns the state struct. Add
a function to free the object it allocates.

8 weeks agooutput/ftp: Log mode for passive connections
Jeff Lucovsky [Sat, 26 Apr 2025 13:21:51 +0000 (09:21 -0400)] 
output/ftp: Log mode for passive connections

This commit will now output the FTP mode -- active or passive -- when
the command is
- (previous): PORT, EPRT
- (new): PASV, EPSV

Issue: 7505

8 weeks agorust: bindgen SCDetectHelperKeywordSetCleanCString 13230/head
Philippe Antoine [Mon, 12 May 2025 19:13:52 +0000 (21:13 +0200)] 
rust: bindgen SCDetectHelperKeywordSetCleanCString

Ticket: 7667

8 weeks agorust: bindgen SCDetectHelperKeywordRegister
Philippe Antoine [Mon, 12 May 2025 18:55:50 +0000 (20:55 +0200)] 
rust: bindgen SCDetectHelperKeywordRegister

Ticket: 7667

8 weeks agorust: bindgen SCDetectHelperKeywordAliasRegister
Philippe Antoine [Mon, 12 May 2025 18:44:21 +0000 (20:44 +0200)] 
rust: bindgen SCDetectHelperKeywordAliasRegister

Ticket: 7667

8 weeks agorust: bindgen SCDetectHelperBufferRegister
Philippe Antoine [Mon, 12 May 2025 18:39:52 +0000 (20:39 +0200)] 
rust: bindgen SCDetectHelperBufferRegister

Ticket: 7667

8 weeks agorust: bindgen DetectHelperMultiBufferMpmRegister
Philippe Antoine [Mon, 12 May 2025 18:30:31 +0000 (20:30 +0200)] 
rust: bindgen DetectHelperMultiBufferMpmRegister

Ticket: 7667

8 weeks agorust: bindgen SCDetectHelperMultiBufferProgressMpmRegister
Philippe Antoine [Sun, 11 May 2025 20:42:00 +0000 (22:42 +0200)] 
rust: bindgen SCDetectHelperMultiBufferProgressMpmRegister

Ticket: 7667

8 weeks agodetect: fix -Wshorten-64-to-32 warnings for content inspection 13223/head
Philippe Antoine [Mon, 12 May 2025 19:50:04 +0000 (21:50 +0200)] 
detect: fix -Wshorten-64-to-32 warnings for content inspection

Ticket: 6186

8 weeks agodetect/entropy: Correct slot for url initialization
Jeff Lucovsky [Mon, 12 May 2025 17:44:28 +0000 (13:44 -0400)] 
detect/entropy: Correct slot for url initialization

Correct the sigmatch slot for url initialization.

8 weeks agohtp: fix unittests shutdown order
Victor Julien [Sat, 10 May 2025 19:46:18 +0000 (21:46 +0200)] 
htp: fix unittests shutdown order

Make sure to free flow/packets before cleaning up global structs.

Solves an crash sometimes seen on OpenBSD in test HTPParserTest26.

8 weeks agolua: better doc for ja3 lib
Philippe Antoine [Thu, 8 May 2025 19:33:00 +0000 (21:33 +0200)] 
lua: better doc for ja3 lib

Completes commit 7e78ad944c8484bc8e8c3f00d95a0ef1f1850aaa

Tickt: 7605

2 months agolua: convert file functions to lib suricata.file 13211/head
Jason Ish [Thu, 8 May 2025 18:18:44 +0000 (12:18 -0600)] 
lua: convert file functions to lib suricata.file

This also breaks out the fileinfo function into a method per file info
item. And likewise for state, just return the state and add a new method
for checking if the file is stored.

Ticket: #7491

2 months agogithub-ci: use all profraw files in coverage test
Victor Julien [Fri, 9 May 2025 14:09:43 +0000 (16:09 +0200)] 
github-ci: use all profraw files in coverage test

2 months agogithub-ci: add --list-app-layer-hooks checks
Victor Julien [Fri, 9 May 2025 10:14:16 +0000 (12:14 +0200)] 
github-ci: add --list-app-layer-hooks checks

2 months agoapp-layer: add --list-app-layer-hooks options
Victor Julien [Thu, 1 May 2025 20:43:27 +0000 (22:43 +0200)] 
app-layer: add --list-app-layer-hooks options

This provides a list of available hooks.

Ticket: #7702.

2 months agogithub-ci: add -h option to coverage test
Victor Julien [Fri, 9 May 2025 10:14:00 +0000 (12:14 +0200)] 
github-ci: add -h option to coverage test

2 months agopgsql: remove unused "password_message" code
Juliana Fajardini [Thu, 1 May 2025 23:24:00 +0000 (20:24 -0300)] 
pgsql: remove unused "password_message" code

``Password message`` is actually logged just as ``Password``.
Remove related dead code.

2 months agopgsql: clearly indicate redacted password message
Juliana Fajardini [Wed, 30 Apr 2025 23:09:27 +0000 (20:09 -0300)] 
pgsql: clearly indicate redacted password message

If a password message was seen while logging passwords was disabled
for pgsql, this would lead to an empty request being logged.
Instead of simply not logging anything when there is a password message
and this is disabled, however, log instead that said password is
redacted.

Bug #7647

2 months agogithub-ci: use current directory for unit test logging 13207/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 "."

2 months agoschema: add rule keyword mapping for flow
Shivani Bhardwaj [Fri, 9 May 2025 12:18:47 +0000 (17:48 +0530)] 
schema: add rule keyword mapping for flow

2 months agoeve/verdict: log 'accept' for firewall accept rules
Victor Julien [Fri, 9 May 2025 08:07:42 +0000 (10:07 +0200)] 
eve/verdict: log 'accept' for firewall accept rules

Ticket: #7698.

2 months agodecode: remove unnecessary PKT_STREAM_EOF flag
Shivani Bhardwaj [Fri, 9 May 2025 07:16:43 +0000 (12:46 +0530)] 
decode: remove unnecessary PKT_STREAM_EOF flag

PKT_STREAM_EOF flag is set only when a pseudo packet is created. In all
the users of this flag, it suffices to use PKT_PSEUDO_STREAM_END
instead. PKT_PSEUDO_STREAM_END is the more widely used flag as well so
keep it and remove this unneeded flag creating a vacancy.

2 months agostream/reassemble: remove unused min_inspect_depth
Shivani Bhardwaj [Fri, 9 May 2025 06:56:40 +0000 (12:26 +0530)] 
stream/reassemble: remove unused min_inspect_depth

Whether minimum inspection depth should be respected is an important
parameter but it is only used by one caller of StreamReassembleRawDo fn
to calculate progress value. This progress value is already passed as a
parameter to the said fn.

2 months agosrc: apply clang formatting changes
Shivani Bhardwaj [Fri, 9 May 2025 05:32:30 +0000 (11:02 +0530)] 
src: apply clang formatting changes

2 months agosignature: rename num to iid
Shivani Bhardwaj [Fri, 9 May 2025 05:30:20 +0000 (11:00 +0530)] 
signature: rename num to iid

to signify that it refers to the internal ID of the signature and
distinguish it from the "id" param that signifies the "sid" specified in
a rule.