]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
3 years agonfs3: enforce more values
Victor Julien [Sun, 20 Feb 2022 22:02:13 +0000 (23:02 +0100)] 
nfs3: enforce more values

Enforce values of a number of u32's that are used as bools or for
really low values.

3 years agorpc: enforce various field values
Victor Julien [Mon, 21 Feb 2022 09:08:41 +0000 (10:08 +0100)] 
rpc: enforce various field values

Minimal frag_len. Correct msgtype and others.

3 years agonfs/rpc: update full record parsers to be more exact
Victor Julien [Sun, 20 Feb 2022 09:00:48 +0000 (10:00 +0100)] 
nfs/rpc: update full record parsers to be more exact

Instead of 'take'ing all data for the RPC prog_data and then
letting the higher level parsers figure out which part to use
take the exact amount.

3 years agonfs: break out partial record handling
Victor Julien [Sun, 20 Feb 2022 07:59:05 +0000 (08:59 +0100)] 
nfs: break out partial record handling

3 years agonfs/rpc: enforce length field limits
Victor Julien [Sat, 19 Feb 2022 07:42:35 +0000 (08:42 +0100)] 
nfs/rpc: enforce length field limits

Limits based on the Linux kernel limits. Then multiplied a few times
to allow for other implementations to have higher limits.

3 years agonfs4: verify bool fields
Victor Julien [Mon, 21 Feb 2022 11:20:13 +0000 (12:20 +0100)] 
nfs4: verify bool fields

3 years agooutput: fix timestamp missing usecs
Victor Julien [Fri, 18 Feb 2022 09:19:04 +0000 (10:19 +0100)] 
output: fix timestamp missing usecs

On ARM 32bit with Musl `tv_usecs` is defined as `int64_t` which lead to
CreateIsoTimeString() printing all zeros on the usecs. Work around this
by first assigning to a `int64_t` and then updating the expected format
string to accept `int64_t`.

Bug: #5094.

3 years agorust/derive: pin proc-macro-crate to v1.1.0. 7022/head
Jason Ish [Thu, 17 Feb 2022 13:23:38 +0000 (07:23 -0600)] 
rust/derive: pin proc-macro-crate to v1.1.0.

The just released proc-macro-crate v1.1.2 requires at least Rust 1.53.
Pin to the previous release for now.

3 years agorust/mime: convert parser to nom7
Pierre Chifflier [Wed, 19 Jan 2022 10:58:49 +0000 (11:58 +0100)] 
rust/mime: convert parser to nom7

3 years agodetect/address: use common cidr code 7018/head
Victor Julien [Thu, 17 Feb 2022 15:53:43 +0000 (16:53 +0100)] 
detect/address: use common cidr code

3 years agoradix: fix unittests after stict checks
Victor Julien [Thu, 17 Feb 2022 12:35:45 +0000 (13:35 +0100)] 
radix: fix unittests after stict checks

3 years agoradix: improve address range handling
Victor Julien [Thu, 17 Feb 2022 12:32:17 +0000 (13:32 +0100)] 
radix: improve address range handling

Handle non-exact address ranges from string. This can come directly
from user input, so here it is accepted but the address is converted
to the address range start. A warning will be issued.

Debug validation checks are added to catch this.

This issue could lead to bad input from iprep (with cidr), defrag config
and htp server personalities to produce a bad radix tree.

Bug: #5084.
Bug: #5085.
Bug: #5086.

3 years agodetect/iponly: fix netmask handling
Victor Julien [Tue, 15 Feb 2022 19:43:27 +0000 (20:43 +0100)] 
detect/iponly: fix netmask handling

If the ipaddress was not the address range start, it was not masked to turn
it into that. So 1.2.3.4/24 was not stored as address 1.2.3.0 with netmask 24,
but as 1.2.3.4 with netmask 24. This was then propagated into the radix tree,
where it was used as an exact key in exact lookups, giving unexpected results.

This patch implements the netmask handling for IPv4 and IPv6, and adds a set
of tests for it.

