Commit Graph

18074 Commits (f53a5d3b7a086fe4c11c193d0feb0da4a280acb8)
 

Author SHA1 Message Date
Philippe Antoine f53a5d3b7a websocket: check pdu opcode for reassembly
Ticket: 8413

RFC 6455 Section 5.4 states

Control frames (see Section 5.5) MAY be injected in the middle of
a fragmented message.

Control frames are identified by opcodes where the most significant
bit of the opcode is 1.

(cherry picked from commit 2fa10052cf)
3 weeks ago
Philippe Antoine c479a804d1 http2: set response_frame_size
Ticket: 8410

Do not set only request_frame_size whatever the direction

(cherry picked from commit 7b0528d85f)
3 weeks ago
Jason Ish 995ad5dc4e examples: fix run mode name in live example
Ticket: #8439
3 weeks ago
Jason Ish adbf372bdd log-cf-common: let mktime determine proper tz
In some timezones, LogCustomFormatTest01 was failing as we were
specifying the wrong setting for is_dst. Instead set it to -1 so mktime
can make the decision based on the environment. Appears to fix this test
for "Brazil/East" in the summer.

Add GitHub CI tests to test this specific test with a few different
timezones.

(cherry picked from commit 468a13e052)
3 weeks ago
Juliana Fajardini 1ce945e230 configure/qa-simulation: explicitly declare default
This is needed to generate the `--build-info` report.

Related to
Ticket #7885

(cherry picked from commit 41834f0a05)
3 weeks ago
Philippe Antoine 831be60a57 dcerpc: only log the tx interfaces
Not all the state ones

Ticket: 8378
(cherry picked from commit 34ed8958a6)
4 weeks ago
Philippe Antoine 691114e95c dcerpc: store persistently contexts
So that we can log and detect on interface uuids, even if
AlterContext packets change one of the contexts, but other contexts
are still used after it in request/responses

Ticket: 8378
(cherry picked from commit 05a11e2897)
4 weeks ago
Philippe Antoine a4aa865f52 detect/geoip: do not require packet
Ticket: 8333

Allows to pass on pseudo packets

So, that a ruleset like
pass ssh any any -> any any (geoip:any,US,IN; sid: 1;)
drop ip any any -> any any (flow:established, to_server; sid:2;)

Does not lead to a drop on the pseudo-packet when we flush
because ssh traffic gets encrypted

(cherry picked from commit d4c036718a)
4 weeks ago
Shivani Bhardwaj fe1cb9d24b dcerpc: remove bad tests
Unittests test_parse_bind_pdu_infinite_loop and
test_parse_bindack_pdu_infinite_loop seem to have artificially made up
header which does not hold up to the strict calculations enforced by the
parser now. Their headers mark the fraglens as 64 and 72 respectively
which are not enough to hold the kind of bind(ack) items that are expected.
It worked so far as the parser passed the entire input slice around but
with the bugfix for issue 7546, the input passed around is strictly
restricted to the fraglen parsed in the header.

Bug 7546

(cherry picked from commit d4008a6508)
4 weeks ago
Philippe Antoine 07c96bf218 dcerpc: use bind context_id in SMB
Ticket: 8375

logger already read this variable but it was never set, and
the rust compiler did not warn about this

Allows to log the interface uuid when ctx_id > 0

Wireshark filter for related pcaps
dcerpc.cn_ctx_id > 0 && dcerpc.pkt_type == 0

(cherry picked from commit 6587e363a3)
4 weeks ago
Philippe Antoine 884125429f dcerpc: support multiple PDU in one parser call
Ticket: 7254

With TCP, we receive a stream of data, which may contain multiple
PDUs in one call

(cherry picked from commit 2c2a3c800f)
4 weeks ago
Philippe Antoine 8e14f4872d dcerpc: do not error the whole flow on unhandled packet type
Ticket: 5133
(cherry picked from commit 55ad2953bf)
4 weeks ago
Victor Julien d3a11d96da detect/icode: mark as supported for firewall mode
Ticket: #8398.
1 month ago
Philippe Antoine 841f2b21e6 clang-format: fix the base branch 1 month ago
Victor Julien e14d03d1e0 github-ci: disable libmagic on macos
5.47 is currently breaking CI, so disable during investigation.

