Commit Graph

15414 Commits (suricata-7.0.7)
 

Author SHA1 Message Date
Shivani Bhardwaj 572a16fb5a release: 7.0.7; update changelog 10 months ago
Ilya Bakhtin f8f65de937 detect: pseudo-packets inherit inspect flags from parent packet
Instead of inheriting from flow, because encrypted protocols like TLS
and SSH may have just set the flow flags to indicate rest of stream is
encrypted and does not need to run stream inspection. But inspection
still needs to be run detection on this last flushing packet.

Ticket: #7235.
(cherry picked from commit 976dec7f33)
10 months ago
Sascha Steinbiss 38bb31e5f6 tls: do not break custom fields when enabling JA4
Ticket: 7286
10 months ago
Philippe Antoine db5a7a2feb util/hash: use randomized hash algorithm
For datasets and http ranges

Ticket: 7209

Prevents abusive hash collisions from known djb2 algorithm

(cherry picked from commit 26da953f6d)
10 months ago
Philippe Antoine ca8bf6e64c http: have a headers limit
Ticket: 7191

So as to avoid quadratic complexity in libhtp.
Make the limit configurable from suricata.yaml,
and have an event when network traffic goes over the limit.

(cherry picked from commit bb714c9178)
10 months ago
Philippe Antoine 34a4625156 ja4: handles non alphanumeric alpn
Ticket: 7267

Follows more closely the specification :
https://github.com/FoxIO-LLC/ja4/blob/main/technical_details/JA4.md#alpn-extension-value

Also fixes the case with a single-char alpn.

(cherry picked from commit 1e152d1f10)
10 months ago
Philippe Antoine c9649bb920 defrag: fix off by one
Ticket: 7067

This off by one could lead to an empty fragment being inserted
in the rb tree, which led to integer underflow

(cherry picked from commit 9203656496)
10 months ago
Philippe Antoine b5eb0c9101 detect/dataset: abort only in debug mode
Ticket: 7195
(cherry picked from commit c55c7d6c27)
10 months ago
Philippe Antoine 72456d359b detect/datasets: implement unset command
Ticket: 7195

Otherwise, Suricata aborted on such a rule

(cherry picked from commit e47598110a)
10 months ago
Philippe Antoine 96d5c81aed datasets: restrict scope of macro/enum
(cherry picked from commit 1352ed68c7)
10 months ago
Victor Julien 4f59fd94a6 stream: improve 3whs completed by ACK with data
If the ACK packet completing the 3whs is received, the stream engine will
transition to "established". However, the packet itself will not be tagged
as "established". This will only happen for the next packet after the 3whs,
so that `flow:established` only matches after the 3whs.

It is possible that the ACK packet completing the 3whs was lost. Since the
ACK packets themselves are not acknowledged, there will be no retransmission
of them. Instead, the next packet can have the expected ACK flag as well as
data.

This case was mishandled in a subtle way. The stream engine state transition
was done correctly, as well as the data handling and app-layer updates.
However, the packet itself was not tagged as "established", which meant
that `flow:established` would not yet match.

This patch detects this case and tags the packet as established if ACK
with data is received that completes the 3whs.

Bug: #7264.
(cherry picked from commit 45eb7e4881)
10 months ago
Philippe Antoine 04ef7b6174 ssl/ja3: better check for ja3 being enabled
Ticket: 6634

Completes commit 84735251b5

Avoids error log in Ja3BufferAddValue about NULL buffer

(cherry picked from commit 1d32f11745)
10 months ago
Juliana Fajardini 1fbe985177 pgsql: trigger raw stream reassembly at tx completion
Once we are tracking tx progress per-direction for PGSQL, we can trigger
the raw stream reassembly, for detection purposes, as soon as the
transactions are completed in the given direction.

Task #7000

(cherry picked from commit 2b1ad81cf5)
10 months ago
Juliana Fajardini 5034ae5e44 pgsql: track transaction progress per direction
PGSQL's current implementation tracks the transaction progress without
taking into consideration flow direction, and also has indirections
that make it harder to understand how the progress is tracked, as well
as when a request or response is actually complete.

