Commit Graph

14434 Commits (4144d9c70916b0015b54d1cb927533a60928db55)

Author SHA1 Message Date
Antoine Abou Faysal a3ab00e920 detect/dataset: add match subdomain option
Ticket: 8385

Add a new match subdomain option that enables blocking a domain and all its subdomains using datasets.
5 months ago
Shivani Bhardwaj 899eb38691 flowbits: deprecate toggle command
toggle command is not used by any major rulesets and increases the state
complexity of flowbits management. Also, all operations can be carried
out with the combination of other available commands. So, remove it.

Task 8595
5 months ago
Jason Ish 546209ff12 bindgen: fix include ordering
At some point, bindgen include ordering changed such that
AppLayerGetFileState was being bindgen'd as opaque, as the definition of
StreamBufferingConfig was not available when bindgen hit
AppLayerGetFileState, and bindgen processes in order.

Move the util includes before the app-layer includes to fix the ordering
problem, but still keep util includes grouped.

The sys diff is large as many things have been re-ordered.
5 months ago
Philippe Antoine 42fc785e12 fuzz/iprep: initialize to 0 buffer buffer before writing to it
And make MSAN happy
5 months ago
William Ling e7edc2a1e2 unittests: convert util-spm tests to FAIL/PASS API
Issue: 6334
5 months ago
Philippe Antoine af7fad5514 detect: allocate arrays on the heap
buffer_type_id is a u32

Ticket: 8001
5 months ago
Philippe Antoine 2eede11195 detect: clean app-layer txs when we pass the flow
Ticket: 8619

Do not wait to run inspection on the other side of transactions
as we do not run any tx detection on passing flows.
Avoids accumulating txs
5 months ago
Philippe Antoine daf68dc36f http2: split progress per direction
Ticket: 8518

Keywords that work for HTTP2 headers match now as soon as possible

A push promise is now considered like a headers frame with regards
to the progress (no dedicated "reserved" progress/state)

http.protocol and http.stat_msg keywords are now registered at
earliest progress, since these are synthetic like "HTTP/2" and
not really seen on the wire.

http.request_line and http.response_line match only on data,
and not on headers, since we must wait the end of headers
to be sure to have the full line

http2.size_update now matches at headers progress as it should

http2.frametype, http2.errorcode, http2.priority now match like
http2.window, when the tx is complete from both sides, as a
half-closed client may still send priority, rst_stream
or window_update frames
5 months ago
Philippe Antoine 567e824e44 fuzz: add target for iprep
Ticket: 3589
5 months ago
Philippe Antoine 29795be5a2 fuzz: make more unit test utilities available for fuzzing 5 months ago
Jason Ish 6687618b67 misc: remove log-cf-common
It was only used to http-log which is now removed.
5 months ago
Jason Ish 3806bf4260 util-time: relocate timestamp format unit test from log-cf-common
log-cf-common is not longer needed with the removal of http-log, but this test
is still valid, so move until util-time.
5 months ago
Jason Ish 865b7243a0 http-log: remove support for http-log
http-log was deprecated in Suricata 8, and marked for removal in
Suricata 9.0.

Ticket: #7232
5 months ago
Giuseppe Longo 0b20011a9f llmnr: implement sticky buffers
Add detection keywords for LLMNR protocol inspection:
- llmnr.queries.rrname
- llmnr.answers.rrname
- llmnr.authorities.rrname
- llmnr.additionals.rrname
- llmnr.response.rrname

LLMNR reuses the existing DNS functions since it follows the same
protocol structure. The implementation registers LLMNR-specific keywords
that leverage the DNS data extraction functions.

Both to_server and to_client directions are supported.

Ticket #8366
5 months ago
Giuseppe Longo 8f205bb34f llmnr: implement logger
This adds an LLMNR protocol logger that reuses existing DNS functions,
following the same approach as the mDNS logger:

- No grouped logging
- Rdata is logged in a field that is named after the rdata type
- Types are logged in lower case
- Flags are logged as an array

Ticket #8366
5 months ago
Giuseppe Longo 13df0f7a06 llmnr: implement parser
This adds a parser for LLMNR protocol over both UDP and TCP.

The parser reuses the existing DNS functions since LLMNR shares
the same wire format as DNS, but implements its own protocol-specific
validation:

- LLMNR-specific flag checks (C, TC, T bits)
- Opcode validation (only standard query opcode 0 is valid)
- An Event is set if Z-flag is set, since it's must be zero per RFC4795

LLMNR transactions inherit DNS behavior where each packet creates a new state
with one transaction.

Ticket #8366
5 months ago
Victor Julien 9e82ff82e2 fuzz: use heap threadvars allocations
Use new allocator to properly set up thread storage.
5 months ago
Victor Julien cefee1390e detect/threshold: don't double init per thread cache
Can get called multiple times in the multi-tenancy case.
5 months ago
Victor Julien f67dadc3d8 detect/threshold: fix unittests for storage based cache 5 months ago
Victor Julien c27868a8c5 threshold: use seed consistently in hashing
Use for IPv6 in the main hash.

Update IPv4 thread cache to also use a seed. For this the thread
initialization is done at thread init instead on the first packet. The
thread ctx is no longer stored in a thread_local, but instead uses the
thread storage API to store in the ThreadVars. This way it will stay
active during rule reloads as well.

