]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
8 weeks agodecode/ipv4: add missing ip-in-ip case handling 13370/head
Juliana Fajardini [Wed, 4 Jun 2025 17:56:25 +0000 (14:56 -0300)] 
decode/ipv4: add missing ip-in-ip case handling

A flow with IPv4 IP in IP traffic won't handle this tunneling case
properly.
This leads to potential malicious traffic not triggering alerts, as well
as other inaccuracies in the logs.

Bug #7725

8 weeks agodecode/ipv4: apply-clang formatting changes
Juliana Fajardini [Wed, 4 Jun 2025 19:33:22 +0000 (16:33 -0300)] 
decode/ipv4: apply-clang formatting changes

8 weeks agodoc/lua: remove reference to removed functions
Jason Ish [Wed, 4 Jun 2025 17:32:11 +0000 (11:32 -0600)] 
doc/lua: remove reference to removed functions

These have all been replaced by libs and already documented in their
lib format.

Ticket: #7728

8 weeks agolua/output: access luastate within lock
Jason Ish [Wed, 4 Jun 2025 17:26:52 +0000 (11:26 -0600)] 
lua/output: access luastate within lock

Fixes Coverity issue:

CID 1648445: (#1 of 1): Data race condition (MISSING_LOCK)
4. missing_lock: Accessing td->lua_ctx->luastate without holding lock
LogLuaCtx_.m. Elsewhere, LogLuaCtx_.luastate is written to with
LogLuaCtx_.m held 41 out of 41 times.

8 weeks agopgsql: fix clippy warnings 13366/head
Juliana Fajardini [Thu, 22 May 2025 13:48:15 +0000 (10:48 -0300)] 
pgsql: fix clippy warnings

8 weeks agopgsql: fix typo in comment that changed meaning
Juliana Fajardini [Tue, 20 May 2025 21:13:18 +0000 (18:13 -0300)] 
pgsql: fix typo in comment that changed meaning

8 weeks agopgsql: debug validation on duplicated request msgs
Juliana Fajardini [Tue, 20 May 2025 15:59:10 +0000 (12:59 -0300)] 
pgsql: debug validation on duplicated request msgs

There shouldn't be duplicated messages in the requests Vec. And thus
the parser shouldn't log duplicated keys nor messages. Add debug
validations to ensure this.

With PGSQL's current state machine, most frontend/ client messages will
lead to the creation of a new transaction - which would prevent
duplicated messages being pushed to the requests array and reaching the
logger.

The current exceptions for that are:

- CopyDataIn
- CopyDone
- CopyFail

Thus, debug statements were added for those cases.

CopyDone and CopyFail, per the documentation, shouldn't be seen
duplicated on the wire for the same transaction. CopyDataIn -- yes, but
we consolidate those, so the expectation is that they won't be
duplicated in the requests array or when reaching the logger either.

Related to
Task #7645

8 weeks agopgsql: separate request completion and state type
Juliana Fajardini [Tue, 20 May 2025 18:56:03 +0000 (15:56 -0300)] 
pgsql: separate request completion and state type

Since some of state types could indicate a request completion, don't
process them in if/else statements.

Related to
Task #7645

8 weeks agopgsql: be more strict with pub usage
Juliana Fajardini [Thu, 22 May 2025 13:28:01 +0000 (10:28 -0300)] 
pgsql: be more strict with pub usage

Review pub visibility to:
Make it pub crate-only wherever possible.
Remove pub altogether where not-needed.

8 weeks agopgsql: reorganize pgsql states for CopyData msgs
Juliana Fajardini [Fri, 16 May 2025 16:17:23 +0000 (13:17 -0300)] 
pgsql: reorganize pgsql states for CopyData msgs

To set apart states that are both for frontend and backend.

8 weeks agopgsql: rename copy in/out response field
Juliana Fajardini [Tue, 13 May 2025 16:33:31 +0000 (13:33 -0300)] 
pgsql: rename copy in/out response field

We used `copy_column_count`, while just `columns` is more accurate with
what PostgreSQL describes, and what Wireshark shows.

Related to
Task #7644
Task #7645

8 weeks agopgsql: rename 'dummy' response variables
Juliana Fajardini [Sat, 10 May 2025 19:35:08 +0000 (16:35 -0300)] 
pgsql: rename 'dummy' response variables

While this could be considered minor, they were not just bad, but
misleading names, as the variables weren't really `dummy` responses,
but consolidating several messages.

8 weeks agopgsql: add initial support to CopyIn mode/subproto
Juliana Fajardini [Tue, 29 Apr 2025 13:33:38 +0000 (10:33 -0300)] 
pgsql: add initial support to CopyIn mode/subproto

This sub-protocol inspects messages sent mainly from the frontend to
the backend after a 'COPY FROM STDIN' has been processed by the
backend.

Parses new messages:
- CopyInResponse -- initiates copy-in mode/sub-protocol
- CopyData (In) -- data transfer message, from frontend to backend
- CopyDone -- signals that no more CopyData messages will be seen from
  the frontend, for the current transaction
- CopyFail -- used by the frontend to signal some failure to proceed
  with sending CopyData messages

Task #7645

8 weeks agoschema/psgql: fix fields order
Juliana Fajardini [Thu, 22 May 2025 16:35:02 +0000 (13:35 -0300)] 
schema/psgql: fix fields order

8 weeks agopgsql: document CopyOut messages
Juliana Fajardini [Thu, 1 May 2025 17:20:41 +0000 (14:20 -0300)] 
pgsql: document CopyOut messages

Related to
Task #7644

8 weeks agopgsql: allow multi-request transactions
Juliana Fajardini [Thu, 1 May 2025 00:48:07 +0000 (21:48 -0300)] 
pgsql: allow multi-request transactions

Important for CopyIn mode/ subprotocol, where the frontend is the one
sending 0 or more messages to the backend as part of a transaction.

Related to
Task #7645

8 weeks agopgsql: make CopyData struct generic
Juliana Fajardini [Tue, 29 Apr 2025 13:31:52 +0000 (10:31 -0300)] 
pgsql: make CopyData struct generic

We have a data structure that can be used both for backend and frontend
messages, but was named as backend only.

Related to
Task #7645

8 weeks agotransforms: move base64 to rust 13361/head
Philippe Antoine [Tue, 3 Jun 2025 11:32:47 +0000 (13:32 +0200)] 
transforms: move base64 to rust

Ticket: 7733

8 weeks agodetect: remove unused transform ids
Philippe Antoine [Tue, 3 Jun 2025 11:32:18 +0000 (13:32 +0200)] 
detect: remove unused transform ids

As they are now dynamic from rust

8 weeks agobase64: use more precise and compact type for mode
Philippe Antoine [Tue, 3 Jun 2025 08:11:02 +0000 (10:11 +0200)] 
base64: use more precise and compact type for mode

8 weeks agotransform: move rust base64 to dedicated subdirectory
Philippe Antoine [Tue, 3 Jun 2025 07:47:01 +0000 (09:47 +0200)] 
transform: move rust base64 to dedicated subdirectory

8 weeks agorust: update brotli crate to latest version
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

8 weeks agolua/util: move SCThreadInfo into suricata.util lib
Jason Ish [Mon, 2 Jun 2025 23:23:08 +0000 (17:23 -0600)] 
lua/util: move SCThreadInfo into suricata.util lib

Move the SCThreadInfo global function into the suricata.util library as
thread_info().

This is the last global function to be registered, so remove the
supporting functions.

8 weeks agolua: simplify streaming output setup
Jason Ish [Mon, 2 Jun 2025 22:54:16 +0000 (16:54 -0600)] 
lua: simplify streaming output setup

Setup the init function to simply return:

   {streaming = "tcp"}

or

   {streaming = "http"}

The returned table can have a lot of parameters that don't make sense
together, this should simplify this one case.

8 weeks agolua/streaming: provide streaming buffer as argument
Jason Ish [Mon, 2 Jun 2025 21:47:03 +0000 (15:47 -0600)] 
lua/streaming: provide streaming buffer as argument

When setting up a Lua output script for streaming data, we're
explicitly requesting stream data. Just pass the streaming data as
arguments, rather than requiring the script to make an extra call to
get the stream data.

The streaming data will be passed in the "stream" field of the args
passed to the log function.

Eliminates the SCStreamingBuffer Lua function.

8 weeks agolua/bytevar: convert SCByteVar to Lua lib
Jason Ish [Mon, 2 Jun 2025 20:37:57 +0000 (14:37 -0600)] 
lua/bytevar: convert SCByteVar to Lua lib

Similar to flowvars and flowints, but a byte var cannot be registered
from a Lua script, but it still needs to be setup. Instead provide an
"map" function that sets it up, or errors out if the byte var is
unknown.

This also required passing the signature into the Lua init method, as
the state of the Signature object and the time of loading the Lua
keyword is required.

8 weeks agolua/logging: re-add lua script and line numbers
Jason Ish [Mon, 2 Jun 2025 16:04:19 +0000 (10:04 -0600)] 
lua/logging: re-add lua script and line numbers

Note that while we try to log the Lua function name, its never
logged. Instead "Lua" is logged as the function name.

8 weeks agoutil/debug: expose more raw logging macros
Jason Ish [Mon, 2 Jun 2025 16:03:27 +0000 (10:03 -0600)] 
util/debug: expose more raw logging macros

Add raw logging macros for config, perf and debug.

8 weeks agolua: fix coverity unchecked return
Jason Ish [Mon, 2 Jun 2025 15:07:20 +0000 (09:07 -0600)] 
lua: fix coverity unchecked return

CID 1648351: (#1 of 1): Unchecked return value (CHECKED_RETURN)
1. check_return: Calling lua_getstack without checking return value (as is done elsewhere 9 out of 10 times).

8 weeks agolua: create suricata.config lua lib
Jason Ish [Fri, 30 May 2025 22:54:29 +0000 (16:54 -0600)] 
lua: create suricata.config lua lib

Currently only provides "log_path" as a replacement for SCLogPath.

8 weeks agohttp1: use a blocking cursor for decompression
Philippe Antoine [Tue, 3 Jun 2025 07:11:35 +0000 (09:11 +0200)] 
http1: use a blocking cursor for decompression

Kind of as is done by HTTP2 which limits input data instead of
output data

Ticket: 7732

8 weeks agoci: check cargo fmt for htp
Philippe Antoine [Tue, 3 Jun 2025 07:11:24 +0000 (09:11 +0200)] 
ci: check cargo fmt for htp

8 weeks agodcerpc: use wrapping to prevent u16 overflow
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

8 weeks agogithub-actions: bump github/codeql-action from 3.28.16 to 3.28.18
dependabot[bot] [Sun, 1 Jun 2025 20:06:51 +0000 (20:06 +0000)] 
github-actions: bump github/codeql-action from 3.28.16 to 3.28.18

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.16 to 3.28.18.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.28.16...v3.28.18)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
8 weeks agogithub-actions: bump ossf/scorecard-action from 2.4.1 to 2.4.2
dependabot[bot] [Sun, 1 Jun 2025 20:06:36 +0000 (20:06 +0000)] 
github-actions: bump ossf/scorecard-action from 2.4.1 to 2.4.2

Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/f49aabe0b5af0936a0987cfb85d86b75731b0186...05b42c624433fc40578a4040d5cf5e36ddca8cde)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-version: 2.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
8 weeks agogithub-actions: bump codecov/codecov-action from 5.4.2 to 5.4.3
dependabot[bot] [Sun, 1 Jun 2025 20:06:32 +0000 (20:06 +0000)] 
github-actions: bump codecov/codecov-action from 5.4.2 to 5.4.3

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/ad3126e916f78f00edff4ed0317cf185271ccc2d...18283e04ce6e62d37312384ff67231eb8fd56d24)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
8 weeks agodoc/payload: fix typo, minor formatting changes 13356/head
Juliana Fajardini [Mon, 2 Jun 2025 14:30:41 +0000 (11:30 -0300)] 
doc/payload: fix typo, minor formatting changes