Bug: #5081.
Bug: #5066.

3 years agoradix: fix unittest not cleaning up
Victor Julien [Tue, 15 Feb 2022 13:44:08 +0000 (14:44 +0100)] 
radix: fix unittest not cleaning up

3 years agodetect/iponly: update SigNumArray comment
Victor Julien [Sat, 12 Feb 2022 07:23:03 +0000 (08:23 +0100)] 
detect/iponly: update SigNumArray comment

3 years agoradix: cleanup test
Victor Julien [Fri, 11 Feb 2022 14:53:41 +0000 (15:53 +0100)] 
radix: cleanup test

3 years agoradix: add tests for Bug #5066
Victor Julien [Fri, 11 Feb 2022 14:52:51 +0000 (15:52 +0100)] 
radix: add tests for Bug #5066

Bug: #5066.

3 years agoradix: fix FP/FN issue in IP-only
Victor Julien [Fri, 11 Feb 2022 14:50:01 +0000 (15:50 +0100)] 
radix: fix FP/FN issue in IP-only

A bug was reported about the IP-only rules not correctly matching. This was
traced to the rules in question not getting recorded into the IP-only radix
tree correctly.

Sequence:

- 100.117.241.0/25 inserted into the tree

- 100.117.241.0/26 inserted into the tree

Both are part of the same radix node, but recorded by their different netmasks
in the user data portion.

Then faulty insert happens:

- 100.117.241.64/26

For reference, these net blocks compute to:

- 100.117.241.0/25:  100.117.241.0  - 100.117.241.127
- 100.117.241.0/26:  100.117.241.0  - 100.117.241.63
- 100.117.241.64/26: 100.117.241.64 - 100.117.241.127

The IP-only engine first does a search to get to the user data it may need to
include. It does so for with `SCRadixFindKeyIPV4ExactMatch` for single IPs, or
using `SCRadixFindKeyIPV4Netblock` in case of a netblock. Any "match" from
either of these is considered an "exact match" by the IP-only setup code.

This exact match expectation turned out to be wrong and
`SCRadixFindKeyIPV4Netblock` behaved more like "best match" instead, which is
a non-exact match, but its the next best match if no exact match is found.

The way the look up for 100.117.241.64/26 went wrong, is that it returned
the user data for 100.117.241.0/26. This happens as follows:

- first it would do an exact find, which didn't give a result

- then it removed bits from the keystream until it found a matching node
  and explore if any of the netmasks it contained matched. Here the first
  step of the bug started:

  it considered the netmask (with user data) a match that matched the
  number of bits of the matching key, but not of the actual range netmask cidr
  value.

  So in this case the number of shared bits between `100.117.241.0/25` and
  `100.117.241.64/26` was 25, so it assumed that the user data for the
  netmask 25 was the match.

  To summarize this step, there are 2 problems with this:
  1. it returns a match on something that isn't an exact match
  2. it considered the wrong netmask value

- the radix code then took the returned node, and did the netmask check
  again. This time it did use its own netmask value, so this time
  it did find the netmask 26 (+ user data). However because of the node that
  was returned, this netmask (+user data) belongs to `100.117.241.0`, not to
  `100.117.241.64`.

- the IP-only detection code was satisfied with what it assumed to be
  "exact match" and just updated the user data to include the user data that
  should have been associated with `100.117.241.64/26` to `100.117.241.0/26`.

This patch addresses the issue as follows:

It makes `SCRadixFindKeyIPV4Netblock` also return an exact match by propagating
the netmask in the search and in the evaluation of the stored netmasks.

It does away with the secondary netmask (+user data) evaluation.
`SCRadixFindKeyIPV4Netblock` is expected to handle this correctly.

The IP-only engine will fall back to the "not found" path, which does an explicit
"best match" lookup and then insert a new entry into the radix tree based on
the user data of the "best match".

Issue was present for IPv6 as well.

Bug: #5066.

3 years agodetect/iponly: cleanups
Victor Julien [Thu, 10 Feb 2022 08:04:23 +0000 (09:04 +0100)] 
detect/iponly: cleanups