Related to ticket #8342.

(cherry picked from commit 3068089762)
1 month ago
Jason Ish a316952db3 github-ci: update almalinux minimal build to use dist archive
Update the AlmaLinux recommended minimal build to use the pre built
distribution archive as this is the type of build the documentation is
targetting.

(cherry picked from commit 551f6ded69)
1 month ago
Jason Ish 3611ca8c09 github-ci: update debian/ubuntu minimal build to use dist
Update the Ubuntu/Debian minimal recommended build to use the
pre-built dist archive instead of building from git, as that is the
type of build this documentation targets.

Also use the ubuntu:22.04 container. The GitHub provided Ubuntu 22.04
VM appears to contain some new additions like a newer Rust that is not
found on a typical Ubuntu 22.04 installation.

(cherry picked from commit 87dba92bdd)
1 month ago
Shivani Bhardwaj 885a28f62a version: start development towards 8.0.5 1 month ago
Juliana Fajardini 6af634b19b release: 8.0.4; update changelog 1 month ago
Lukas Sismis 7e92018808 dpdk: update mempool size tests
In reaction to commit reversal some tests had to be adjusted
to pass the CI.

Based on the reversed commit 0c54932a4b.
1 month ago
Lukas Sismis 2a764b47a8 Revert "dpdk: fix mempool sizing to always yield 2^n -1"
Due to incorrect mempool size calculation, in some cases
(e.g. when rx-descriptors=32k, tx-descriptors=64) the mempool
size was calculated insufficiently in the auto mode (in the example
case it would result to 32767 which wouldn't even hold RX descriptors).

Even with a fix, the mempool size would increase (and in turn hugepage
consumption), as current mempools are just a sum of rx + tx descriptors.
To avoid introducing behavior-change this commit is reverted.

Ticket: 8371

This reverts commit 0c54932a4b.
1 month ago
Philippe Antoine 6484a012a3 detect/http2: use ThreadCtx for all headers keywords
Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 062f56ddde)
1 month ago
Philippe Antoine 029cc968c8 detect/http2: use ThreadCtx for http.request_header
And also for http.response_header

Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 4e538dfa3b)
1 month ago
Philippe Antoine 7b77edfa69 detect/http2: use ThreadCtx for http.header.raw
Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 0933e944df)
1 month ago
Philippe Antoine c0efcf559d detect/http2: use ThreadCtx for http.header
Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 711de8a5ea)
1 month ago
Philippe Antoine 94e5b1c90b detect/http2: use ThreadCtx for http.header_names
Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 52a2f2dd19)
1 month ago
Philippe Antoine 77387c1315 app-layer: fix uint overflow in debug assertion
Krb5 can request it needs a 0xFFFFFFFF record

(cherry picked from commit 61b5461782)
1 month ago
Philippe Antoine 1193019d3a krb5: use app-layer incomplete support
Ticket: 3540
Ticket: 8305
(cherry picked from commit 8e886a8ecd)
1 month ago
Victor Julien f12cf353a3 ldap: add rules file to dist
(cherry picked from commit 1732257923)
1 month ago
Giuseppe Longo 870a09cb7b ldap: add ldap.rules file
Add a file containing rules to match LDAP protocol events.

Ticket #8368

(cherry picked from commit b6fa3c8e8c)
1 month ago
Jason Ish 3264677d4c ndpi: fix logging of pcap_cnt
PcapPacketCntGet does not exist in 8.0.x.
1 month ago
Victor Julien 640d03bef5 stream/reassembly: improve progress tracking for GAP cases
When during raw reassembly it is detected that last ack is moved beyond
the progress and also beyond the data retrieved, update progress to the
last ack value.

Bug: #8272.
(cherry picked from commit ac1a514c7b)
1 month ago
Philippe Antoine 7635d88589 ldap: abandon request does not wait for a response
Ticket: 8356