8 weeks agodocs/exceptions: minor improvements
Juliana Fajardini [Tue, 27 May 2025 21:13:54 +0000 (18:13 -0300)] 
docs/exceptions: minor improvements

Add section label and doc reference, add another term to Common terms
section.

Tried to also improve readability for the Midstream behavior tables:
- Highlight key-words when differences are only in `do` vs `no`.
- Change order of sentences in certain descriptions, to align with the
  steps those happen for the engine.

8 weeks agodoc/exceptions: clarify ambiguous terminology
Juliana Fajardini [Tue, 6 May 2025 17:52:19 +0000 (14:52 -0300)] 
doc/exceptions: clarify ambiguous terminology

The terms 'inspection' and 'detection' were being used to signify
different engine actions in this document, while throughout the
documentation and code they're many times interchangeable.

Replace 'inspection' with 'parsing' or even 'decoding and parsing' as
more appropriate.

Add a small glossary to clarify what we mean with those terms.

8 weeks agodoc/exceptions: standardize page section markdown
Juliana Fajardini [Tue, 6 May 2025 17:07:40 +0000 (14:07 -0300)] 
doc/exceptions: standardize page section markdown

Following the discussion on #7396, use those symbols for to keep the
standard.
Remove the repeting `Exception Policies` section header, too.