This patch introduces tracking such progress per direction and adds
completion status per direction, too. This will help when triggering
raw stream reassembly or for unidirectional transactions, and may be
useful when we implement sub-protocols that can have multiple requests
per transaction, as well.

CancelRequests and TerminationRequests are examples of unidirectional
transactions. There won't be any responses to those requests, so we can
also mark the response side as done, and set their transactions as
completed.

Bug #7113

(cherry picked from commit dcccbb1196)
10 months ago
Juliana Fajardini 629b5d7298 pgsql: use new API style for extern C functions
(cherry picked from commit 2c7824a41f)
10 months ago
Juliana Fajardini add17d15c6 pgsql: order StateProgress enum per direction
Related to
Bug #7113

(cherry picked from commit 3ba179422d)
10 months ago
Victor Julien 19006560a1 dcerpc: don't reuse completed tx
In the DCERPC over TCP pcap, logging and rule matching is disrupted by adding a simple rule:

        alert tcp any any -> any any (flow:to_server,established; \
                dce_iface:5d2b62aa-ee0a-4a95-91ae-b064fdb471fc; dce_opnum:1; \
                dce_stub_data; content:"|42 77 4E 6F 64 65 49 50 2E 65 78 65 20|"; \
                content:!"|00|"; within:100; distance:97; sid:1; rev:1; )

Works: alert + 3 dcerpc records.

But when adding a trivial rule:

        alert tcp any any -> any any (flow:to_server,established; \
                dce_iface:5d2b62aa-ee0a-4a95-91ae-b064fdb471fc; dce_opnum:1; \
                dce_stub_data; content:"|42 77 4E 6F 64 65 49 50 2E 65 78 65 20|"; \
                content:!"|00|"; within:100; distance:97; sid:1; rev:1; )
        alert tcp any any -> any any (dsize:3; sid:2; rev:1; )

The alert for sid:1 disappears and also there is one dcerpc event less.

In the single rule case we can aggressively free the transactions, as there
is only an sgh in the toserver direction.

This means that when we encounter the 2nd REQUEST, the first 2 transactions
have already been processed and freed. So for the 2nd REQUEST we open a new
TX and run inspection and logging on it.

When the 2nd rule is added, it adds toclient sgh as well. This means that we
will now slightly delay the freeing of the transactions.

As a consequence we still have the TX for the first REQUEST when the 2nd REQUEST
is parsed. This leads to the 2nd REQUEST re-using the TX. Since the TX is
already marked as inspected, it means the toserver rule now no longer matches.
Also we're not logging this TX correctly now.

This commit fixes the issue by not "finding" a TX that as already been
marked complete in the search direction.

Bug #7187.

(cherry picked from commit 65392c02f5)
10 months ago
Victor Julien b5851d2d14 eve/alert: fix validation check
Bug: #6875.
(cherry picked from commit 0be3ba802e)
10 months ago
Victor Julien d8c1975da9 membuffer: annotate printf style function
(cherry picked from commit ff8597d50b)
10 months ago
Victor Julien b041ab4383 eve/alert: break out of payload logging callback if buffer is full
(cherry picked from commit 926c6e3add)
10 months ago
Victor Julien f37ded702c eve/frame: break out of logging callback if buffer is full
(cherry picked from commit 1dea4fea0b)
10 months ago
Victor Julien 9670c3016b membuffer: return bytes written
(cherry picked from commit 7d5b537f5c)
10 months ago
Victor Julien 376c4b8a2b membuffer: use buffer pointer as flexible array member
(cherry picked from commit 9c3669b03f)

An additional change was made to correct an ASAN issue -- the membuffer
is reset following allocation in MemBufferCreateNew().
10 months ago
Victor Julien e1e3f5b1b8 membuffer: turn complex macros into functions
For better readability and type checking.

