]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
15 months agodecode: refactor L3 checkum handling
Victor Julien [Fri, 5 Apr 2024 11:25:31 +0000 (13:25 +0200)] 
decode: refactor L3 checkum handling

Use a flag to indicate a calculated csum is available.

Allows packet reset to just use memset.

15 months agodecode: use macro's instead of direct ptr checks
Victor Julien [Thu, 28 Mar 2024 08:41:06 +0000 (09:41 +0100)] 
decode: use macro's instead of direct ptr checks

To prepare future changes to the Packet header pointers.

Ticket: #5517.

15 months agodecode/icmpv6: improve packet vars layout
Victor Julien [Wed, 27 Mar 2024 11:17:15 +0000 (12:17 +0100)] 
decode/icmpv6: improve packet vars layout

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/icmpv6: remove unused error_ptr field
Victor Julien [Wed, 27 Mar 2024 11:14:06 +0000 (12:14 +0100)] 
decode/icmpv6: remove unused error_ptr field

Was only set, never checked.

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/icmpv6: remove embedded address storage
Victor Julien [Wed, 27 Mar 2024 11:07:51 +0000 (12:07 +0100)] 
decode/icmpv6: remove embedded address storage

Only used in tests. For the tests, switch to getting headers from embedded IPv6 header.

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/icmpv6: remove unused L4 header pointers from Packet
Victor Julien [Wed, 27 Mar 2024 10:46:48 +0000 (11:46 +0100)] 
decode/icmpv6: remove unused L4 header pointers from Packet

Not used, so no need to keep them.

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/icmpv4: shrink icmpv4 packet vars
Victor Julien [Wed, 27 Mar 2024 10:40:46 +0000 (11:40 +0100)] 
decode/icmpv4: shrink icmpv4 packet vars

Remove unused L4 header pointers.

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/icmpv4: remove unused Packet members
Victor Julien [Wed, 27 Mar 2024 09:56:13 +0000 (10:56 +0100)] 
decode/icmpv4: remove unused Packet members

Addresses are pulled from embedded IPv4 header directly.
Embeded hlen was unused.

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/tcp: remove unused macro
Victor Julien [Thu, 11 Apr 2024 14:24:51 +0000 (16:24 +0200)] 
decode/tcp: remove unused macro

SET_OPTS is now unused, so remove.

15 months agodecode/tcp: reduce size needed for SACK tracking
Victor Julien [Wed, 27 Mar 2024 09:39:26 +0000 (10:39 +0100)] 
decode/tcp: reduce size needed for SACK tracking

No longer use a pointer, but rather an offset.

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/tcp: minor struct layout optimization
Victor Julien [Wed, 27 Mar 2024 08:56:16 +0000 (09:56 +0100)] 
decode/tcp: minor struct layout optimization

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/tcp: reduce size needed for tracking WSCALE
Victor Julien [Wed, 27 Mar 2024 08:43:44 +0000 (09:43 +0100)] 
decode/tcp: reduce size needed for tracking WSCALE

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/tcp: reduce space needed for tracking TFO
Victor Julien [Wed, 27 Mar 2024 08:31:06 +0000 (09:31 +0100)] 
decode/tcp: reduce space needed for tracking TFO

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/tcp: reduce space needed for MSS tracking
Victor Julien [Wed, 27 Mar 2024 08:24:39 +0000 (09:24 +0100)] 
decode/tcp: reduce space needed for MSS tracking

Part of effort to make Packet more compact.

Ticket: #6938.

15 months agodecode/tcp: optimize SACKOK storage
Victor Julien [Wed, 27 Mar 2024 08:15:59 +0000 (09:15 +0100)] 
decode/tcp: optimize SACKOK storage

Take less space in the TCPVars for tracking if SACKOK is set.

Reduces size by 16 bytes.

Ticket: #6938.

15 months agodecode/ipv4: minor test cleanups
Victor Julien [Thu, 28 Mar 2024 08:31:11 +0000 (09:31 +0100)] 
decode/ipv4: minor test cleanups

15 months agodecode/ipv6: prep for turning ip4h/ip6h into union
Victor Julien [Tue, 26 Mar 2024 09:21:57 +0000 (10:21 +0100)] 
decode/ipv6: prep for turning ip4h/ip6h into union