Related to
Task #7396

8 weeks agodoc/rule-types: fix typo
Juliana Fajardini [Tue, 27 May 2025 20:43:28 +0000 (17:43 -0300)] 
doc/rule-types: fix typo

8 weeks agotransform: fix identity function for base64 xfrom
Philippe Antoine [Sun, 18 May 2025 20:37:31 +0000 (22:37 +0200)] 
transform: fix identity function for base64 xfrom

As SCDetectTransformFromBase64Data is not a flat structure,
because it has pointers to other buffers, we cannot use it simply
for TransformId

We need to compute a serialization of the data hold by
SCDetectTransformFromBase64Data and own it.

2 months agolua: convert log functions to suricata.log lib 13339/head
Jason Ish [Fri, 30 May 2025 17:02:44 +0000 (11:02 -0600)] 
lua: convert log functions to suricata.log lib

Convert the Lua global functions for logging (SCLogInfo, etc) to a Lua
lib names "suricata.log".

Ticket: #7727

2 months agodetect/analyzer: use note instead of warning
Shivani Bhardwaj [Thu, 29 May 2025 09:04:57 +0000 (14:34 +0530)] 
detect/analyzer: use note instead of warning

It is invalid to issue a warning based purely on pattern matching
between the matched content and certain http methods. Without a check
for which keyword exists in the rule, it makes more sense to issue this
as a general note.