3 years agodetect/iponly: minor debug 'Print' improvements
Victor Julien [Thu, 10 Feb 2022 07:50:07 +0000 (08:50 +0100)] 
detect/iponly: minor debug 'Print' improvements

3 years agoradix: minor debug 'Print' improvements
Victor Julien [Thu, 10 Feb 2022 07:49:17 +0000 (08:49 +0100)] 
radix: minor debug 'Print' improvements

3 years agoutil/cidr: simplify IPv4 CIDR handling; add IPv6
Victor Julien [Thu, 17 Feb 2022 09:56:53 +0000 (10:56 +0100)] 
util/cidr: simplify IPv4 CIDR handling; add IPv6

Instead of building a table at init just calculate it on demand.

Callsites are all during init, so its not performance critical.

Add similar function for IPv6.

3 years agodoc/userguide: minor rewording and reformatting for runmodes 7013/head
Victor Julien [Wed, 16 Feb 2022 06:47:41 +0000 (07:47 +0100)] 
doc/userguide: minor rewording and reformatting for runmodes

3 years agodevguide: add page about app-layer frame support
Juliana Fajardini [Tue, 21 Sep 2021 21:26:26 +0000 (22:26 +0100)] 
devguide: add page about app-layer frame support

This explains the frame support from the perspective of a developer,
with introductory explanation on how to add frame support to an
applayer proto.

Doc #4697

3 years agohttp: add comment tags to support documentation
Juliana Fajardini [Wed, 9 Feb 2022 18:12:11 +0000 (18:12 +0000)] 
http: add comment tags to support documentation

With these, the portion of code within the tags should be included
in the related code-snippets (for frame support documentation) w/o
errors, even if the code within changes. The tags can also work as
a reminder that the existing code is being shown elsewhere, so folks
know documentation might need updates, in case of major changes.

3 years agorust: add comment tags to support documentation
Juliana Fajardini [Wed, 9 Feb 2022 17:26:25 +0000 (17:26 +0000)] 
rust: add comment tags to support documentation

With these, the portion of code within the tags should be included
in the related code-snippets (for frame support documentation) w/o
errors, even if the code within changes. The tags can also work as
a reminder that the existing code is being shown elsewhere, so folks
know documentation might need updates, in case of major changes.

3 years agosip: apply rustfmt to a few functions
Juliana Fajardini [Tue, 15 Feb 2022 16:14:50 +0000 (16:14 +0000)] 
sip: apply rustfmt to a few functions

Our current rust code isn't always documentation friendly when it
comes to using code snippets. Used rustfmt to apply rust default
formatting on functions that we wanted to show in our documentation
for Frame support

3 years agotelnet: apply rustfmt to parse_request
Juliana Fajardini [Wed, 9 Feb 2022 13:29:45 +0000 (13:29 +0000)] 
telnet: apply rustfmt to parse_request

When we want to share our code in our documentation pages, the current
rust formatting isn't so nice to read. Formatted just the portion of
the code that will be shown, for now.

3 years agonfs: limits the number of active transactions per flow
Philippe Antoine [Thu, 3 Feb 2022 20:55:09 +0000 (21:55 +0100)] 
nfs: limits the number of active transactions per flow

Ticket: 4530

3 years agonfs: remove unused events variable
Philippe Antoine [Tue, 15 Feb 2022 17:00:01 +0000 (18:00 +0100)] 
nfs: remove unused events variable

3 years agonfs: derive AppLayerEvent for NFSEvent
Philippe Antoine [Thu, 3 Feb 2022 20:58:51 +0000 (21:58 +0100)] 
nfs: derive AppLayerEvent for NFSEvent

3 years agofuzz: test for too many open txs in a flow
Philippe Antoine [Thu, 6 Jan 2022 14:51:00 +0000 (15:51 +0100)] 
fuzz: test for too many open txs in a flow

so as to avoid performance problems coming from this.