Store IPv6 decoder vars in a new Packet::l3 section in the packet.

Use inline functions instead of the often multi-layer macro's for
various IPv6 header getters.

Ticket: #6938.

15 months agodecode/ipv4: prep for turning ip4h/ip6h into union
Victor Julien [Mon, 25 Mar 2024 08:57:06 +0000 (09:57 +0100)] 
decode/ipv4: prep for turning ip4h/ip6h into union

Store IPv4 decoder vars in a new Packet::l3 section in the packet.

Use inline functions instead of the often multi-layer macro's for
various IPv4 header getters.

Ticket: #6938.

15 months agodecode: minor style cleanup in the header ptrs
Victor Julien [Tue, 26 Mar 2024 09:21:31 +0000 (10:21 +0100)] 
decode: minor style cleanup in the header ptrs

15 months agovalidate: remove ip4h/ip6h check
Victor Julien [Mon, 25 Mar 2024 08:34:25 +0000 (09:34 +0100)] 
validate: remove ip4h/ip6h check

In preparation of making them union members.

15 months agodefrag: track ip hdr offset in tracker
Victor Julien [Sun, 24 Mar 2024 06:21:29 +0000 (07:21 +0100)] 
defrag: track ip hdr offset in tracker

In preparation of future Packet structure changes.

Ticket: #6938.

15 months agodecode: reduce macro use in IPv4/IPv6
Victor Julien [Sat, 23 Mar 2024 07:44:38 +0000 (08:44 +0100)] 
decode: reduce macro use in IPv4/IPv6

Improve readability by setting up data/data_len once before
passing on to the other decoders.

Work in preparation of other decoder changes.

Ticket: #5517.

15 months agoflow: avoid direct IP header checks
Victor Julien [Fri, 22 Mar 2024 12:37:35 +0000 (13:37 +0100)] 
flow: avoid direct IP header checks

To prepare future changes to the Packet header pointers.

Ticket: #5517.

15 months agodecode: reduce PKT_IS_IPV4/PKT_IS_IPV6 use
Victor Julien [Fri, 22 Mar 2024 09:34:31 +0000 (10:34 +0100)] 
decode: reduce PKT_IS_IPV4/PKT_IS_IPV6 use

Replace it with inline functions. Adds inline functions to
wrap PKT_IS_IPV4/PKT_IS_IPV6.

This is in preparation of removing the macro's, and cleaning up the
header pointers.

Ticket: #5517.

15 months agodecode: rename IP_GET_IPPROTO to PacketGetIPProto
Victor Julien [Fri, 22 Mar 2024 08:39:11 +0000 (09:39 +0100)] 
decode: rename IP_GET_IPPROTO to PacketGetIPProto

To match function naming style.

Ticket: #5517.

15 months agodecode: implement IP_GET_IPPROTO as inline func
Victor Julien [Fri, 22 Mar 2024 08:36:51 +0000 (09:36 +0100)] 
decode: implement IP_GET_IPPROTO as inline func

For better readability and type checking.

Ticket: #5517.

15 months agotls/random: fix incorrect direction handling
Shivani Bhardwaj [Fri, 26 Apr 2024 07:29:41 +0000 (12:59 +0530)] 
tls/random: fix incorrect direction handling

The connp objects were incorrectly set per direction leading to
incorrect matches on respective directions.

Bug 6989

15 months agopcap: address codeql warning
Victor Julien [Wed, 24 Apr 2024 07:46:11 +0000 (09:46 +0200)] 
pcap: address codeql warning

Use of potentially dangerous function: localtime

Windows localtime is thread safe and no localtime_r is availabe on
Windows, so use separate logic for Windows.

15 months agorohash: fix codeql warnings
Victor Julien [Wed, 24 Apr 2024 07:40:32 +0000 (09:40 +0200)] 
rohash: fix codeql warnings

Suspicious pointer scaling to void

15 months agorohash: minor code cleanups
Victor Julien [Wed, 24 Apr 2024 07:39:07 +0000 (09:39 +0200)] 
rohash: minor code cleanups