Ticket: #8617.
5 months ago
Victor Julien b742d58544 hash: allow registing with a seed value
Seed value will have to be used by the caller's hash function.
5 months ago
Victor Julien 730ff5075d threads: use threadvars memory helpers 5 months ago
Victor Julien ad1459df72 threads: add threadvars allocator and free func
Mostly meant to help unittests and fuzz targets alloc the storage
correctly.
5 months ago
Victor Julien b11aa94d42 decode/vlan: implement max layers for IEEE8021ah
Ticket: #8615.
5 months ago
Victor Julien 377462ea63 defrag: decrement memuse on alloc failure
Ticket: #8613.
5 months ago
Jason Ish 9f40968bba rust/ffi: bindgen thread storage
Ticket: #8445
5 months ago
Victor Julien 736f50600f mpm/hs: fix compile warnings
CC       util-mpm-hs-cache.o
util-mpm-hs-cache.c:301:59: error: implicit conversion loses integer precision: '__size_t' (aka 'unsigned long') to 'uint32_t'
      (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
  301 |         SCSha256Update(hasher, (const uint8_t *)ref_info, strlen(ref_info));
      |         ~~~~~~~~~~~~~~                                    ^~~~~~~~~~~~~~~~
util-mpm-hs-cache.c:310:46: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'uint32_t'
      (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
  310 |     if (!SCSha256FinalizeToHex(hasher, hash, hash_len)) {
      |          ~~~~~~~~~~~~~~~~~~~~~               ^~~~~~~~
2 errors generated.
5 months ago
Victor Julien e0b501a4b7 detect: cleanup last tx logic
Move into DetectTransaction.
5 months ago
Victor Julien 3d00e73d91 detect: make progress values uint8_t
Also reflect that it can be >= 48, like in prefilter.
5 months ago
Victor Julien a9b3ad49ea detect/firewall: minor code cleanup 5 months ago
Victor Julien 4db84cfa28 detect/firewall: clean up apply accept logic
Use end state from tx.

Handle flow control from inside the function consistently.
5 months ago
Victor Julien 68885e75e1 detect/firewall: refactor per tx rule result handling
Break out the 3 options: match, partial match, no match for firewall
into separate functions.

Additionally, handle the re-match case for matches on a hook where the
progress value didn't yet progress further. In this case the continue
inspection logic revisits the rule and the accept needs to be
re-applied.
5 months ago
Juliana Fajardini a783007408 detect/bypass: ban bypass keyword for firewall mode
Related to
Ticket #8551
5 months ago
Juliana Fajardini edaa912ed9 detect: ban `replace` keyword for firewall mode
Ticket #8551
5 months ago
Juliana Fajardini 6e71ff3013 detect/parse: allow banning keywords with fw mode
Related to
Ticket #8551
5 months ago
Juliana Fajardini 04a7674512 detect/parse: allow banning keywords from fw rules
Related to
Ticket #8551
5 months ago
Philippe Antoine e089ac9775 util/mpm-ac: preallocate on the heap rather than stack
Ticket: 8001

As the the size of the allocation can get large
5 months ago
Philippe Antoine dc5185e355 util/mpm-ac-ks: preallocate on the heap rather than stack
Ticket: 8001

As the the size of the allocation can get large
5 months ago
Philippe Antoine 94a3e03903 util/mpm: add MpmCtx argument to MpmInitThreadCtx
Ticket: 8001

Will allow algorithms such as ac to use the MpmCtx, especially
the number of patterns, to preallocate some structures.

For detect engine PatternMatchThreadPrepare, create a dummy
MpmCtx out of all the MpmCtx in the DetectEngineCtx,
and get the max value for the number of patterns
5 months ago
Philippe Antoine 25bf59f238 util/spm: explicit needle_len is u16
So, stack allocation is bounded

Ticket: 8001
5 months ago
Victor Julien 9c76480ac3 detect/firewall: further simplify flow control
For the last for progress case we can just break on a firewall drop.

For the accept:flow and accept:tx cases the next sig (if any) will check
the flow/tx flag and manage flow control from there.
5 months ago
Victor Julien bb6dc93789 detect/firewall: clean up per rule run check 5 months ago
Victor Julien 035e8bc851 detect/firewall: minor flow control cleanup 5 months ago
Victor Julien bb7aff36a8 detect/firewall: simplify pre-check flow
Simplify pre-check logic. Pre-check takes care of enforcing
FLOW_ACTION_ACCEPT, APP_LAYER_TX_ACCEPT and default policy enforcement
before the current rule's hook. This should be done in firewall mode for
each rule regardless whether it is a firewall or TD rule.

No need to track verdict state anymore.
5 months ago
Victor Julien 68f73302ce detect/firewall: clean up tx inspection loop 5 months ago
Victor Julien a86fe01cc3 detect/firewall: consolidate action handling
Step towards consolidating all action handling into a central location.
5 months ago
Victor Julien 1ad9c3ec29 detect/firewall: clean up pre-check policy logic 5 months ago
Victor Julien 52967c69ec detect/firewall: fix accept:tx,alert in default policy 5 months ago
Victor Julien 247c6a2333 detect/firewall: inject alert before default policy
If default policy is invoked because of missing rules for next hooks,
make sure to inject an alert before the next hook policies might do so.
5 months ago
Victor Julien 90a837cef3 detect/firewall: update discarded logic
Only count alert queue overflow here, not alerts in the queue after a drop.
5 months ago