3 years agoswf: fix coverity warnings 7003/head
Victor Julien [Tue, 15 Feb 2022 06:56:57 +0000 (07:56 +0100)] 
swf: fix coverity warnings

*** CID 1499365:    (UNINIT)
/src/util-file-swf-decompression.c: 98 in FileSwfZlibDecompression()
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
97         inflateInit(&infstream);

>>>     CID 1499365:    (UNINIT)
>>>     Using uninitialized value "infstream.total_out" when calling "inflate".
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:
103                 break;

/src/util-file-swf-decompression.c: 98 in FileSwfZlibDecompression()
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
97         inflateInit(&infstream);

>>>     CID 1499365:    (UNINIT)
>>>     Using uninitialized value "infstream.total_out" when calling "inflate".
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:
103                 break;

*** CID 1499363:  Error handling issues  (CHECKED_RETURN)
/src/util-file-swf-decompression.c: 97 in FileSwfZlibDecompression()
91
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
>>>     CID 1499363:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "inflateInit_(&infstream, "1.2.11", 112)" without checking return value. This library function may fail and return an error code.
97         inflateInit(&infstream);
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:

Bug: #5079.

3 years agodnp3/eve: regenerate object logging code
Victor Julien [Tue, 15 Feb 2022 06:42:08 +0000 (07:42 +0100)] 
dnp3/eve: regenerate object logging code

To propagate jb_set_string_from_bytes() generator update.

Bug: #5080.

3 years agodnp3: update gen script to use jb_set_string_from_bytes
Victor Julien [Tue, 15 Feb 2022 06:37:02 +0000 (07:37 +0100)] 
dnp3: update gen script to use jb_set_string_from_bytes

Bug: #5080.

3 years agobuild: remove configure check for cargo vendor 6996/head
Jason Ish [Fri, 11 Feb 2022 15:26:06 +0000 (09:26 -0600)] 
build: remove configure check for cargo vendor

cargo vendor has been part of the core cargo command since Rust 1.37,
and are minimum Rust version is not 1.41, so remove the check. Its
always available now.

3 years agorust/make: fix maintainer-clean-local target
Jason Ish [Fri, 11 Feb 2022 15:13:31 +0000 (09:13 -0600)] 
rust/make: fix maintainer-clean-local target

Was using the wrong name, so vendored Rust crates were not being
cleaned up on make maintainer-clean.

3 years agorust/dcerpc: convert parser to nom7 functions
Pierre Chifflier [Wed, 19 Jan 2022 10:41:52 +0000 (11:41 +0100)] 
rust/dcerpc: convert parser to nom7 functions

3 years agolog/stack: Propagate original signal 6979/head
Jeff Lucovsky [Fri, 11 Feb 2022 15:38:45 +0000 (10:38 -0500)] 
log/stack: Propagate original signal

Issue: 4550

This commit modifies the "stack trace on signal" to propagate the
original signal received instead of always raising SIGABRT.

3 years agorust/ntp: upgrade dependency on ntp-parser 6974/head
Pierre Chifflier [Wed, 12 Jan 2022 09:50:42 +0000 (10:50 +0100)] 
rust/ntp: upgrade dependency on ntp-parser

3 years agogithub: bump MSRV and minimum known version 6971/head
Victor Julien [Thu, 10 Feb 2022 11:46:31 +0000 (12:46 +0100)] 
github: bump MSRV and minimum known version

3 years agogithub: remove xenial build
Victor Julien [Thu, 10 Feb 2022 11:41:55 +0000 (12:41 +0100)] 
github: remove xenial build

3 years agorust/ike: convert parser to nom7 functions and upgrade dependency
Pierre Chifflier [Wed, 12 Jan 2022 13:12:26 +0000 (14:12 +0100)] 
rust/ike: convert parser to nom7 functions and upgrade dependency

3 years agorust/rfb: convert parser to nom7 functions
Pierre Chifflier [Wed, 19 Jan 2022 10:16:40 +0000 (11:16 +0100)] 
rust/rfb: convert parser to nom7 functions