15 months agomisc: remove some unused includes 10952/head
Jason Ish [Wed, 24 Apr 2024 17:57:26 +0000 (11:57 -0600)] 
misc: remove some unused includes

Remove unused includes noticed while updating runmode access.

15 months agorun-mode: remove duplicate var; add setter function
Jason Ish [Wed, 24 Apr 2024 17:25:19 +0000 (11:25 -0600)] 
run-mode: remove duplicate var; add setter function

Remove the global "run_mode" var as it was a duplicate of the runmode on
the "instance" struct. For direct access outside of suricata.c, use the
getter function.

Also expose a setter function for unit tests that need to change it.

15 months agoutil/base64: add more tests to increase coverage
Shivani Bhardwaj [Wed, 24 Apr 2024 07:59:39 +0000 (13:29 +0530)] 
util/base64: add more tests to increase coverage

15 months agoutil/mime: check invalidity after final b64 block
Shivani Bhardwaj [Wed, 24 Apr 2024 07:17:34 +0000 (12:47 +0530)] 
util/mime: check invalidity after final b64 block

Since there is code in place that skips over invalid base64 characters
and creates a new array out of the remainder vector, all test must be
made after that final array has been created and against the variable
that holds the actual length of the final array.

15 months agoutil/mime: skipped chars should be marked consumed
Shivani Bhardwaj [Wed, 24 Apr 2024 07:17:01 +0000 (12:47 +0530)] 
util/mime: skipped chars should be marked consumed

15 months agoutil/base64: use real numbers in test vectors
Shivani Bhardwaj [Fri, 19 Apr 2024 12:08:21 +0000 (17:38 +0530)] 
util/base64: use real numbers in test vectors

15 months agoutil/base64: update tests to correct consumed bytes
Shivani Bhardwaj [Fri, 19 Apr 2024 11:52:03 +0000 (17:22 +0530)] 
util/base64: update tests to correct consumed bytes

Also, don't treat a successful decoding that had invalid characters as
errors. The caller does not treat them as errors so it makes sense to
consider it successful if something was decoded.

Bug 6964

15 months agoutil/base64: use decoder fns per RFC
Shivani Bhardwaj [Fri, 19 Apr 2024 11:47:30 +0000 (17:17 +0530)] 
util/base64: use decoder fns per RFC

instead of the common decoder fn.

Bug 6964

15 months agoutil/base64: add base64 decode fns per RFC
Shivani Bhardwaj [Fri, 19 Apr 2024 11:45:46 +0000 (17:15 +0530)] 
util/base64: add base64 decode fns per RFC

Base64 decoder tried to handle several different cases in one fn
including how the data should be decoded and corresponding consumed and
decoded bytes calculated for RFC 2045 and RFC 4648 which are very
different. This left window for mistakes and edge cases that one mode is
not supposed to take care of while the other can.

Separate the decoder per RFC so as to have each variable their own scope
and playground. This also makes it much easier to debug if there are any
issues in decoding w.r.t. different callers.

This also takes care of some known issues like making sure the consumed
bytes are correctly handled.

Bug 6964

15 months agodoc: add sdp update
Giuseppe Longo [Sat, 16 Mar 2024 15:01:05 +0000 (16:01 +0100)] 
doc: add sdp update

15 months agorust/sip: parse and log sdp
Giuseppe Longo [Sat, 16 Mar 2024 14:36:42 +0000 (15:36 +0100)] 
rust/sip: parse and log sdp

If SDP payload is found within a SIP message, it will be parsed and then
logged.

Ticket #6627

15 months agorust/sdp: implement logger
Giuseppe Longo [Sat, 16 Mar 2024 14:34:50 +0000 (15:34 +0100)] 
rust/sdp: implement logger

This implements a logger for the SDP protocol.
Given that SDP is encapsulated within other protocols (such as SIP),
enabling it separately is not necessary.

Ticket #6627

15 months agorust/sdp: implement protocol parser
Giuseppe Longo [Sat, 16 Mar 2024 14:34:21 +0000 (15:34 +0100)] 
rust/sdp: implement protocol parser

This implements a parser for the SDP protocol.
Given that SDP is encapsulated within other protocols (such as SIP),
enabling it separately is not necessary.

Ticket #6627.