Bug 5177

2 months agoutil/flow-rate: fix sum calc on index next to base
Shivani Bhardwaj [Thu, 10 Apr 2025 06:36:05 +0000 (12:06 +0530)] 
util/flow-rate: fix sum calc on index next to base

When the buffer is wrapped around, for any new index, the calculation
must subtract the previous value stored in the buffer. So far, the code
ended up adding to the existing buffer value on the index unless it was
the first index after wrapping around. This is incorrect and would end
up flagging a flow as elephant a lot before than it should be.

Harden the Test06 by checking for such a case.

Bug 7694

2 months agomdns: add mdns parser, logger and detection 13334/head
Jason Ish [Wed, 28 May 2025 18:43:05 +0000 (12:43 -0600)] 
mdns: add mdns parser, logger and detection

The mDNS support is based heavily on the DNS support, reusing the
existing DNS parser where possible. This meant adding variations on
DNS, as mDNS is a little different. Mainly being that *all* mDNS
traffic is to_server, yet there is still the concept of request and
responses.

Keywords added are:
- mdns.queries.rrname
- mdns.answers.rrname
- mdns.additionals.rrname
- mdns.authorities.rrname
- mdns.response.rrname

They are mostly in-line with the DNS keywords, except
mdns.answers.rdata which is a better than that mdns.response.rrname,
as its actually looking at the rdata, and not rrnames.