3 years agocodecov: fix informational; disable github annotations 6962/head
Victor Julien [Wed, 9 Feb 2022 14:33:48 +0000 (15:33 +0100)] 
codecov: fix informational; disable github annotations

3 years agoapp-layer: fix counter setup logic 6958/head
Victor Julien [Wed, 9 Feb 2022 07:31:01 +0000 (08:31 +0100)] 
app-layer: fix counter setup logic

Completes 0ccf5b914766335425d262de7f69b959c527329c

3 years agoframes: address coverity issue
Victor Julien [Wed, 9 Feb 2022 07:23:19 +0000 (08:23 +0100)] 
frames: address coverity issue

Minor cleanups to assist coverity.

Bug: #5065.

3 years agodetect-bytetest: remove unittests 6956/head
Modupe Falodun [Mon, 7 Feb 2022 21:50:37 +0000 (22:50 +0100)] 
detect-bytetest: remove unittests

These tests are reimplemented as Suricata-Verify

Task: 4911

3 years agocodecov: set to informational 6947/head
Victor Julien [Mon, 7 Feb 2022 19:10:31 +0000 (20:10 +0100)] 
codecov: set to informational

3 years agoci: formatting errors are now fatal
Victor Julien [Tue, 1 Feb 2022 16:19:38 +0000 (17:19 +0100)] 
ci: formatting errors are now fatal

3 years agosip: enable for 5061/udp
Victor Julien [Sun, 23 Jan 2022 07:07:24 +0000 (08:07 +0100)] 
sip: enable for 5061/udp

3 years agosip: add frames support
Victor Julien [Tue, 8 Feb 2022 08:52:35 +0000 (09:52 +0100)] 
sip: add frames support

Frames:
- sip.pdu
- sip.request_line
- sip.response_line
- sip.request_headers
- sip.response_headers
- sip.request_body
- sip.response_body

The `sip.pdu` frame is always created, the rest only if the record
parser succeeded.

Ticket: #5036.

3 years agoframes: support UDP frames
Victor Julien [Fri, 21 Jan 2022 14:20:51 +0000 (15:20 +0100)] 
frames: support UDP frames

UDP frames point to the UDP packet payloads.

The frames are removed after each packet.

Ticket: #4983.

3 years agooutput/file: remove 'waldo' code 6935/head
Victor Julien [Sat, 5 Feb 2022 16:32:15 +0000 (17:32 +0100)] 
output/file: remove 'waldo' code

It was no longer used after "file-store v1" was removed.

3 years agofile/store: warning grammer fixup
Victor Julien [Sat, 5 Feb 2022 16:24:21 +0000 (17:24 +0100)] 
file/store: warning grammer fixup

3 years agohtp: rearrange tx user data for more efficiency
Victor Julien [Tue, 30 Mar 2021 14:08:36 +0000 (16:08 +0200)] 
htp: rearrange tx user data for more efficiency

3 years agooutput/lua: minor cleanups
Victor Julien [Sun, 6 Feb 2022 12:56:35 +0000 (13:56 +0100)] 
output/lua: minor cleanups

3 years agooutput/streaming: use unique thread data name
Victor Julien [Sun, 6 Feb 2022 12:54:09 +0000 (13:54 +0100)] 
output/streaming: use unique thread data name

3 years agooutput/stats: use unique thread data name
Victor Julien [Sun, 6 Feb 2022 12:53:05 +0000 (13:53 +0100)] 
output/stats: use unique thread data name

3 years agooutput/packet: use unique thread data name
Victor Julien [Sun, 6 Feb 2022 12:51:57 +0000 (13:51 +0100)] 
output/packet: use unique thread data name

3 years agooutput/filedata: use unique thread data name
Victor Julien [Sun, 6 Feb 2022 12:50:07 +0000 (13:50 +0100)] 
output/filedata: use unique thread data name

3 years agooutput/file: use unique thread data name
Victor Julien [Sun, 6 Feb 2022 12:45:58 +0000 (13:45 +0100)] 
output/file: use unique thread data name