15 months agoapp-layer: remove unused C wrappers 10947/head
Philippe Antoine [Sun, 21 Apr 2024 21:40:34 +0000 (23:40 +0200)] 
app-layer: remove unused C wrappers

Ticket: 4083

15 months agogithub-ci: update fedora builds 10934/head
Jason Ish [Tue, 23 Apr 2024 14:52:35 +0000 (08:52 -0600)] 
github-ci: update fedora builds

f39 -> f40
f38 -> f39

15 months agodetect/parse: set limits for pcre2
Philippe Antoine [Sun, 24 Mar 2024 20:12:15 +0000 (21:12 +0100)] 
detect/parse: set limits for pcre2

Ticket: 6889

To avoid regexp dos with too much backtracking.
This is already done on pcre keyword, and pcrexform transform.
We use the same default limits for rules parsing.

15 months agohttp2: do not log duplicate headers
Philippe Antoine [Thu, 28 Mar 2024 10:15:51 +0000 (11:15 +0100)] 
http2: do not log duplicate headers

Ticket: 6900

And thus avoid DOS by logging a request using a compressed
header block repeated many times and having a long value...

15 months agohttp2: use a reference counter for headers
Philippe Antoine [Wed, 27 Mar 2024 13:33:54 +0000 (14:33 +0100)] 
http2: use a reference counter for headers

Ticket: 6892

As HTTP hpack header compression allows one single byte to
express a previously seen arbitrary-size header block (name+value)
we should avoid to copy the vectors data, but just point
to the same data, while reamining memory safe, even in the case
of later headers eviction from the dybnamic table.

Rust std solution is Rc, and the use of clone, so long as the
data is accessed by only one thread.

15 months agoutil/base64: fix buffer overflow
Philippe Antoine [Thu, 28 Mar 2024 13:00:02 +0000 (14:00 +0100)] 
util/base64: fix buffer overflow

Ticket: 6902

In case the caller of DecodeBase64 does not supply a big enough
output buffer.

15 months agodefrag: fix check for complete packet
Jason Ish [Fri, 12 Jan 2024 17:09:59 +0000 (11:09 -0600)] 
defrag: fix check for complete packet

The list of fragments may still contain overlaps, so adding up the
fragment lengths is flawed. Instead track the largest size of
contiguous data that can be re-assembled.

Bug: #6675

15 months agodefrag: fix subsequent overlap of start of original (bsd)
Jason Ish [Thu, 7 Dec 2023 22:44:56 +0000 (16:44 -0600)] 
defrag: fix subsequent overlap of start of original (bsd)

Fix the BSD policy case where a subsequent fragment starts before an
original fragment and overlaps the beginning of the original
fragment. In this case the overlapping data from the new fragment is
preferred.

Suricata was preferring the data from the original fragment, but it
should only do that when the original fragment has an offset <= to the
new fragment.

- Adds tests for this case.

Bug: #6669

15 months agodefrag: check next fragment for overlap before stopping re-assembly
Jason Ish [Tue, 28 Nov 2023 18:35:26 +0000 (12:35 -0600)] 
defrag: check next fragment for overlap before stopping re-assembly

Instead of breaking the loop when the current fragment does not have
any more fragments, set a flag and continue to the next fragment as
the next fragment may have data that occurs before this fragment, but
overlaps it.

Then break if the next fragment does not overlap the previous.

Bug: #6668

15 months agodefrag: use uint8_t in unit tests
Jason Ish [Fri, 12 Jan 2024 15:26:22 +0000 (09:26 -0600)] 
defrag: use uint8_t in unit tests

15 months agodefrag: consistent unit test naming
Jason Ish [Mon, 27 Nov 2023 22:27:27 +0000 (16:27 -0600)] 
defrag: consistent unit test naming

Use a more consistent naming scheme between ipv4 and ipv6.

15 months agodefrag: make tests more readable
Jason Ish [Mon, 27 Nov 2023 21:59:23 +0000 (15:59 -0600)] 
defrag: make tests more readable

Make tests more readable for comparing to the paper "Target-Based
Fragmentation Reassembly".

15 months agodefrag: minor cleanups
Jason Ish [Fri, 8 Dec 2023 22:27:12 +0000 (16:27 -0600)] 
defrag: minor cleanups