As such, abandon request is a complete tx

(cherry picked from commit 76d2925bdf)
1 month ago
Philippe Antoine 2d5172aaf3 http2: bound number of http2 frames per tx
Ticket: 8289

If stream.reassembly.depth is unlimited,
an attacker controlling the 2 sides of a communication going through Suricata
can send a transition with an infinite number of headers, until suricata OOMs

Solution is to offer a configuration option to bound the number
of HTTP2 frames we store in a HTTP2 transaction, and produce an
anomaly if this bound is crossed

(cherry picked from commit 784e173278)
1 month ago
Philippe Antoine 632acbe74c detect/tls: add null check for tls.alpn keyword
Ticket: 8294

Fixes: 6c1238b7bd ("tls: Integrate ALPNs into HandshakeParams object")

May happen if we analyze TLS without seeing the hello

(cherry picked from commit cb76301581)
1 month ago
Philippe Antoine aa12b193d3 smtp/mime: fix urls finding in buffering case
We used to look for a full line, but as we look fot the last eol
we need to use the right index in the not-reversed list

(cherry picked from commit 49fd7001ff)
1 month ago
Philippe Antoine 7a670e9b7a smtp/mime: avoid quadratic complexity in mime_smtp_find_url_strings
Ticket: 8292

When we have buffered something in ctx.decoded_line,
we already looked for '\n' in it, so we do not need to run it again

Otherwise, callers that supply mime_smtp_find_url_strings with
a few bytes at a time without "\n", have a quadratic
complexity

(cherry picked from commit 8bba47aa09)
1 month ago
Jason Ish 44e75573ac examples/lib/live: a lib example with live capture
Simple libpcap example for live capture. Allows listening on multiple
interfaces to show how multiple threads (workers) can be used.

Ticket: #8096
(cherry picked from commit f711e57e8e)
1 month ago
Jason Ish 5eae2993ee examples/lib/cplusplus: simplfy, make more like the simple example
To prep for the removal of the lib runmode, simplify this C++ example
to match our simple example. We don't yet have the C++ compatible
headers to allow for a C++ app to register its own custom runmode.

(cherry picked from commit 7dd23392cc)
1 month ago
Jason Ish b7447b1437 examples/lib/custom: use own custom run mode
Debug validation revealed that library ThreadVars were being
created *after* the threads were sealed. And the only way to create
your ThreadVars that fits within the current application life-cycle is
to create them in your own custom run mode.

This is likely a better model for users who are bringing their own
packets and threads anyways, as they are essentially providing their
own capture method, and all capture methods provide their own run
mode. They're also using their own threads, which means adapting to
their own threading model.

This is suitable for a backport to 8.0. But for 9.0 we can go further
and remove the built-in library run mode, which will be done in a
follow-up commit.

Ticket: #8259
(cherry picked from commit 445de77c71)
1 month ago
Jason Ish 4da63239b3 github-ci: add debug validation to almalinux 10 build
After the distcheck, this build doesn't need unittests, so add
debug-validation, as this can trigger assertions in our lib examples
that are tested in this job

This triggers a debug-validation error in the custom library example.

Ticket: #8259
(cherry picked from commit 02e4399059)
1 month ago
Lukas Sismis e0f2cdf7c3 hs: prune stale MPM cache files
Hyperscan MPM can cache the compiled contexts to files.
This however grows as rulesets change and leads to bloating
the system. This addition prunes the stale cache files based
on their modified file timestamp.

Part of this work incorporates new model for MPM cache stats
to split it out from the cache save function and aggregate
cache-related stats in one place (newly added pruning).

Ticket: 7893
(cherry picked from commit 15c83be61a)

hs: suppress TOCTOU stat use

To explain a bit more the TOCTOU issue found, we can consider
a case where Suricata starts to prune, yet externally somebody also
starts erasing cache files.
Right after Suricata checks the file age with the stat function,
somebody may delete or update the file of our interest.