3 years agooutput/tx: use unique thread data name
Victor Julien [Sun, 6 Feb 2022 12:42:36 +0000 (13:42 +0100)] 
output/tx: use unique thread data name

3 years agooutput: minor header cleanups
Victor Julien [Sun, 6 Feb 2022 12:32:25 +0000 (13:32 +0100)] 
output: minor header cleanups

3 years agooutput: declare OutputLoggerThreadStore once
Victor Julien [Sun, 6 Feb 2022 07:06:39 +0000 (08:06 +0100)] 
output: declare OutputLoggerThreadStore once

3 years agoapp-layer: fix error counter logic
Victor Julien [Fri, 4 Feb 2022 09:29:03 +0000 (10:29 +0100)] 
app-layer: fix error counter logic

3 years agogithub: enable dependabot for Rust/cargo 6925/head
Victor Julien [Thu, 3 Feb 2022 22:02:38 +0000 (23:02 +0100)] 
github: enable dependabot for Rust/cargo

3 years agodetect-uricontent: convert unittests to FAIL/PASS APIs 6924/head
Modupe Falodun [Wed, 2 Feb 2022 19:21:24 +0000 (20:21 +0100)] 
detect-uricontent: convert unittests to FAIL/PASS APIs

3 years agodetect-uricontent: remove unittests
Modupe Falodun [Wed, 2 Feb 2022 18:52:49 +0000 (19:52 +0100)] 
detect-uricontent: remove unittests

These tests are reimplemented as Suricata-verify

Task: 4911

3 years agodetect-engine-enip: remove unittests
Modupe Falodun [Tue, 1 Feb 2022 22:24:05 +0000 (23:24 +0100)] 
detect-engine-enip: remove unittests

These test is reimplemented in Suricata-Verify

Task: 4911

3 years agoapp-layer: error counters
Victor Julien [Tue, 9 Nov 2021 12:45:54 +0000 (13:45 +0100)] 
app-layer: error counters

Per app-layer error counters for:
gap, parser, internal (AppLayerResult issues), alloc

3 years agoflow/manager: remove dead code
Victor Julien [Thu, 11 Nov 2021 12:28:44 +0000 (13:28 +0100)] 
flow/manager: remove dead code

3 years agostream: remove unused defines
Victor Julien [Thu, 25 Nov 2021 07:23:24 +0000 (08:23 +0100)] 
stream: remove unused defines

3 years agodoc: refresh main README; more accurate CI description 6911/head
Victor Julien [Tue, 1 Feb 2022 06:44:24 +0000 (07:44 +0100)] 
doc: refresh main README; more accurate CI description

3 years agodetect-dce-opnum: remove unittests
Modupe Falodun [Mon, 31 Jan 2022 21:53:27 +0000 (22:53 +0100)] 
detect-dce-opnum: remove unittests

These tests are reimplemented in Suricata-Verify

Task: 4911

3 years agodevguide: move image generation into sphinx setup
Jason Ish [Mon, 31 Jan 2022 18:06:55 +0000 (12:06 -0600)] 
devguide: move image generation into sphinx setup

While ReadTheDocs can't execute arbitrary scripts, we can install
mscgen in the container that builds the docs (see .readthedocs.yaml).

Then instead of calling generate-images.sh from the Makefile, move this
into the setup function defined on conf.yaml, which will generate the
scripts as part of a normal Sphinx workflow.

This should give us an image generation solution that works on
ReadTheDocs, and locally within anyones build system provided they have
mscgen installed.

3 years agosmtp: check if we have a current transaction
Philippe Antoine [Tue, 25 Jan 2022 20:10:37 +0000 (21:10 +0100)] 
smtp: check if we have a current transaction

Ticket: 4948

This is not the perfect solution, but it prevents to trigger
the assert, and keep the assert.
A better solution would need to create transaction from
the reponse parsing, in case a later command was buffered and
not answered. But this would not be enough as NoNewTx prevents
the creation of a new transaction for RSET...