- typo in comment
- remove debug function that is not used and no longer valid

15 months agodpdk: increase timeout for DPDK test runs 10921/head
Lukas Sismis [Thu, 18 Apr 2024 07:24:50 +0000 (09:24 +0200)] 
dpdk: increase timeout for DPDK test runs

15 months agoutil/mime: adds safety check
Philippe Antoine [Thu, 18 Apr 2024 11:36:34 +0000 (13:36 +0200)] 
util/mime: adds safety check

Ticket: 6904

Even if there is no problem, just fortify the function,
so that it is future-proof if the caller does not do the check.

15 months agodetect: use direction-based tx for app-layer logging
Philippe Antoine [Thu, 18 Apr 2024 09:54:34 +0000 (11:54 +0200)] 
detect: use direction-based tx for app-layer logging

When we only have stream matches.

Ticket: 6846

This solves the case where another transaction was created
by parsing data in the other direction, before running the
detection.

Like
1. get data in direction 1
2. acked data: parse it, but do not run detection in dir 1
3. other data in direction 2
4. other data acked : parse it and create new tx,
then run detection for direction 1 with data from first packet

15 months agomime: validate that chunk size stays within limit
Victor Julien [Thu, 28 Mar 2024 14:47:06 +0000 (15:47 +0100)] 
mime: validate that chunk size stays within limit

15 months agosmtp: minor debug cleanup
Victor Julien [Thu, 28 Mar 2024 14:46:34 +0000 (15:46 +0100)] 
smtp: minor debug cleanup

15 months agostreaming/buffer: add validation checks for data chunk sizes
Victor Julien [Thu, 28 Mar 2024 14:12:02 +0000 (15:12 +0100)] 
streaming/buffer: add validation checks for data chunk sizes

15 months agoutil/file: add validation check for extreme data chunk sizes
Victor Julien [Thu, 28 Mar 2024 14:09:31 +0000 (15:09 +0100)] 
util/file: add validation check for extreme data chunk sizes

15 months agostreaming/buffer: improve integer handling safety
Victor Julien [Thu, 28 Mar 2024 12:46:23 +0000 (13:46 +0100)] 
streaming/buffer: improve integer handling safety

Unsafe handling of buffer offset and to be inserted data's length
could lead to a integer overflow. This in turn would skip growing
the target buffer, which then would be memcpy'd into, leading to
an out of bounds write.

This issue shouldn't be reachable through any of the consumers of
the API, but to be sure some debug validation checks have been
added.

Bug: #6903.

15 months agodetect/http-server-body: avoid FP on toserver direction
Philippe Antoine [Wed, 17 Apr 2024 11:39:39 +0000 (13:39 +0200)] 
detect/http-server-body: avoid FP on toserver direction

Ticket: 6948

http.response_body keyword did not enforce a direction, and thus
could match on files sent with POST requests

15 months agoips: check for livedev.use-for-tracking
Victor Julien [Tue, 16 Apr 2024 13:07:46 +0000 (15:07 +0200)] 
ips: check for livedev.use-for-tracking

For the capture methods that support livedev and IPS,
livedev.use-for-tracking is not supported.

This setting causes major flow tracking issues, as both sides of
a flow would be tracked in different flows.

This patch disables the livedev.use-for-tracking setting if it
is set to true. A warning will be issued.

Ticket: #6726.

15 months agocapture: block IDS + IPS combination
Victor Julien [Tue, 16 Apr 2024 16:55:32 +0000 (18:55 +0200)] 
capture: block IDS + IPS combination

In general, improve IPS setup error checking.

Ticket: #5588.

15 months agocapture: improve IDS + IPS check
Victor Julien [Tue, 16 Apr 2024 13:38:13 +0000 (15:38 +0200)] 
capture: improve IDS + IPS check

Improve it for af-packet, dpdk, netmap. Check would not consider
an interface IDS if the `default` section contained a copy-mode
field.

15 months agoyaml: unify 0 stats counter config option terms
Juliana Fajardini [Wed, 17 Apr 2024 00:29:51 +0000 (21:29 -0300)] 
yaml: unify 0 stats counter config option terms

