]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
3 months agogithub-actions: f41 codecov improvements 12993/head 13003/head
Victor Julien [Tue, 8 Apr 2025 04:34:22 +0000 (06:34 +0200)] 
github-actions: f41 codecov improvements

Add missing gpg package.

Reduce disk space usage.

3 months agodetect/domain: move transform fully to rust
Victor Julien [Tue, 8 Apr 2025 18:19:36 +0000 (20:19 +0200)] 
detect/domain: move transform fully to rust

3 months agodetect/prefilter: fix coverity issue
Victor Julien [Tue, 8 Apr 2025 18:05:22 +0000 (20:05 +0200)] 
detect/prefilter: fix coverity issue

** CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
/src/detect-engine-prefilter.c: 944 in SetupNonPrefilter()

________________________________________________________________________________________________________
*** CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
/src/detect-engine-prefilter.c: 944 in SetupNonPrefilter()
938                 const DetectBufferType *buf = DetectEngineBufferTypeGetById(de_ctx, list_id);
939                 /* for now, exclude app-layer-events, as they are not tied to a specific
940                  * progress value like other keywords. */
941                 SCLogDebug("list_id %d buf %p", list_id, buf);
942                 if (list_id == app_events_list_id)
943                     continue;
>>>     CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
>>>     Dereferencing "buf", which is known to be "NULL".
944                 if (buf->packet) {
945                     SCLogDebug("packet buf");
946                     /* packet is handled below */
947                     pkt_non_pf = true;
948                 } else if (buf->frame) {
949                     for (DetectEngineFrameInspectionEngine *f = de_ctx->frame_inspect_engines;

3 months agolog-pcap: error out if malloc fails for bpf filter
Jason Ish [Tue, 8 Apr 2025 21:29:03 +0000 (15:29 -0600)] 
log-pcap: error out if malloc fails for bpf filter

3 months agodoc/userguide: type in pfring upgrade notes
Jason Ish [Tue, 8 Apr 2025 14:33:52 +0000 (08:33 -0600)] 
doc/userguide: type in pfring upgrade notes

3 months agoversion: start development towards 8.0.0-rc1
Jason Ish [Tue, 8 Apr 2025 21:21:13 +0000 (15:21 -0600)] 
version: start development towards 8.0.0-rc1

3 months agorelease: 8.0.0-beta1; update changelog suricata-8.0.0-beta1
Shivani Bhardwaj [Tue, 8 Apr 2025 12:36:59 +0000 (18:06 +0530)] 
release: 8.0.0-beta1; update changelog

3 months agolua: enable lua rules by default 12985/head 12986/head
Victor Julien [Tue, 8 Apr 2025 08:15:07 +0000 (10:15 +0200)] 
lua: enable lua rules by default

Now that sandboxing is in place, lua rule support is enabled by default.

3 months agodetect: add ldap.responses.attribute_type 12980/head
Alice Akaki [Sun, 2 Mar 2025 23:41:26 +0000 (19:41 -0400)] 
detect: add ldap.responses.attribute_type

ldap.responses.attribute_type matches on LDAP attribute type/description
This keyword maps the eve field ldap.responses[].search_result_entry.attributes[].type
It is a sticky buffer
Supports multiple buffer matching
Supports prefiltering

Ticket: #7533

3 months agodetect: add ldap.request.attribute_type
Alice Akaki [Thu, 13 Feb 2025 05:18:37 +0000 (01:18 -0400)] 
detect: add ldap.request.attribute_type

ldap.request.attribute_type matches on LDAP attribute type/description
This keyword maps the following eve fields:
ldap.request.search_request.attributes[]
ldap.request.modify_request.changes[].modification.attribute_type
ldap.request.add_request.attributes[].name
ldap.request.compare_request.attribute_value_assertion.description
It is a sticky buffer
Supports multiple buffer matching
Supports prefiltering

Ticket: #7533

3 months agorustfmt: rust/src/ldap/detect.rs
Alice Akaki [Fri, 4 Apr 2025 01:24:14 +0000 (21:24 -0400)] 
rustfmt: rust/src/ldap/detect.rs

3 months agoapp/ftp: Eliminate scan-build warning
Jeff Lucovsky [Fri, 28 Mar 2025 14:12:59 +0000 (10:12 -0400)] 
app/ftp: Eliminate scan-build warning

Scan-build reports that FTPRealloc could be called with size=0. Modify
the logic so it's never passed 0.

3 months agodoc/ftp: Document the ftp.reply keyword
Jeff Lucovsky [Fri, 28 Mar 2025 12:55:28 +0000 (08:55 -0400)] 
doc/ftp: Document the ftp.reply keyword

Issue: 7508

3 months agodetect/ftp: Add ftp.reply rule keyword
Jeff Lucovsky [Thu, 27 Mar 2025 14:30:47 +0000 (10:30 -0400)] 
detect/ftp: Add ftp.reply rule keyword

Issue: 7508

Add the rule detection keyword "ftp.reply". This is a multi-buffer
command.

3 months agoapp/ftp: Use Rust FTP response line handling
Jeff Lucovsky [Fri, 21 Mar 2025 14:01:27 +0000 (10:01 -0400)] 
app/ftp: Use Rust FTP response line handling

Use the Rust logic to parse FTP response lines with the goal to support
multi-buffer matches better.

A side effect is that the completion codes are no longer strings; the
schema update reflects this.

Issue: 4082

3 months agoapp/ftp: Move FTP response handling to rust
Jeff Lucovsky [Fri, 21 Mar 2025 13:57:38 +0000 (09:57 -0400)] 
app/ftp: Move FTP response handling to rust

Move handling of FTP responses to Rust to improve support for FTP
keyword matching. Parsing the response line when encountered
simplifies multi-buffer matching and metadata output.

Issue: 4082

3 months agouserguide/pop3: minor typo and formatting fixing
Juliana Fajardini [Mon, 7 Apr 2025 16:25:08 +0000 (09:25 -0700)] 
userguide/pop3: minor typo and formatting fixing

3 months agopop3: app-layer parser using sawp-pop3
Alex Savage [Mon, 24 Mar 2025 23:41:18 +0000 (23:41 +0000)] 
pop3: app-layer parser using sawp-pop3

This module uses the sawp-pop3 crate to parse POP3 requests and responses
Features:
- eve logging
- events for parsable but non-RFC-compliant messages

Ticket: 3243

3 months agodoc/userguide: doc domain and tld transforms
Eric Leblond [Mon, 31 Mar 2025 14:55:19 +0000 (16:55 +0200)] 
doc/userguide: doc domain and tld transforms

3 months agotld: add new transform
Eric Leblond [Wed, 24 Aug 2022 11:57:56 +0000 (13:57 +0200)] 
tld: add new transform

Extract the TLD from a buffer.

Ticket: #5639

3 months agodomain: add new transformation
Eric Leblond [Tue, 23 Aug 2022 14:44:23 +0000 (16:44 +0200)] 
domain: add new transformation

Ticket: #5639

3 months agoplugin: document app-layer plugins
Philippe Antoine [Fri, 17 Jan 2025 11:18:15 +0000 (12:18 +0100)] 
plugin: document app-layer plugins

Ticket: 7149
Ticket: 7150
Ticket: 7153

3 months agoplugin: add in-tree app-layer template plugin for testing
Philippe Antoine [Wed, 13 Nov 2024 10:07:03 +0000 (11:07 +0100)] 
plugin: add in-tree app-layer template plugin for testing

Ticket: 7151
Ticket: 7152
Ticket: 7154

3 months agorust: export jsonbuilder API in sys crate
Philippe Antoine [Wed, 2 Apr 2025 21:07:13 +0000 (23:07 +0200)] 
rust: export jsonbuilder API in sys crate

using cbindgen + bindgen

3 months agodoc/firewall: start of documentation
Victor Julien [Fri, 28 Mar 2025 14:14:28 +0000 (15:14 +0100)] 
doc/firewall: start of documentation

3 months agofirewall: beginning of ruleset analyzer
Victor Julien [Sat, 29 Mar 2025 07:21:46 +0000 (08:21 +0100)] 
firewall: beginning of ruleset analyzer

Output a `firewall.json` with a per table list of rules.

Also output a sorted list of the threat detection rules.

3 months agofirewall: start of firewall rules support
Victor Julien [Wed, 26 Feb 2025 10:38:35 +0000 (11:38 +0100)] 
firewall: start of firewall rules support

Config:

Firewall rules are like normal rule, with some key differences.

They are loaded separate, and first, from:

```yaml
firewall-rule-path: /etc/suricata/firewall/
firewall-rule-files:
  - fw.rules
```

Can also be loaded with --firewall-rules-exclusive: Mostly for QA purposes.

Allow -S with --firewall-rules-exclusive, so that firewall and threat detection
rules can be tested together.

Rules:

Differences with regular "threat detection" rules:

1. these rules are evaluated before threat detection rules

2. these rules are evaluated in the order as they appear in the rule file

3. currently only rules specifying an explicit hook at supported

   a. as a consequence, no rules will be treated as (like) IP-only, PD-only or
      DE-only

Require explicit action scope for firewall rules. Default policy is
drop for the firewall tables.

Actions:

New action "accept" is added to allow traffic in the filter tables.

New scope "accept:tx" is added to allow accepting a transaction.

Tables:

Rulesets are per table.

Table processing order: `packet:filter` -> `packet:td` -> `app:*:*` -> `app:td`.

Each of the tables has some unique properties:

`packet:filter`:
- default policy is `drop:packet`
- rules are process in order
- action scopes are explicit
- `drop` or `accept` is immediate
- `accept:hook` continues to `packet:td`

`packet:td`:
- default policy is `accept:hook`
- rules are ordered by IDS/IPS ordering logic
- action scopes are implicit
- actions are queued
- continues to `app:*:*` or `alert/action finalize`

`app:*:*`:
- default policy is `drop:flow`
- rules are process in order
- action scopes are explicit
- `drop` is immediate
- `accept` is conditional on possible `drop` from `packet:td`
- `accept:hook` continues to `app:td`, `accept:packet` or `accept:flow`
  continues to `alert/action finalize`

`app:td`:
- default policy is `accept:hook`
- rules are ordered by IDS/IPS ordering logic
- action scopes are implicit
- actions are queued
- continues to `alert/action finalize`

Implementation:

During sigorder, split into packet:filter, app:*:* and general td.

Allow fw rules to work when in pass:flow mode. When firewall mode is enabled,
`pass:flow` will not skip the detection engine anymore, but instead
process the firewall rules and then apply the pass before inspecting threat
detect rules.

3 months agodetect/xbits: implement tx bits
Victor Julien [Fri, 21 Mar 2025 08:42:09 +0000 (09:42 +0100)] 
detect/xbits: implement tx bits

Implement `xbits:set,mybit,track tx;` and `xbits:isset,mybit,track tx;`.

Store these in the AppLayerTxData.

Ticket: #6455.

3 months agoeve/alert: log ts_progress/tc_progress
Victor Julien [Mon, 17 Mar 2025 08:13:08 +0000 (09:13 +0100)] 
eve/alert: log ts_progress/tc_progress

This is mostly to help with debugging firewall rules, but
can be useful in other places.

3 months agodetect/app-layer-state: keyword for protocol state
Victor Julien [Fri, 14 Mar 2025 15:20:15 +0000 (16:20 +0100)] 
detect/app-layer-state: keyword for protocol state

Allow matching on the app-layer protocol state.

3 months agodetect/prefilter: allow special engine for each app update
Victor Julien [Fri, 14 Mar 2025 14:35:58 +0000 (15:35 +0100)] 
detect/prefilter: allow special engine for each app update

Allow registering the progress as -1, which means it will be invoked
each time the app prefilters are called.

3 months agodetect: start of pkt hooks
Victor Julien [Thu, 23 Jan 2025 15:11:30 +0000 (16:11 +0100)] 
detect: start of pkt hooks

New facility to allow a user to specify where to hook a rule
into the engine. This patch adds this for packets, adding two
hooks:

- `all`: to let a rule be evaluated by all rules
- `flow_start`: to have a rule be evaluated only for the first
  packet in both directions

Implemented by adding a hook flags field in the packet.

3 months agodetect/tls.version: allow using rule hook
Victor Julien [Mon, 31 Mar 2025 10:07:05 +0000 (12:07 +0200)] 
detect/tls.version: allow using rule hook

tls.version isn't hooked to a specific state by default. Allow it
to register at the rule hook.

3 months agodetect: explicit action scopes
Victor Julien [Thu, 3 Apr 2025 14:03:13 +0000 (16:03 +0200)] 
detect: explicit action scopes

For drop and pass allow setting the scope explicitly:

        drop:flow
        drop:packet

        pass:flow
        pass:packet

Ticket: #7481.

3 months agodetect/tls: more precise state registration for keywords
Victor Julien [Fri, 28 Feb 2025 08:28:10 +0000 (09:28 +0100)] 
detect/tls: more precise state registration for keywords

3 months agodetect: reuse hook based generic lists
Victor Julien [Mon, 20 Jan 2025 12:05:32 +0000 (13:05 +0100)] 
detect: reuse hook based generic lists

3 months agodetect/lua: use rule hook instead of init() 'needs' table
Victor Julien [Sun, 19 Jan 2025 09:54:41 +0000 (10:54 +0100)] 
detect/lua: use rule hook instead of init() 'needs' table

For registration of app-layer inspection, no longer use the 'needs'
table from the script, but instead use the rule hook setting.

Ticket: #4783.

3 months agodetect: introduce explicit hooks
Victor Julien [Tue, 14 Jan 2025 08:41:11 +0000 (09:41 +0100)] 
detect: introduce explicit hooks

Generic:
        <app_proto>:request_started and <app_proto>:response_started
        <app_proto>:request_complete and <app_proto>:response_complete

Per protocol, it uses the registered progress (state) values. E.g.

        tls:client_hello_done

A rule ruleset could be:

        pass tls:client_hello_done any any -> any any (tls.sni; content:"www.google.com"; sid:21; alert;)
        drop tls:client_hello_done any any -> any any (sid:22;)

The pass rule is evaluated when the client hello is parsed, and if it
doesn't match the drop rule will be evaluated.

Registers each generic lists as "<alproto>:<progress state>:generic"
(e.g. "tls:client_hello_done:generic").

Ticket: #7485.

3 months agohttp1: register progress state names
Victor Julien [Thu, 23 Jan 2025 10:05:48 +0000 (11:05 +0100)] 
http1: register progress state names

Use `request_started` for HTP_REQUEST_NOT_STARTED as when data is
received, the request parsing has started. The request line isn't
complete yet.

Similar for `response_started`.

3 months agotls: expose progress by name
Victor Julien [Fri, 17 Jan 2025 11:10:29 +0000 (12:10 +0100)] 
tls: expose progress by name

3 months agoapp-layer: API for mapping progress name vs id
Victor Julien [Fri, 17 Jan 2025 11:10:01 +0000 (12:10 +0100)] 
app-layer: API for mapping progress name vs id

3 months agotls: introduce per direction progress tracking
Victor Julien [Thu, 16 Jan 2025 11:32:40 +0000 (12:32 +0100)] 
tls: introduce per direction progress tracking

Per direction track progress to be able to have more fine grained
control over where the detection engines and logging hooks in.

3 months agodetect: allow longer buffer names
Victor Julien [Mon, 20 Jan 2025 08:05:04 +0000 (09:05 +0100)] 
detect: allow longer buffer names

To support hook based buffer names.

3 months agodetect: move non-pf rules into special prefilter engines
Victor Julien [Thu, 28 Dec 2023 21:11:56 +0000 (22:11 +0100)] 
detect: move non-pf rules into special prefilter engines

Instead of having a per detection engine list of rule that couldn't be
prefiltered, put those into special "prefilter" engines.

For packet and frame rules this doesn't change much, it just removes
some hard coded logic from the detect engine.

For the packet non-prefilter rules in the "non-prefilter" special prefilter
engine, add additional filtering for the packet variant. It can prefilter on
alproto, dsize and dest port.

The frame non-prefilter rules are added to a single engine, that per
rule checks the alproto and the type.

For app-layer, there is an engine per progress value, per app-layer
protocol and per direction. This hooks app-layer non-prefilter rules
into the app inspect logic at the correct "progress" hook.

e.g. a rule like
        dns.query; bsize:1;

Negated MPM rules will also fall into this category:
        dns.query; content:!"abc";

Are part of a special "generic list" app engine for dns, at the
same progress hook as `dns.query`.

This all results in a lot fewer checks:

previous:

  --------------------------------------------------------------------------
  Date: 1/29/2025 -- 10:22:25. Sorted by: number of checks.
  --------------------------------------------------------------------------
   Num      Rule         Gid      Rev      Ticks        %      Checks   Matches  Max Ticks   Avg Ticks   Avg Match   Avg No Match
  -------- ------------ -------- -------- ------------ ------ -------- -------- ----------- ----------- ----------- --------------
  1        20           1        0        181919672    11.85  588808   221      60454       308.96      2691.46     308.07
  2        50           1        0        223455914    14.56  453104   418      61634       493.17      3902.59     490.02
  3        60           1        0        185990683    12.12  453104   418      60950       410.48      1795.40     409.20
  4        51           1        0        192436011    12.54  427028   6084     61223       450.64      2749.12     417.42
  5        61           1        0        180401533    11.75  427028   6084     61093       422.46      2177.04     397.10
  6        70           1        0        153899099    10.03  369836   0        61282       416.13      0.00        416.13
  7        71           1        0        123389405    8.04   369836   12833    44921       333.63      2430.23     258.27
  8        41           1        0        63889876     4.16   155824   12568    39138       410.01      1981.97     272.10
  9        40           1        0        64149724     4.18   155818   210      39792       411.70      4349.57     406.38
  10       10           1        0        70848850     4.62   65558    0        39544       1080.70     0.00        1080.70
  11       11           1        0        94743878     6.17   65558    32214    60547       1445.19     2616.14     313.92

this commit:

  --------------------------------------------------------------------------
  Date: 1/29/2025 -- 10:15:46. Sorted by: number of checks.
  --------------------------------------------------------------------------
   Num      Rule         Gid      Rev      Ticks        %      Checks   Matches  Max Ticks   Avg Ticks   Avg Match   Avg No Match
  -------- ------------ -------- -------- ------------ ------ -------- -------- ----------- ----------- ----------- --------------
  1        50           1        0        138776766    19.23  95920    418      167584      1446.80     3953.11     1435.83
  2        60           1        0        97988084     13.58  95920    418      182817      1021.56     1953.63     1017.48
  3        51           1        0        105318318    14.60  69838    6084     65649       1508.04     2873.38     1377.74
  4        61           1        0        89571260     12.41  69838    6084     164632      1282.56     2208.41     1194.20
  5        11           1        0        91132809     12.63  32779    32214    373569      2780.22     2785.58     2474.45
  6        10           1        0        66095303     9.16   32779    0        56704       2016.39     0.00        2016.39
  7        70           1        0        48107573     6.67   12928    0        42832       3721.19     0.00        3721.19
  8        71           1        0        32308792     4.48   12928    12833    39565       2499.13     2510.05     1025.09
  9        41           1        0        25546837     3.54   12886    12470    41479       1982.53     1980.84     2033.05
  10       40           1        0        26069992     3.61   12886    210      38495       2023.13     4330.05     1984.91
  11       20           1        0        639025       0.09   221      221      14750       2891.52     2891.52     0.00

3 months agodetect: check for a flow drop first
Victor Julien [Thu, 13 Mar 2025 08:23:22 +0000 (09:23 +0100)] 
detect: check for a flow drop first

3 months agoflow: remove FLOW_NOPACKET_INSPECTION flag
Victor Julien [Thu, 13 Mar 2025 08:20:57 +0000 (09:20 +0100)] 
flow: remove FLOW_NOPACKET_INSPECTION flag

It was not used separately from FLOW_ACTION_PASS.

3 months agodetect: skip duplicate nopacket inspect check
Victor Julien [Wed, 12 Mar 2025 11:05:41 +0000 (12:05 +0100)] 
detect: skip duplicate nopacket inspect check

3 months agooutput: option to add suricata version in eve logs
Philippe Antoine [Thu, 3 Apr 2025 13:34:18 +0000 (15:34 +0200)] 
output: option to add suricata version in eve logs

Ticket: 4853

3 months agopcap-log: define PCAP_NETMASK_UNKNOWN if not set 12968/head
Jason Ish [Fri, 4 Apr 2025 04:35:59 +0000 (22:35 -0600)] 
pcap-log: define PCAP_NETMASK_UNKNOWN if not set

This is defined in by newer versions of libpcap,
but older versions are still in use.

3 months agopcap-log: only allow one instance of pcap-log
Jason Ish [Tue, 1 Apr 2025 21:44:50 +0000 (15:44 -0600)] 
pcap-log: only allow one instance of pcap-log

As a global is used to store state, only one instance can be used.

See https://redmine.openinfosecfoundation.org/issues/7640.

3 months agopcap-log: add stats for written and filtered
Jason Ish [Tue, 1 Apr 2025 22:03:46 +0000 (16:03 -0600)] 
pcap-log: add stats for written and filtered

Filtered is the number of packets not written as they were filtered out.

3 months agopcap-log: add bpf filter for packets that are logged
Jason Ish [Tue, 1 Apr 2025 21:18:54 +0000 (15:18 -0600)] 
pcap-log: add bpf filter for packets that are logged

Add an optional bpf filter to pcap-log. If set, packets must match the
filter to be logged, otherwise they will be ignored.

This allows a user to limit what is logged to disk if they have pcap-log
enabled, but still inspect all data captured.

Ticket: #6832

3 months agohttp: restore behavior for event http.uri_delim_non_compliant
Philippe Antoine [Sat, 5 Apr 2025 19:22:25 +0000 (21:22 +0200)] 
http: restore behavior for event http.uri_delim_non_compliant

If we see a space-like character that is not space 0x20 in uri,
we set this event, even it the request line finished with a normal
space and protocol

Fixes: 9c324b796e6b ("http: Use libhtp-rs.)
3 months agodoc: stylistic and grammar fixes 12965/head
Lukas Sismis [Fri, 4 Apr 2025 10:25:38 +0000 (12:25 +0200)] 
doc: stylistic and grammar fixes

3 months agossh: sync the hassh setting with the defaults
Lukas Sismis [Thu, 19 Sep 2024 07:25:22 +0000 (09:25 +0200)] 
ssh: sync the hassh setting with the defaults

3 months agostream: decouple stream.bypass dependency from tls bypass
Dean Balandin [Tue, 27 Jun 2023 12:40:37 +0000 (12:40 +0000)] 
stream: decouple stream.bypass dependency from tls bypass

Decouple app.protocols.tls.encryption-handling and stream.bypass.
There's no apparent reason why encrypted TLS bypass traffic should
depend on stream bypass, as these are unrelated features.

Ticket: 6788

3 months agossh: add option to select behavior of encrypted parts
Lukas Sismis [Thu, 19 Sep 2024 07:24:01 +0000 (09:24 +0200)] 
ssh: add option to select behavior of encrypted parts

Ticket: 6788

3 months agotls: deprecate "default" as a encryption-handling option
Lukas Sismis [Thu, 27 Mar 2025 16:10:12 +0000 (17:10 +0100)] 
tls: deprecate "default" as a encryption-handling option

The default value for TLS encryption is generic and not precise.
The new keyword, "track-only" substitues the old keyword, being
more on point what action is actually taken when the TLS flow
reaches an encrypted state.

3 months agolua/detect: remove rule sid, rev and gid globals
Jason Ish [Fri, 4 Apr 2025 16:52:51 +0000 (10:52 -0600)] 
lua/detect: remove rule sid, rev and gid globals

For some rules the values are always 0, for others they get set, so not
consistent. Also not documented and not tested and should be replaced by
a "suricata.rule" lib.

For example, these globals would be set for this rule:

alert tcp any any -> any any (flow:to_server;
flowbits:isnotset,dataset_added; lua:dataset.lua;
flowbits:set,dataset_added;sid:1;rev:99;)

But not this rule:

alert dns any any -> any any (msg:"TEST DNS LUA dns.rrname"; \
      content:"org"; lua:test-rrname.lua; sid:1; rev:1;)

Related to ticket
https://redmine.openinfosecfoundation.org/issues/7490 (but not a fix)

This does not affect the functions with similar names for getting rule
details in output context.

3 months agodetect: rename with prefix SCSigTablePreRegister
Philippe Antoine [Wed, 2 Apr 2025 12:24:53 +0000 (14:24 +0200)] 
detect: rename with prefix SCSigTablePreRegister

to make it available to rust via bindgen

3 months agosnmp: restrict rust visibility
Philippe Antoine [Fri, 24 Jan 2025 15:31:01 +0000 (16:31 +0100)] 
snmp: restrict rust visibility

3 months agosnmp: register protocol dynamically
Philippe Antoine [Thu, 16 Jan 2025 08:00:24 +0000 (09:00 +0100)] 
snmp: register protocol dynamically

Ticket: 4103

3 months agosnmp: make log function use the generic prototype
Philippe Antoine [Thu, 16 Jan 2025 07:58:44 +0000 (08:58 +0100)] 
snmp: make log function use the generic prototype

and cast

and also remove unneeded mut

and rustfmt

3 months agooutput: public header for use in rust
Philippe Antoine [Sat, 29 Mar 2025 20:38:18 +0000 (21:38 +0100)] 
output: public header for use in rust

Ticket: 5053

Move enum OutputJsonLogDirection and struct
EveJsonTxLoggerRegistrationData to a public header user by rust
thanks to bindgen

Rename to use SC prefix on the way

And make EveJsonSimpleTxLogFunc use a const pointer to transaction

3 months agoscripts: remove unused code in setup-app-layer
Philippe Antoine [Sat, 29 Mar 2025 20:35:57 +0000 (21:35 +0100)] 
scripts: remove unused code in setup-app-layer

and fix typo

3 months agooutput: plugins can log flow or packet direction
Philippe Antoine [Thu, 16 Jan 2025 07:53:34 +0000 (08:53 +0100)] 
output: plugins can log flow or packet direction

3 months agoapp-layer: helper function AppProtoNewProtoFromString
Philippe Antoine [Thu, 16 Jan 2025 07:45:59 +0000 (08:45 +0100)] 
app-layer: helper function AppProtoNewProtoFromString

So that we do not have to know g_alproto_max to register
dynamically a new protocol from its name

3 months agoapp-layer: make some arrays even more dynamic
Philippe Antoine [Thu, 16 Jan 2025 07:40:46 +0000 (08:40 +0100)] 
app-layer: make some arrays even more dynamic

Ticket: 5053

Do not asume that we know the number of alprotos at the end
of AppLayerNamesSetup, but make arrays allocated by later
AppLayerProtoDetectSetup dynamic so that it can be reallocated
from AppLayerParserRegisterProtocolParsers

This helps have a single entry point for a protocol like SNMP

3 months agodetect: fix overflow for files protocol
Philippe Antoine [Wed, 15 Jan 2025 19:59:12 +0000 (20:59 +0100)] 
detect: fix overflow for files protocol

CID 1640392

Would happen only if we reached 15 protocols handling files

3 months agosmb/log: configuration option for types logging 12951/head
Philippe Antoine [Thu, 20 Mar 2025 10:07:05 +0000 (11:07 +0100)] 
smb/log: configuration option for types logging

suricata.yaml output section for smb now parses a types list
and will restrict logging of transactions to these types.

By default, everything still gets logged

Remove unused rs_smb_log_json_request on the way

Ticket: 7620

3 months agoconf: extend API for rust
Philippe Antoine [Thu, 20 Mar 2025 09:42:56 +0000 (10:42 +0100)] 
conf: extend API for rust

Will allow rust to list the values of an array such as
dns.types for outputs

3 months agopgsql: use generic name for TerminationMessage msg 12948/head
Juliana Fajardini [Fri, 4 Apr 2025 21:34:26 +0000 (14:34 -0700)] 
pgsql: use generic name for TerminationMessage msg

Since this structure can be used for different messages with other
meanings.

Related to
Task #4854

3 months agodoc/pgsql: document CopyOut-related response msgs
Juliana Fajardini [Fri, 4 Apr 2025 22:17:55 +0000 (15:17 -0700)] 
doc/pgsql: document CopyOut-related response msgs

Related to
Task #4854

3 months agopgsql: add initial support to copy-out subproto
Juliana Fajardini [Wed, 2 Apr 2025 03:00:07 +0000 (20:00 -0700)] 
pgsql: add initial support to copy-out subproto

This sub-protocol inspects messages exchanged between postgresql backend
and frontend after a 'COPY TO STDOUT' has been processed.

Parses new messages:
- CopyOutResponse -- initiates copy-out mode/sub-protocol
- CopyData -- data transfer messages
- CopyDone -- signals that no more CopyData messages will be seen from
  the sender for the current transaction

Task #4854

3 months agodetect/transforms: Add engine detect thread ctx to signature
Jeff Lucovsky [Fri, 4 Apr 2025 14:54:20 +0000 (10:54 -0400)] 
detect/transforms: Add engine detect thread ctx to signature

Modify the transform function signature to include the detect engine
thread ctx.

3 months agodoc/ftp: Add ftp.command_data 12942/head
Jeff Lucovsky [Sat, 29 Mar 2025 12:22:15 +0000 (08:22 -0400)] 
doc/ftp: Add ftp.command_data

This commits adds documentation for the ftp.command_data rule keyword
that includes usage examples.

3 months agodetect/ftp: ftp.command_data keyword
Jeff Lucovsky [Fri, 28 Mar 2025 15:01:15 +0000 (11:01 -0400)] 
detect/ftp: ftp.command_data keyword

Issue: 7503

Add the rule keyword ftp.command_data; a sticky buffer that matches on
the values send with FTP commands, e.g., USER someuser

3 months agorust: fix clippy warning manual_contains 12938/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

3 months agorust: fix clippy warnings doc_overindented_list_items
Philippe Antoine [Thu, 3 Apr 2025 11:40:39 +0000 (13:40 +0200)] 
rust: fix clippy warnings doc_overindented_list_items

warning: doc list item overindented
   --> src/nfs/rpc_records.rs:284:5
    |
284 | ///           type: bool
    |     ^^^^^^^^^^ help: try using `  ` (2 spaces)
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
    = note: `#[warn(clippy::doc_overindented_list_items)]` on by default

3 months agorust: fix clippy missing_abi warning
Philippe Antoine [Mon, 31 Mar 2025 19:12:22 +0000 (21:12 +0200)] 
rust: fix clippy missing_abi warning

warning: extern declarations without an explicit ABI are deprecated
  --> src/core.rs:72:1
   |
72 | extern {
   | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
   |
   = note: `#[warn(missing_abi)]` on by default

3 months agodoc/sdp: fix doc to match real keywords names
Philippe Antoine [Thu, 3 Apr 2025 07:23:10 +0000 (09:23 +0200)] 
doc/sdp: fix doc to match real keywords names

Ticket: 7291

3 months agoci: make a build with ja disabled
Philippe Antoine [Thu, 27 Mar 2025 19:40:42 +0000 (20:40 +0100)] 
ci: make a build with ja disabled

Ticket: 7461

In order to run all SV tests in CI, including the ones that
require the abse,ce of the JA3 or JA4 feature

3 months agohttp: Use libhtp-rs.
Todd Mortimer [Mon, 26 Jun 2023 20:01:50 +0000 (20:01 +0000)] 
http: Use libhtp-rs.

Ticket: #2696

There are a lot of changes here, which are described below.

In general these changes are renaming constants to conform to the
libhtp-rs versions (which are generated by cbindgen); making all htp
types opaque and changing struct->member references to
htp_struct_member() function calls; and a handful of changes to offload
functionality onto libhtp-rs from suricata, such as URI normalization
and transaction cleanup.

Functions introduced to handle opaque htp_tx_t:
- tx->parsed_uri => htp_tx_parsed_uri(tx)
- tx->parsed_uri->path => htp_uri_path(htp_tx_parsed_uri(tx)
- tx->parsed_uri->hostname => htp_uri_hostname(htp_tx_parsed_uri(tx))
- htp_tx_get_user_data() => htp_tx_user_data(tx)
- htp_tx_is_http_2_upgrade(tx) convenience function introduced to detect response status 101
  and “Upgrade: h2c" header.

Functions introduced to handle opaque htp_tx_data_t:
- d->len => htp_tx_data_len()
- d->data => htp_tx_data_data()
- htp_tx_data_tx(data) function to get the htp_tx_t from the htp_tx_data_t
- htp_tx_data_is_empty(data) convenience function introduced to test if the data is empty.

Other changes:

Build libhtp-rs as a crate inside rust. Update autoconf to no longer
use libhtp as an external dependency. Remove HAVE_HTP feature defines
since they are no longer needed.

Make function arguments and return values const where possible

htp_tx_destroy(tx) will now free an incomplete transaction

htp_time_t replaced with standard struct timeval

Callbacks from libhtp now provide the htp_connp_t and the htp_tx_data_t
as separate arguments. This means the connection parser is no longer
fetched from the transaction inside callbacks.

SCHTPGenerateNormalizedUri() functionality moved inside libhtp-rs, which
now provides normalized URI values.
The normalized URI is available with accessor function: htp_tx_normalized_uri()
Configuration settings added to control the behaviour of the URI normalization:
- htp_config_set_normalized_uri_include_all()
- htp_config_set_plusspace_decode()
- htp_config_set_convert_lowercase()
- htp_config_set_double_decode_normalized_query()
- htp_config_set_double_decode_normalized_path()
- htp_config_set_backslash_convert_slashes()
- htp_config_set_bestfit_replacement_byte()
- htp_config_set_convert_lowercase()
- htp_config_set_nul_encoded_terminates()
- htp_config_set_nul_raw_terminates()
- htp_config_set_path_separators_compress()
- htp_config_set_path_separators_decode()
- htp_config_set_u_encoding_decode()
- htp_config_set_url_encoding_invalid_handling()
- htp_config_set_utf8_convert_bestfit()
- htp_config_set_normalized_uri_include_all()
- htp_config_set_plusspace_decode()
Constants related to configuring uri normalization:
- HTP_URL_DECODE_PRESERVE_PERCENT => HTP_URL_ENCODING_HANDLING_PRESERVE_PERCENT
- HTP_URL_DECODE_REMOVE_PERCENT => HTP_URL_ENCODING_HANDLING_REMOVE_PERCENT
- HTP_URL_DECODE_PROCESS_INVALID => HTP_URL_ENCODING_HANDLING_PROCESS_INVALID

htp_config_set_field_limits(soft_limit, hard_limit) changed to
htp_config_set_field_limit(limit) because libhtp didn't implement soft
limits.

libhtp logging API updated to provide HTP_LOG_CODE constants along with
the message. This eliminates the need to perform string matching on
message text to map log messages to HTTP_DECODER_EVENT values, and the
HTP_LOG_CODE values can be used directly. In support of this,
HTP_DECODER_EVENT values are mapped to their corresponding HTP_LOG_CODE
values.

New log events to describe additional anomalies:
HTP_LOG_CODE_REQUEST_TOO_MANY_LZMA_LAYERS
HTP_LOG_CODE_RESPONSE_TOO_MANY_LZMA_LAYERS
HTP_LOG_CODE_PROTOCOL_CONTAINS_EXTRA_DATA
HTP_LOG_CODE_CONTENT_LENGTH_EXTRA_DATA_START
HTP_LOG_CODE_CONTENT_LENGTH_EXTRA_DATA_END
HTP_LOG_CODE_SWITCHING_PROTO_WITH_CONTENT_LENGTH
HTP_LOG_CODE_DEFORMED_EOL
HTP_LOG_CODE_PARSER_STATE_ERROR
HTP_LOG_CODE_MISSING_OUTBOUND_TRANSACTION_DATA
HTP_LOG_CODE_MISSING_INBOUND_TRANSACTION_DATA
HTP_LOG_CODE_ZERO_LENGTH_DATA_CHUNKS
HTP_LOG_CODE_REQUEST_LINE_UNKNOWN_METHOD
HTP_LOG_CODE_REQUEST_LINE_UNKNOWN_METHOD_NO_PROTOCOL
HTP_LOG_CODE_REQUEST_LINE_UNKNOWN_METHOD_INVALID_PROTOCOL
HTP_LOG_CODE_REQUEST_LINE_NO_PROTOCOL
HTP_LOG_CODE_RESPONSE_LINE_INVALID_PROTOCOL
HTP_LOG_CODE_RESPONSE_LINE_INVALID_RESPONSE_STATUS
HTP_LOG_CODE_RESPONSE_BODY_INTERNAL_ERROR
HTP_LOG_CODE_REQUEST_BODY_DATA_CALLBACK_ERROR
HTP_LOG_CODE_RESPONSE_INVALID_EMPTY_NAME
HTP_LOG_CODE_REQUEST_INVALID_EMPTY_NAME
HTP_LOG_CODE_RESPONSE_INVALID_LWS_AFTER_NAME
HTP_LOG_CODE_RESPONSE_HEADER_NAME_NOT_TOKEN
HTP_LOG_CODE_REQUEST_INVALID_LWS_AFTER_NAME
HTP_LOG_CODE_LZMA_DECOMPRESSION_DISABLED
HTP_LOG_CODE_CONNECTION_ALREADY_OPEN
HTP_LOG_CODE_COMPRESSION_BOMB_DOUBLE_LZMA
HTP_LOG_CODE_INVALID_CONTENT_ENCODING
HTP_LOG_CODE_INVALID_GAP
HTP_LOG_CODE_ERROR

The new htp_log API supports consuming log messages more easily than
walking a list and tracking the current offset. Internally, libhtp-rs
now provides log messages as a queue of htp_log_t, which means the
application can simply call htp_conn_next_log() to fetch the next log
message until the queue is empty. Once the application is done with a
log message, they can call htp_log_free() to dispose of it.

Functions supporting htp_log_t:
htp_conn_next_log(conn) - Get the next log message
htp_log_message(log) - To get the text of the message
htp_log_code(log) - To get the HTP_LOG_CODE value
htp_log_free(log) - To free the htp_log_t

3 months agodoc: update configuration with flow rate-tracking 12931/head
Shivani Bhardwaj [Wed, 2 Apr 2025 09:17:21 +0000 (14:47 +0530)] 
doc: update configuration with flow rate-tracking

Feature 5647

3 months agoutil: add initial flow rate tracking implementation
Shivani Bhardwaj [Sat, 29 Mar 2025 13:33:16 +0000 (19:03 +0530)] 
util: add initial flow rate tracking implementation

In order to track flow rate and thus determine a course of action or
categorize it as elephant flow, track a flow's byte count per direction
in a ring buffer for a given time interval.

The implementation is simple and keeps overwriting the buffer and
updating the final sum. The sum of all the elements in the ring buffer
at any point in time should reflect the number of bytes for the
respective flow in the last of a given configured interval.
e.g. if the definition says that the flows must be tracked by a rate of
100k bytes in 10 seconds, the ring buffer at any point in time should
carry the total number of bytes seen by the respective flow in the last
10 seconds.

So far, the implementation only supports reading the flow rate
definition from suricata.yaml and using it to track the flows.

This solution adds up a space complexity to the existing Flow struct.
However, the added space complexity should only take effect if the
feature is in use. Since this buffer extends the Flow struct, it does
not impact the usual business logic or complexity of the code.

This implementation is currently limited to defining the time interval
of flow rate in seconds only. However, the number of seconds defined are
directly proportional to the aforementioned added space complexity as
that's the size of the ring buffer.

Feature 5647

3 months agojsonbuilder: prefix C API with SC
Jason Ish [Wed, 2 Apr 2025 04:38:27 +0000 (22:38 -0600)] 
jsonbuilder: prefix C API with SC

3 months agodetect: add email.x_mailer keyword
Alice Akaki [Tue, 1 Apr 2025 22:35:57 +0000 (18:35 -0400)] 
detect: add email.x_mailer keyword

email.x_mailer matches on MIME EMAIL X-Mailer
This keyword maps to the EVE field email.x_mailer
It is a sticky buffer
Supports prefiltering

Ticket: #7598

3 months agodetect: add email.message_id keyword
Alice Akaki [Tue, 1 Apr 2025 19:40:25 +0000 (15:40 -0400)] 
detect: add email.message_id keyword

email.message_id matches on MIME EMAIL Message-Id
This keyword maps to the EVE field email.message_id
It is a sticky buffer
Supports prefiltering

Ticket: #7593

3 months agomime/email: remove unnecessary logs
Alice Akaki [Wed, 2 Apr 2025 20:38:11 +0000 (16:38 -0400)] 
mime/email: remove unnecessary logs

fields 'date' and 'subject' are logged by enabling extended logging mode

3 months agodetect/flowbits: implement prefilter support
Victor Julien [Wed, 2 Apr 2025 07:09:48 +0000 (09:09 +0200)] 
detect/flowbits: implement prefilter support

Allow for more efficient rules that 'prefilter' on flowbits with 'isset' logic.

This prefilter is enabled by default, which means that if no mpm is present or
no explicit prefilter is used, the flowbits prefilter will be set up for a rule.

flowbits 'isset' prefilter

For rules that have a 'flowbits:isset,<bit>' statement, a "regular" prefilter
facility is created. It means that the rules are removed from the normal
match list(s) and added to a prefilter engine that runs prior to the individual
rule inspection stage.

Implementation: the prefilter is implemented as an RB_TREE of flowbits, with the
rule id's they "enable" stored per tree node. The matching logic is walking the
list of bits set in the flow and looking each of them up in the RB_TREE, adding
the rule ids of each of the matching bits to the list of rule candidates.

The 'isset' prefilter has one important corner case, which is that bits can in
fact be set during the rule evaluation stage. This is different from all other
prefilter engines, that evaluate an immutable state (for the lifetime of the
packet inspection).

flowbits 'set' post-match prefilter

For flowbits 'set' action, special post-match 'prefilter' facilities deal with
this corner case. The high level logic is that these track which 'isset' sigs
depend on them, and add these dependencies to the candidates list when a 'set'
action occurs.

This is implemented in a few steps:

1. flowbits 'set' is flagged
2. when 'set' action occurs the flowbit is added to a "post rule
   match work queue"
3. when the rule evaluation ends, the post-match "prefilter" engine is run
   on each of the flowbits in the "post rule match work queue"
4. these engines ammend the candidates list with the rule id dependencies
   for the flowbit
5. the candidates list is sorted to make sure within the execution for that
   packet the inspection order is maintained

Ticket: #2486.

3 months agodetect/prefilter: add post-match 'prefilter' engine
Victor Julien [Wed, 2 Apr 2025 07:06:57 +0000 (09:06 +0200)] 
detect/prefilter: add post-match 'prefilter' engine

Add support for special post-match engines. This allows a rule to enable
other rules when it matches.

Implementation is similar to prefilter engines, however prefilter
engines run before individual rules while this post-match engine runs
after and individual rule match. It will then add the new rules to the
existing rule list.

3 months agodetect/prefilter: fix pointer check
Victor Julien [Wed, 26 Feb 2025 19:16:18 +0000 (20:16 +0100)] 
detect/prefilter: fix pointer check

3 months agoflowbits: allow setter to know if set is new
Victor Julien [Mon, 10 Oct 2022 09:42:02 +0000 (11:42 +0200)] 
flowbits: allow setter to know if set is new

3 months agoflowbits: toggle returns state of the bit
Victor Julien [Fri, 10 Jun 2022 19:07:15 +0000 (21:07 +0200)] 
flowbits: toggle returns state of the bit

3 months agodetect: generic callback for md5-like keywords
Philippe Antoine [Tue, 7 Jan 2025 13:34:19 +0000 (14:34 +0100)] 
detect: generic callback for md5-like keywords

Ticket: 5634

3 months agodetect: use buffer ptr in validate callback api
Philippe Antoine [Tue, 15 Oct 2024 13:28:19 +0000 (15:28 +0200)] 
detect: use buffer ptr in validate callback api

Ticket: 5634

Allows to share the same validator functions when only the buffer
id is changing like for urilen, while still accessing the buffer
name for error logs

3 months agodetect/sdp: minor style fixup 12922/head
Victor Julien [Wed, 2 Apr 2025 08:30:01 +0000 (10:30 +0200)] 
detect/sdp: minor style fixup

3 months agodoc: add sdp sticky buffers
Giuseppe Longo [Mon, 30 Dec 2024 15:39:25 +0000 (16:39 +0100)] 
doc: add sdp sticky buffers

3 months agosdp: add sdp.media.encryption_key sticky buffer
Giuseppe Longo [Mon, 30 Dec 2024 15:38:35 +0000 (16:38 +0100)] 
sdp: add sdp.media.encryption_key sticky buffer

This adds a sticky (multi) buffer to match the "Encryption key" subfield
of the "Media description" field in both requests and responses.

Ticket #7291

3 months agosdp: add sdp.media.connection_data sticky buffer
Giuseppe Longo [Wed, 2 Oct 2024 08:25:59 +0000 (10:25 +0200)] 
sdp: add sdp.media.connection_data sticky buffer

This adds a sticky (multi) buffer to match the "Connection data"
subfield of the "Media description" field in both requests and
responses.

Ticket #7291