3 years agodoc: suricata.yaml fields about maximum transactions
Philippe Antoine [Thu, 13 Jan 2022 15:05:46 +0000 (16:05 +0100)] 
doc: suricata.yaml fields about maximum transactions

For HTTP2, MQTT and FTP.

3 years agoftp: limits the number of active transactions per flow
Philippe Antoine [Thu, 13 Jan 2022 14:51:04 +0000 (15:51 +0100)] 
ftp: limits the number of active transactions per flow

Ticket: 4530

As for HTTP2 and MQTT.
In FTP case, transactions are pipelined, not identified by an id.
So, there are less chances of DOS by quadratic complexity.

3 years agomqtt: make max transactions configurable
Philippe Antoine [Wed, 12 Jan 2022 20:58:47 +0000 (21:58 +0100)] 
mqtt: make max transactions configurable

Allows users to find balance between completeness of decoding
and increases resource consumption, which can DOS suricata.

3 years agohttp2: makes some settings configurable
Philippe Antoine [Thu, 6 Jan 2022 15:04:17 +0000 (16:04 +0100)] 
http2: makes some settings configurable

max-streams and max-table-size

Allows users to find balance between completeness of decoding
and increases resource consumption, which can DOS suricata.

3 years agomqtt: limits the number of active transactions per flow
Philippe Antoine [Thu, 2 Dec 2021 09:03:05 +0000 (10:03 +0100)] 
mqtt: limits the number of active transactions per flow

Ticket: 4530

So, that we do not get DOS by quadratic complexity, while
looking for a new pkt_id over the ever growing list
of active transactions

3 years agohttp2: limits the number of active transactions per flow
Philippe Antoine [Thu, 2 Dec 2021 08:54:05 +0000 (09:54 +0100)] 
http2: limits the number of active transactions per flow

Ticket: 4530

So, that we do not get DOS by quadratic complexity, while
looking for a new stream id over the ever growing list
of active streams

3 years agofuzz: target for applayer cleans transactions
Philippe Antoine [Thu, 17 Jun 2021 13:02:30 +0000 (15:02 +0200)] 
fuzz: target for applayer cleans transactions

Ticket: 4530

Otherwise, we timeout because we kept too many of them
as Suricata would not

3 years agosrc: use bool instead of int 6907/head
Aaron Bungay [Mon, 1 Mar 2021 02:41:13 +0000 (02:41 +0000)] 
src: use bool instead of int

3 years agosmtp/mime: configurable url scheme extraction
Aaron Bungay [Sun, 19 Apr 2020 22:22:18 +0000 (18:22 -0400)] 
smtp/mime: configurable url scheme extraction

Parse extract-url-schemes from the mime config.
e.g. 'extract-urls-schemes: [http, https, ftp, mailto]'
Update MimeDecConfig struct to new url extraction fields.
Change app-layer-smtp.c & util-decode-mime.c to initialize new struct
fields for MimeDecConfig.
Sets the default value for extract-url-schemes if not found in the
config to 'extract-urls-schemes: [http]' for backwards compatibility.

Uses the schemes defined in the mime config value for
extract-urls-schemes to search for URLS starting with those scheme
names followed by "://".
Logs the URLS with the scheme + '://' at the start if the
log-url-scheme is set in the mime config, otherwise the old behaviour
is reverted to and the urls are logged with the schemes stripped.

Removed unused constant URL_STR now that URLS are being searched for
using extract-urls-schemes mime config values instead of just URL's
starting with 'http://'.

Added commented out new options for extract-urls-schemes and
log-url-scheme to suricata.yaml.in.

Update FindUrlStrings comments.
Remove old outdated comments/commented code from FindUrlStrings.
Update test case for mime which now needs schemes list to be set.
Add Test Cases for FindUrlStrings() method.

Feature: #2054

3 years agogithub-ci: replace failing CentOS 8 by AlmaLinux 8.4 6903/head
Victor Julien [Mon, 31 Jan 2022 10:42:10 +0000 (11:42 +0100)] 
github-ci: replace failing CentOS 8 by AlmaLinux 8.4