When we added feature #5976 (72146b969), we overlook that we also have
a config stats option for the human-readable stats logs to output
0 counters.
Due to not seeing this before, we now have two different setting names
for basically the same thing, but in different logs:
- zero-valued-counters for EVE
- null-values for stats.log

This ensures we use the same terminology, and change the recently added
one to `null-values`, as this one has been around for longer.

Task #6962

15 months agoyaml/eve/stats: remove mention exception policy
Juliana Fajardini [Tue, 16 Apr 2024 21:31:47 +0000 (18:31 -0300)] 
yaml/eve/stats: remove mention exception policy

The stats config for EVE logs have a comment about exception policy
stats counters. This went in with 72146b969c06fb953, but shouldn't have,
as there are no options there.

15 months agooutput/alert: check flag before logging app-layer 10887/head
Philippe Antoine [Wed, 13 Mar 2024 20:26:05 +0000 (21:26 +0100)] 
output/alert: check flag before logging app-layer

Ticket: 6846

15 months agooutput: do not use tx id 0 when there is no tx
Philippe Antoine [Mon, 11 Mar 2024 13:06:50 +0000 (14:06 +0100)] 
output: do not use tx id 0 when there is no tx

Ticket: 6846

This led to packet rules logging irrelevant app-layer data

15 months agodetect/ipopts: Handle multiple ip options
Jeff Lucovsky [Tue, 16 Apr 2024 12:34:42 +0000 (08:34 -0400)] 
detect/ipopts: Handle multiple ip options

Issue: 6864

Multiple IP options were not handled properly as the value being OR'd
into the packet's ip option variable were enum values instead of bit
values.

15 months agodetect/ipopts: Remove unneeded PCRE logic
Jeff Lucovsky [Thu, 21 Mar 2024 13:37:26 +0000 (09:37 -0400)] 
detect/ipopts: Remove unneeded PCRE logic

Issue: 6864

Reduce complexity by eliminating the PCRE logic and adding a unittest to
validate null/empty string handling

15 months agodetect/ipopt: Misc. cleanup
Jeff Lucovsky [Thu, 21 Mar 2024 13:38:57 +0000 (09:38 -0400)] 
detect/ipopt: Misc. cleanup

Minor changes to improve readability, remove extraneous include files.

15 months agowebsocket: configurable logging of payload in alerts 10873/head
Philippe Antoine [Sat, 6 Jan 2024 22:09:05 +0000 (23:09 +0100)] 
websocket: configurable logging of payload in alerts

15 months agoapp-layer: websockets protocol support
Philippe Antoine [Fri, 22 Dec 2023 11:01:33 +0000 (12:01 +0100)] 
app-layer: websockets protocol support

Ticket: 2695

15 months agoprotodetect: run expected probing parser
Philippe Antoine [Sat, 30 Dec 2023 20:36:07 +0000 (21:36 +0100)] 
protodetect: run expected probing parser

When there is a protocol change, and a specific protocol is
expected, like WebSeocket, always run it, no matter the port.

15 months agoprotodetect: allows not port-based probing parsers
Philippe Antoine [Sat, 30 Dec 2023 20:28:50 +0000 (21:28 +0100)] 
protodetect: allows not port-based probing parsers

As for WebSocket which is detected only by protocol change.

15 months agoprotodetect: remove unused field
Philippe Antoine [Sat, 30 Dec 2023 20:21:21 +0000 (21:21 +0100)] 
protodetect: remove unused field

port is used in AppLayerProtoDetectProbingParserPort
and not in AppLayerProtoDetectProbingParserElement

15 months agohttp2: add settings from newer RFCs
Philippe Antoine [Fri, 22 Dec 2023 14:51:33 +0000 (15:51 +0100)] 
http2: add settings from newer RFCs

Including the one for websocket over HTTP/2

15 months agoenip: register on default 44818/tcp port
Philippe Antoine [Fri, 22 Dec 2023 09:05:17 +0000 (10:05 +0100)] 
enip: register on default 44818/tcp port

if no config option is found,
as is done for udp

Ticket: 6304

15 months agoconf: avoid quadratic complexity 10865/head
Philippe Antoine [Thu, 21 Mar 2024 08:38:25 +0000 (09:38 +0100)] 
conf: avoid quadratic complexity