(cherry picked from commit 3ef98f2b87)
10 months ago
Victor Julien 0bc6fa2fbf unix-manager: add \n string to buffer using correct API call
(cherry picked from commit ea98df8da2)
10 months ago
Victor Julien 45cb6882e9 eve/frame: improve frame payload logging
Log using stream callback API, meaning that data will also
be logged if there are GAPs.

Also implement GAP indicators: '[123 bytes missing]'.

(cherry picked from commit 6e10c66078)
10 months ago
Victor Julien ffdecd801a eve/frames: pass membuffer to API
In preparation of stream logging changes.

(cherry picked from commit a205583269)
10 months ago
Victor Julien 5e501e2591 eve/alert: init membuffer size on missing config
Don't init buffer to 0 size but use the desired default of 4k.

(cherry picked from commit 462a6d7913)
10 months ago
Victor Julien 410ff80c34 eve/alert: log payload directly from stream buffer
This avoids looping over partly duplicate segments that cause
output data corruption by logging parts of the stream data multiple
times.

For data with GAPs now add a indicator '[4 bytes missing]' similar
to how Wireshark does it.

Bug: #6553.
(cherry picked from commit 43858f70ad)
10 months ago
Victor Julien 8bab8f9027 eve/frame: implement payload-buffer-size option
Modeled after the same option in eve/alert. Defaults to 4k.

(cherry picked from commit 829bab295b)
10 months ago
Victor Julien a7dc1aa733 stream: const args for StreamReassembleLog
Needed a workaround cast for RBTREE use.

(cherry picked from commit a5a6527d26)
10 months ago
Philippe Antoine 6a8d29c69e ci: mov from cifuzz to clusterfuzzlite
To better support main7 CI fuzzing

Ticket: 7253
(cherry picked from commit b3bd57246f)
10 months ago
Philippe Antoine 50ee5e09c7 frames: do not only rely on FRAME_STREAM_ID
As stream frame is not always created,
hence the first frame is not always a stream frame :
If stream frame is not enabled, it does not get created,
and other enabled frames may be created first.
See use of FrameConfigTypeIsEnabled

This resulted that this other frame got its length updated
on stream end, which led to false positives.

Also checking FRAME_STREAM_TYPE is more consistent.

Not a clean cherry-pick as AppLayerFrameGetLastOpenByType
does not exist in main7

Ticket: 7213
10 months ago
Philippe Antoine 9571df8936 rust/detect: fix too_long_first_doc_paragraph clippy warning
warning: first doc comment paragraph is too long
  --> src/detect/iprep.rs:57:1
   |
57 | / /// value matching is done use `DetectUintData` logic.
58 | | /// isset matching is done using special `DetectUintData` value ">= 0"
59 | | /// isnotset matching bypasses `DetectUintData` and is handled directly
60 | | /// in the match function (in C).
   | |_
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
   = note: `#[warn(clippy::too_long_first_doc_paragraph)]` on by default
help: add an empty line

(cherry picked from commit dc3c048b49)
10 months ago
Philippe Antoine d3927afb70 rust/dcerpc: fix single_match clippy warning
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
  --> src/dcerpc/log.rs:36:33
   |