Suricata aging decision doesn't reflect the actual state of the file.
This commit additionally adds a check for noent failure of the unlink operation
(considered as a success). The code can still delete a file that is recently
updated but was considered stale.

In the documentation-following deployments this should not happen anyway as
one cache folder should only be used by a single Suricata instance (and within
Suricata instance only one thread handles cache eviction).
Additionally, the `stat` and `unlink` command are immediatelly followed, making
this scenario extra unlikely.

Additional comment in the code explains problems of using fstat and potential
issues on Windows.

Ticket: 8244
(cherry picked from commit 0fe0390a2f)

hs/cache: cleaner and more detailed output

Reduce logging level of a minor informational message.

Split tracking of pruning by age and by version and log those
separately, where the logging only appears if something has been
removed.

Ticket: 8323
(cherry picked from commit 569ba3d26f)

hs: remove redundant file handle in HSLoadCache

HSLoadCache opened the cache file but never used the resulting handle
for reading. The actual read was done by HSReadStream which opened
the same file independently.

Removed the unused fopen/fclose pair and flattened the control flow.

Ticket: 8326
(cherry picked from commit d754b28717)

hs: use binary mode for cache file I/O

HSSaveCache wrote serialized Hyperscan databases using text mode ("w")
while HSReadStream already read them with binary mode ("rb").
Matched file reading modes to the binary format and simplified
write-size check.

Ticket: 8326
(cherry picked from commit 0cdc77b707)

hs: warn about the same cache directory

This is especially relevant for multi-instance simultaneous setups
as we might risk read/write races.

(cherry picked from commit 56c1552c3e)

hs: validate cached database against current HS installation

After deserializing a cached Hyperscan database, verify that its
version, CPU features, and mode match the current Hyperscan
installation by comparing hs_database_info output against a
reference database. Reject loading incompatible caches.

Ticket: 8326
(cherry picked from commit 2e7b12dda4)

hs: include HS platform info in cache file hash

Hash Hyperscan installation info (version, CPU features, mode)
into the cache filename. A Hyperscan upgrade or platform change
would now produce a different filename, so stale caches from an
older installation are never opened.

Ticket: 8326
(cherry picked from commit d640719413)

hs: address coverity warning in a reference string

Move the locking mechanism outside of the getter function and hold the
lock until the reference string is no longer reused.

** CID 1682023:       Concurrent data access violations  (MISSING_LOCK)
/src/util-mpm-hs-cache.c: 139           in HSGetReferenceDbInfo()

(cherry picked from commit 6ec9e5c957)
1 month ago
Lukas Sismis 4604266685 detect-engine: make mpm & spm part of MT stub ctx
As a intermediary step for Hyperscan (MPM) caching,
the MPM config initialization should be part of the default
detect engine context for later dynamic retrieval.

Ticket: 7893
(cherry picked from commit 08f5abe5e9)
1 month ago
Lukas Sismis 4261f5e4e7 hs: touch cache files on use to signal activity
Ticket: 7893
(cherry picked from commit 7031c26865)
1 month ago
Lukas Sismis 763f883d5d path: signal last use of the file (touch)
To have a system-level overview of when was the last time the file was
used, update the file modification timestamp to to the current time.

This is needed to remove stale cache files of the system.

Access time is not used as it may be, on the system level, disabled.

Ticket: 7893
(cherry picked from commit fd3847db72)
1 month ago
Lukas Sismis f701a67d82 conf: add time parsing conf function
(cherry picked from commit 85f0382072)
1 month ago
Lukas Sismis 1d7e58209f misc: time unit parsing function
(cherry picked from commit 3e4fdb2118)
1 month ago
Lukas Sismis bb2a605757 hs: change hash in the cache name to SHA256
(cherry picked from commit c282880174)
1 month ago
Lukas Sismis a733a6b8d6 hs: reduce cache filename size to max file limit
(cherry picked from commit 2a313ff429)
1 month ago
Lukas Sismis 828f67403c hs: update the file description
(cherry picked from commit 47fc78eeae)
1 month ago