Ticket: 6878

Follow up on 15649424a76d01eb332d85620ffc4956d4f3d9be

When adding many sequence nodes, either from start or scalar event

We add "sequence nodes" whose name is an integer cf sequence_node_name
and then run ConfNodeLookupChild to see if it had been already set
(from the command line cf comment in the code)
And ConfNodeLookupChild iterates the whole linked list...

1. We add node 1
2. To add node 2, we check if node 1 equals this new node
3. To add node 3, we check if nodes 1, or 2 equals this new node's name
And so on...

This commits avoids these checks ig the list is empty at the beginning

15 months agodataset: cleanup datasets that hit the memcap while loading
Andreas Herz [Tue, 16 Apr 2024 15:22:20 +0000 (17:22 +0200)] 
dataset: cleanup datasets that hit the memcap while loading

Datasets that hit the memcap limit need to be discarded if the memcap is
hit or otherwise the datasets are still loaded with partial data while
the signature is not loaded due to the memcap error.

Ticket: #6678

15 months agodecode/ppp: fix iplen check int handling
Victor Julien [Tue, 16 Apr 2024 06:26:40 +0000 (08:26 +0200)] 
decode/ppp: fix iplen check int handling

** CID 1596376:    (CONSTANT_EXPRESSION_RESULT)
/src/decode-ppp.c: 64 in DecodePPPCompressedProto()
/src/decode-ppp.c: 55 in DecodePPPCompressedProto()