36 |               DCERPC_TYPE_BIND => match &state.bind {
   |  _________________________________^
37 | |                 Some(bind) => {
38 | |                     jsb.open_array("interfaces")?;
39 | |                     for uuid in &bind.uuid_list {
...  |
51 | |                 None => {}
52 | |             },
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
   = note: `#[warn(clippy::single_match)]` on by default

(cherry picked from commit 2a984e3b13)
10 months ago
Victor Julien c6aeec10b5 detect/app-layer-proto: fix prefilter check
Prefilter wasn't yet using `AppProtoEquals` which might lead to
mismatches with HTTP and DCERPC related signatures.
11 months ago
Victor Julien 9d922af7c1 detect/app-layer-proto: don't run detection on ALPROTO_UNKNOWN
Don't return true for negated protocol check if no protocol has been
evaluated due to ALPROTO_UNKNOWN in the packet direction.

This leads to false positives for negated matching, as an expression
like "!tls" will match if checked against ALPROTO_UNKNOWN.

This patch readds missing check. The keyword returns no match as
long as the alproto is ALPROTO_UNKNOWN.

Fixes: bf9bbdd612 ("detect: fix app-layer-protocol keyword for HTTP")

Ticket: #7242.
11 months ago
Philippe Antoine 98fd40a4b3 tls/ja3: do not append to ja3 str once ja3 hash is computed
Ticket: 6634

That means take only the first client hello into account.
This way, we do not end with ja3 string with 9 commas...

(cherry picked from commit 84735251b5)
11 months ago
Philippe Antoine ded2082416 rust/ike: fix collapsible_match clippy warning
warning: this `match` can be collapsed into the outer `match`
help: the outer pattern can be modified to include the inner pattern
(cherry picked from commit 42e5e556e5)
11 months ago
Philippe Antoine bc1b906a7b rust: fix byte_char_slices clippy warnings
warning: can be more succinctly written as a byte str
   --> src/mime/smtp.rs:762:37
    |
762 |     mime_smtp_find_url_strings(ctx, &[b'\n']);
    |                                     ^^^^^^^^ help: try: `b"\n"`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#byte_char_slices
    = note: `#[warn(clippy::byte_char_slices)]` on by default

(cherry picked from commit 564f685eea)
11 months ago
Sascha Steinbiss dc8cda6887 userguide: fix spelling of `security_result` EVE field
This ensures that the correct spelling of the `security_result` EVE
field for RFB (as opposed to `security-result`) is also reflected in the
documentation.

Ticket: #7210
(cherry picked from commit cb14e44780)
11 months ago
Sascha Steinbiss 8c8abbf7fa rust/rfb: use consistent key name for security_result
A typo caused a slightly different key (`security-result`) to be used
for the case in which the result was `FAIL`. This commit addresses this
by ensuring the same string is used for all cases.

Ticket: #7198
11 months ago
Eric Leblond 0f3a37acaa datasets: fix parsing of ip4 in ip6
The lookup function was not taking into account that we can have
an IPv4 or an IPv6 address as parameters and that this addresses
need to be converted to Suricata internal storage.
By using the already defined dedicated parsing function, we are
fixing the issue.

Issue: #6969
(cherry picked from commit 4668c95513)
11 months ago
Juliana Fajardini 37ec6251e9 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.

(cherry picked from commit ce1556cefd)
11 months ago
Juliana Fajardini 1c483c9d65 output/json: add pgsql metadata logging to alerts
Bug #6092

Related to
Bug #6983
11 months ago
Juliana Fajardini f5cc23464b pgsql/logger: open json object from logger function
Before, the JsonBuilder object for the pgsql event was being created
from the C-side function that actually called the Rust logger.

This resulted that if another module - such as the Json Alert called the
PGSQL logger, we wouldn't have the `pgsql` key present in the log output
- only its inner fields.

Bug #6983

(cherry picked from commit 69e26de197)
11 months ago
Victor Julien 32c8a7614d doc/userguide: update guidance on 5 to 6 upgrading
TCP memory use can be higher than expected in certain configs.

Ticket: #6552.
(cherry picked from commit 3456dea276)
11 months ago
Victor Julien 107cd77ecb tcp: fix 'broken ack' on flow timeout
Don't set an ACK value if ACK flag is no longer set. This avoids a bogus
`pkt_broken_ack` event set.

Fixes: ebf465a11b ("tcp: do not assign TCP flags to pseudopackets")

Ticket: #7158.
(cherry picked from commit a404fd26af)
11 months ago
Philippe Antoine 7b547c7cd6 detect/nfs: do not free a null pointer
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=69840
(cherry picked from commit b34d4b1314)
11 months ago
Jason Ish 03844b4291 eve/dns: make version required
The "eve.version" field is not always logged. Update the schema to
enforce that it is, and fix it for records that don't log it.

Ticket: #7167
(cherry picked from commit fcc1b1067b)
11 months ago