3 years agodetect-flowbits: remove unittests
Modupe Falodun [Sun, 30 Jan 2022 14:06:09 +0000 (15:06 +0100)] 
detect-flowbits: remove unittests

These tests are reimplemented in Suricata-Verify

Task: 4911

3 years agomqtt: parse properties with the right buffer's length
Philippe Antoine [Sun, 23 Jan 2022 20:30:22 +0000 (21:30 +0100)] 
mqtt: parse properties with the right buffer's length

3 years agohttp2: event for variable-length integer overflow
Philippe Antoine [Tue, 25 Jan 2022 08:01:54 +0000 (09:01 +0100)] 
http2: event for variable-length integer overflow

http2_parse_var_uint can overflow the variable-length
integer it is decoding. In this case, it now returns an error
of kind LengthValue.

The new function http2_parse_headers_blocks, which factorizes
the code loop for headers, push promise, and continuation, will
check for this specific error, and instead of erroring itself,
will return the list of so far parsed headers, plus another one
with HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeIntegerOverflow

This status is then checked by process_headers to create an
app-layer event.

3 years agohttp2: check overflow before it happens
Philippe Antoine [Sun, 23 Jan 2022 20:22:32 +0000 (21:22 +0100)] 
http2: check overflow before it happens

instead of checking afterwards if value got smaller

3 years agogithub-ci: update commit and formatting containers 6894/head
Jason Ish [Thu, 27 Jan 2022 17:20:31 +0000 (11:20 -0600)] 
github-ci: update commit and formatting containers

Update the Ubuntu containers for the commit and formatting checks to
Ubuntu 20.04.

The latest version of the checkout action requires git v2.18 in order to
checkout the code as a git repo, which is required for these workflows.

With older versions of git the action will download the code as a
tarball and lack the .git directory.

3 years agogithub-ci: pin actions to specific versions
Jason Ish [Fri, 21 Jan 2022 21:29:48 +0000 (15:29 -0600)] 
github-ci: pin actions to specific versions

Resolve the GitHub scanning pinned-dependencies for most of our GitHub
actions.  The oss-fuzz actions have not been updated.

3 years agodetect: logs an error if a protocol is disabled
Philippe Antoine [Thu, 9 Dec 2021 14:40:09 +0000 (15:40 +0100)] 
detect: logs an error if a protocol is disabled

So that the user knows that the rule cannot match

3 years agodetect: checking validity of rules with http protocol
Philippe Antoine [Fri, 28 Jan 2022 13:02:32 +0000 (14:02 +0100)] 
detect: checking validity of rules with http protocol

We want to check that a rule beginning with alert http
can be valid, that is if either HTTP1 or HTTP2 is enabled.
So, AppLayerProtoDetectGetProtoName will do a more complex
check for this ALPROTO_HTTP (any).

3 years agogeneral: Fix typo
Jeff Lucovsky [Thu, 27 Jan 2022 17:30:14 +0000 (12:30 -0500)] 
general: Fix typo

3 years agoconfig/ref: Raise errors for ref.config parsing
Jeff Lucovsky [Wed, 26 Jan 2022 21:35:12 +0000 (16:35 -0500)] 
config/ref: Raise errors for ref.config parsing

This commit raises an error in configuration test mode if there was an
error parsing reference.config.

Issue: 4659

3 years agodetect/bypass: remove unittest
Modupe Falodun [Thu, 27 Jan 2022 14:32:30 +0000 (15:32 +0100)] 
detect/bypass: remove unittest

This test is reimplemented in Suricata-Verify

Task: 4911

3 years agogithub-ci: update codecov 6880/head
Victor Julien [Fri, 28 Jan 2022 09:37:08 +0000 (10:37 +0100)] 
github-ci: update codecov

Update to v2 API.
Pin the version as suggested by Scorecard.
No longer fail on error. This was not found to be very actionable.

3 years agogithub-ci: set workflow permissions to read-all
Jason Ish [Fri, 21 Jan 2022 21:45:59 +0000 (15:45 -0600)] 
github-ci: set workflow permissions to read-all