________________________________________________________________________________________________________
*** CID 1596376:    (CONSTANT_EXPRESSION_RESULT)
/src/decode-ppp.c: 64 in DecodePPPCompressedProto()
58             case 0x57: { /* PPP_IPV6 */
59                 if (unlikely(len < (data_offset + IPV6_HEADER_LEN))) {
60                     ENGINE_SET_INVALID_EVENT(p, PPPIPV6_PKT_TOO_SMALL);
61                     return TM_ECODE_FAILED;
62                 }
63                 DEBUG_VALIDATE_BUG_ON(len < data_offset);
>>>     CID 1596376:    (CONSTANT_EXPRESSION_RESULT)
>>>     "65535 /* 32767 * 2 + 1 */ < (uint16_t)(len - data_offset)" is always false regardless of the values of its operands. This occurs as the logical first operand of "?:".
64                 uint16_t iplen = MIN(USHRT_MAX, (uint16_t)(len - data_offset));
65                 return DecodeIPV6(tv, dtv, p, pkt + data_offset, iplen);
66             }
67             case 0x2f: /* PPP_VJ_UCOMP */
68                 if (unlikely(len < (data_offset + IPV4_HEADER_LEN))) {
69                     ENGINE_SET_INVALID_EVENT(p, PPPVJU_PKT_TOO_SMALL);
/src/decode-ppp.c: 55 in DecodePPPCompressedProto()
49             case 0x21: { /* PPP_IP */
50                 if (unlikely(len < (data_offset + IPV4_HEADER_LEN))) {
51                     ENGINE_SET_INVALID_EVENT(p, PPPVJU_PKT_TOO_SMALL);
52                     return TM_ECODE_FAILED;
53                 }
54                 DEBUG_VALIDATE_BUG_ON(len < data_offset);
>>>     CID 1596376:    (CONSTANT_EXPRESSION_RESULT)
>>>     "65535 /* 32767 * 2 + 1 */ < (uint16_t)(len - data_offset)" is always false regardless of the values of its operands. This occurs as the logical first operand of "?:".
55                 uint16_t iplen = MIN(USHRT_MAX, (uint16_t)(len - data_offset));
56                 return DecodeIPV4(tv, dtv, p, pkt + data_offset, iplen);
57             }
58             case 0x57: { /* PPP_IPV6 */
59                 if (unlikely(len < (data_offset + IPV6_HEADER_LEN))) {
60                     ENGINE_SET_INVALID_EVENT(p, PPPIPV6_PKT_TOO_SMALL);

15 months agopgsql: check for eol when parsing response 10856/head
Juliana Fajardini [Sat, 13 Apr 2024 02:12:03 +0000 (23:12 -0300)] 
pgsql: check for eol when parsing response

It was brought to my attention by GLongo that Pgsql parser handled eof
diffrently for requests and responses, and apparently there isn't a good
reason for such a difference therefore, apply same logic used for
rs_pgsql_parse_request for checking for eof when parsing a response.

15 months agoeve/alert: add missing pgsql metadata
Juliana Fajardini [Sat, 13 Apr 2024 02:10:48 +0000 (23:10 -0300)] 
eve/alert: add missing pgsql metadata

Bug #6092

15 months agoja4: implement for TLS and QUIC
Sascha Steinbiss [Sat, 24 Feb 2024 10:10:47 +0000 (11:10 +0100)] 
ja4: implement for TLS and QUIC

Ticket: OISF#6379

15 months agoja3: make feature compile time configurable
Sascha Steinbiss [Fri, 12 Apr 2024 17:54:23 +0000 (19:54 +0200)] 
ja3: make feature compile time configurable

15 months agosuricata: initialize feature tracking earlier
Sascha Steinbiss [Sat, 24 Feb 2024 09:34:50 +0000 (10:34 +0100)] 
suricata: initialize feature tracking earlier

This gives app layer code a chance to access feature
information.

15 months agoflow/inject: Select thread_id by flow flag 10852/head
Jeff Lucovsky [Mon, 15 Apr 2024 14:17:17 +0000 (10:17 -0400)] 
flow/inject: Select thread_id by flow flag

Issue: 6957

Rather than selecting the thread_id index by packets traveling to the
server, use the flow flags. If the flow has been reversed, the second
slot is represents the thread id to be used.

15 months agodecode/ppp: add missing types definitions
Victor Julien [Mon, 15 Apr 2024 10:29:12 +0000 (12:29 +0200)] 
decode/ppp: add missing types definitions

Recognize PPP_CCP, PPP_CBCP and PPP_COMP_DGRAM.

Does not implement decoders for these record types, so these
are logged as unsupported types. Was "wrong_type" before.

15 months agodecode/ppp: clean up ppph pointer use
Victor Julien [Fri, 12 Apr 2024 13:26:46 +0000 (15:26 +0200)] 
decode/ppp: clean up ppph pointer use

No users of the pointer anymore, so remove it.

15 months agodecode/ppp: remove ppph check in favor of flag
Victor Julien [Fri, 12 Apr 2024 13:19:45 +0000 (15:19 +0200)] 
decode/ppp: remove ppph check in favor of flag

As we now support variable size headers, we can't use the old pointer.

Replace with a flag.

15 months agodecode/ppp: support different header formats
Victor Julien [Fri, 12 Apr 2024 10:42:37 +0000 (12:42 +0200)] 
decode/ppp: support different header formats

Support compressed proto and optional HDLC header.

Bug: #6942.

15 months agodetect/analyzer: add more details for tcp_mss 10841/head
Philippe Antoine [Sun, 14 Apr 2024 19:36:17 +0000 (21:36 +0200)] 
detect/analyzer: add more details for tcp_mss

Issue: #6355

15 months agodetect/analyzer: create tojson function for generic integers
Philippe Antoine [Sun, 14 Apr 2024 19:34:57 +0000 (21:34 +0200)] 
detect/analyzer: create tojson function for generic integers

As will be needed for tcp.mss

16 months agoutil: remove unused bloom filter code 10832/head
Philippe Antoine [Fri, 12 Apr 2024 15:14:01 +0000 (17:14 +0200)] 
util: remove unused bloom filter code

Ticket: 4083

16 months agosrc: remove unused headers-exported functions
Philippe Antoine [Tue, 16 May 2023 09:15:10 +0000 (11:15 +0200)] 
src: remove unused headers-exported functions

+ remove double definition of IPPairLock

Ticket: #4083

16 months agostats: Memcap pressure max relocation
Jeff Lucovsky [Sun, 24 Mar 2024 12:22:34 +0000 (08:22 -0400)] 
stats: Memcap pressure max relocation

This commit moves the memcap pressure/pressure_max stats from the global
stats namespace into the memcap namespace.

With per-thread stats, they will be within the flow-manager's values.

Issue: 6398