mDNS has its own logger that differs from the DNS logger:

- No grouped logging

- In answers/additionals/authorities, the rdata is logged in a field
  that is named after the rdata type. For example, "txt" data is no
  longer logged in the "rdata" field, but instead a "txt" field. We
  currently already did this in DNS for fields that were not a single
  buffer, like SOA, SRV, etc. So this makes things more consistent. And
  gives query like semantics that the "grouped" object was trying to
  provide.

- Types are logged in lower case ("txt" instead of "TXT")

- Flags are logged as an array: "flags": ["aa", "z"]

Ticket: #3952

2 months agodns: parse multiple txt segments into an array
Jason Ish [Tue, 27 May 2025 17:27:23 +0000 (11:27 -0600)] 
dns: parse multiple txt segments into an array

A DNS TXT answer record can actually be made of up multiple TXT
entries in a single record. Suricata currently expands these into
multiple TXT records, however that is not very representative of the
actualy DNS message.

Instead, if a TXT record contains multiple labels, parse them into an
array.

We still expand multiple TXT segements into multiple TXT records at
logging time for compatibility, but this will allow something like
MDNS to log more accurately to the protocol.

2 months agopgsql: add query keyword 13331/head
Juliana Fajardini [Sun, 25 May 2025 21:58:40 +0000 (18:58 -0300)] 
pgsql: add query keyword

Add the `pgsql.query` rule keyword to match on PGSQL's query
request message contents. This currently matches on the EVE field:

pgsql.request.simple_query

`pgsql.query` is a sticky buffer and can be used as a fast_pattern.

Task #6259

2 months agogithub-ci: enable asan for suricata-lua-sys in fuzz build
Jason Ish [Wed, 21 May 2025 20:09:15 +0000 (14:09 -0600)] 
github-ci: enable asan for suricata-lua-sys in fuzz build

2 months agogithub-ci/macos: don't pass CFLAGS to make
Jason Ish [Tue, 20 May 2025 20:53:57 +0000 (14:53 -0600)] 
github-ci/macos: don't pass CFLAGS to make

With autoconf, CFLAGS should only need to be passed to
./configure. They're then memorized in the generated Makefiles.

2 months agogithub-ci: cache npcap binary download
Jason Ish [Tue, 20 May 2025 17:32:35 +0000 (11:32 -0600)] 
github-ci: cache npcap binary download

2 months agorust: pass CC to to cargo
Jason Ish [Tue, 20 May 2025 20:41:13 +0000 (14:41 -0600)] 
rust: pass CC to to cargo

This is required for crates that use a C compiler to use the same one as
used by Suricata. Important for cross compiling.

Also pass AR and RANLIB which are often used for cross compiling.

2 months agolua: update to suricata-lua-sys 0.1.0-alpha.9
Jason Ish [Tue, 20 May 2025 17:03:23 +0000 (11:03 -0600)] 
lua: update to suricata-lua-sys 0.1.0-alpha.9

This version supports picking up CFLAGS either passed with CFLAGS or
SURICATA_LUA_SYS_CFLAGS.

2 months 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.

2 months 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

2 months 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

2 months 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.

2 months 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

2 months 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

2 months 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.

2 months 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.

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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.

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

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

Ticket: 7667

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

Ticket: 7667

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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"

2 months 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.

2 months 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

2 months 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.

2 months 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.

2 months 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

2 months 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

2 months 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.

2 months 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

2 months 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

2 months 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

2 months 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.

2 months 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

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

Ticket: 7667

2 months 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.

2 months 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