Commit Graph

18228 Commits (078ab2ff7028ebb8243ef8f5467acd7e84c26387)
 

Author SHA1 Message Date
Juliana Fajardini a68bc82dd0 detect/parse: convert Notice Log into Debug
(cherry picked from commit 6933602050)
3 months ago
Victor Julien a0382a9fdf qa: add script to test firewall bridge mode
(cherry picked from commit 1c66eec656)

Removed the bridge script as arp isn't supported in 8.0.x.
3 months ago
Juliana Fajardini 6f6d18492e exceptions: add dedicated flow drop reason
To better control stats counters.

(cherry picked from commit 8a8574b149)

Cherry-pick note: moved PKT_DROP_REASON_EP_FLOW_DROP to the last
non fw stop to keep the non-fw values the same.
3 months ago
Juliana Fajardini a261229aaf detect: add flow drop by firewall as drop reason
To track flow drops triggered by the firewall.
Add flow drop by firewall as drop reason.

As part of
Ticket #7699

(cherry picked from commit 312967f291)
3 months ago
Juliana Fajardini 680b54fa6f schema: expand stats.ips.replaced explanation
As this is a less obvious counter.

(cherry picked from commit 0acb136b40)
3 months ago
Juliana Fajardini d950432d2e docs: add firewall stats doc
Related to
Ticket #7699

(cherry picked from commit 234172a93c)
3 months ago
Juliana Fajardini e3a6f29836 detect/firewall: add dedicated stats counters
Add a `firewall` stats counter aggregator for all firewall-related
stats.
De-overload "detect.alert_queue_overflow", by adding
"firewall.discarded_alerts" to account for discarded drops in
Firewall mode.
Add Debug statements for tracking corner cases where it can be
difficult to know where a drop is coming from.

Added counters:
- stats.firewall.blocked
- stats.firewall.accepted
- stats.firewall.rejected
- stats.firewall.drop_reason.default_app_policy
- stats.firewall.drop_reason.default_packet_policy
- stats.firewall.drop_reason.flow_drop
- stats.firewall.drop_reason.pre_flow_hook
- stats.firewall.drop_reason.pre_stream_hook
- stats.firewall.drop_reason.rules
- stats.firewall.discarded_alerts

Ticket #7699

(cherry picked from commit 5b488feef5)

Cherry-pick notes:

- moved counter to keep struct layout the same as much as possible.
- moved the FLOW_ACTION_BY_FIREWALL to aux_flags and renamed to
  FLOW_AUX_ACTION_BY_FIREWALL
3 months ago
Victor Julien b7b9720503 flow: add aux flags
Flow::flags field ran out of space, and for ABI compatibility the move
to u64 like in main isn't possible. So add a `aux_flags` field in an
alignment hole to facilitate the coming flags.
3 months ago
Juliana Fajardini 1664b0960e docs/configuration: add firewall mode settings
Partly related to
Ticket #7699

(cherry picked from commit 32d89072d2)
3 months ago
Victor Julien 314dce88d9 detect/tx: minor debug additions and fixes
(cherry picked from commit 367ca7f430)
3 months ago
Victor Julien bac8ebf225 firewall/analyzer: include all hooks
For protocols using default 0-1 states, add support.

For others, print 'unknown' if no name is yet supported.

Ticket: #8514.
(cherry picked from commit b29226c7ea)
3 months ago
Victor Julien 017a28b6ac detect/analyzer: log actual policy for app firewall
(cherry picked from commit f7c44c4c23)
3 months ago
Victor Julien 1444de0eb4 detect/firewall: configurable default policies
Allow configurable policies, including accept. For app-layer this
requires looping all available hooks to apply the policies.

Support configurable policies for packet-filter, pre-stream, pre-flow.

If there are no rules there is also no rule group (sgh). Make sure
the app hooks policies are correctly handled in this case by allowing
a NULL sgh to be handled as well.

For tx rule match actually apply drop directly. Previously this was
always handled by the default drop:flow policy.

Ticket: #7701.
(cherry picked from commit 7134592fea)

Cherry-pick note: moved the DetectEngineCtx member to the end of the
struct to keep the struct layout the same.
3 months ago
Victor Julien 1fb2f0bfa3 firewall: support multi-action statements in rules
For firewall rules, allow multiple actions to be specified in a list

        accept:flow,pass:flow,alert
        accept:flow,alert
        accept:flow,pass:flow

It is mandatory to make the first action the primary firewall policy
action: accept, drop, reject.

Ticket: #8480.
(cherry picked from commit e76728a536)
3 months ago
Victor Julien c17728c5e7 firewall: accept:flow no longer implies pass:flow
Previously a `accept:flow` action would act as both a firewall "accept" and
a threat detection "pass" for the rest of the flow.

This patch changes that. The `accept:flow` action now only accepts the
rest of the packets for the firewall ruleset, but does still continue
threat detection rule evaluation.

Ticket: #8444.
(cherry picked from commit eaacb41aaf)
3 months ago
Victor Julien a08d4d7df1 detect/firewall: rename flow control variable
For improved readability.

(cherry picked from commit 0093bd6123)
3 months ago
Victor Julien a0ebecc104 detect/firewall: apply default policy in no rules case
When there are no rules after prefilter the default policy needs to be invoked.

(cherry picked from commit b695100491)
3 months ago
Victor Julien f08a748e35 firewall: limit action scope packet for app-hooks
For non-UDP (so TCP), don't allow `accept:packet` or `drop:packet` as
this makes the evaluation of other rule hooks unpredictable.

Ticket: #8497.
(cherry picked from commit 33b3793372)
3 months ago
Victor Julien 430bca635e detect/firewall: add single call for applying app default policy
(cherry picked from commit d561f6184a)
3 months ago
Victor Julien 8ee91f8575 detect: clean up firewall rule match handling
(cherry picked from commit 171b14786b)
3 months ago
Victor Julien ee766f6ae9 detect: clean up of last_tx check
(cherry picked from commit b922142865)
3 months ago
Victor Julien b13c890d1b detect: minor code cleanup
(cherry picked from commit 4fd5bbed35)
3 months ago
Victor Julien a32e97ae52 firewall: fix hooks getting skipped in some rulesets
If a ruleset would use `dns:request_complete` but not have a rule for
`dns:request_started`, the `request_started` hook default policy would
not get invoked.

Add a check to make sure it is invoked.

Ticket: #8495.
(cherry picked from commit 900ae89ed8)
3 months ago
Victor Julien e39128f4b3 detect/firewall: clean up flow control
Use an enum for the firewall related flow control, to improve
readability of the firewall inspection logic.

(cherry picked from commit 6d3599e1c2)
3 months ago
Philippe Antoine 3adaddee68 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

(cherry picked from commit 2eede11195)
3 months ago
Shivani Bhardwaj dd5888ce8a version: start development towards 8.0.6 4 months ago
Shivani Bhardwaj 5611b60c61 release: 8.0.5; update changelog 4 months ago
Philippe Antoine 3d371fff99 detect/transforms: dotprefix can be chained
Ticket: 8537

Otherwise, it may cause a use-after-free, in case of reallocated
buffer and we used the buffer inspect which was freed.

(cherry picked from commit 6d437956e2)
4 months ago
Philippe Antoine 11d1fe1ca8 detect/transforms: decompress checks earlier if it is in-place
Ticket: 8536

Otherwise, it may cause a use-after-free.

So, need to allocate the temporary vector, before calling
SCInspectionBufferCheckAndExpand

(cherry picked from commit 2b20a436e7)
4 months ago
Philippe Antoine 4253b82db7 detect/engine: helper to know if a transform happens in-place
(cherry picked from commit 4c42998feb)
4 months ago
Philippe Antoine 9c24b5bf1c http2: better compression against decompression bombs
Ticket: 8513

Suricata decides at 2 levels if a http2 flow is doing a compression
bomb.

There is a direct computation when one chunk of TCP data
is being parsed.
In this case, do not take the ratio into account, just use the size
of the decompressed data, so that if we get a big chunk of TCP data
like 1 MiB, and a not so high ratio of 200, we do not trigger
the debug assertion in util-file.c about 64MiB

The other case stays unchanged : when accumulating over the lifetile of
a flow with multiple txs, take into account the compression ratio,
so that a flow of many txs, having a super high (brotli) compression
ratio, ends up classified as a compression bomb.
(For example, having 100 txs each turning a 100 byte input into a 700 KiB
one)

(cherry picked from commit bf64b52b95)
4 months ago
Philippe Antoine 8abe0f2a8d http1: do not re-parse Content-Disposition header
Ticket: 8529

When Suricata handles a HTTP1 response body, it does so with a
file, and tries to get the filename from the Content-Disposition
header if any, then from the uri.

If it failed to find a file name, it tried again every time
there was new data from the response body, even if there was
no new data to find a file name in either the header nor the uri.

This causes a slowdown in the case the Content-Disposition header
is big.

Fix is to set the flag on the first call of the callback, to be
sure that we will parse the Content-Disposition header for a
filename header only once per http1 response.

(cherry picked from commit 9aaa6f7854)
4 months ago
Philippe Antoine 3a6414eb6a ikev2: remove unused field
Ticket: 8415
(cherry picked from commit 614c48d3c3)
4 months ago
Philippe Antoine 20104d0978 http2: protection against decompression bombs
Ticket: 8513

During decompression, fail early if we have a big decompression
ratio, and enough data.
Track this data also during a tx lifetime, and even a flow/state
lifetime, so that we set event and fail also if the compression
bomb is split over multiple packets

(cherry picked from commit 7bf48b02be)
4 months ago
Philippe Antoine 69107199d6 http2: code refactoring to split big function
(cherry picked from commit 29e4b08647)
4 months ago
Jeff Lucovsky 519ded68fc defrag: release tracker lock before decoding reassembled packet
Decoding the reassembled packet inside DefragInsertFrag while holding
the tracker mutex creates a deadlock situation if the reassembled packet
contains tunneled fragments: two threads could each hold one tracker
mutex and deadlock on the other. Move the decode in Defrag() after
DefragTrackerRelease() so no lock is held during decode (and possibly
re-entering the defrag system).

Make sure to fetch tracker->ip_hdr_offset after DefragInsertFrag since
it may be written during that call if the first fragment arrives last.

Issue: 8550
(cherry picked from commit 1dc629d978)
4 months ago
Philippe Antoine 09c45d91a5 lua: add bounds checks for flowints and flowvars
Ticket: 8556
(cherry picked from commit 0b239c4848)
4 months ago
Philippe Antoine 82cf3d67b1 ldap: bound the number of responses
Ticket: 8405
(cherry picked from commit e98d419d96)
4 months ago
Jason Ish d62b7cd980 dnp3: bound response reassembly
Ticket: 8460
(cherry picked from commit 078c08d84b)
4 months ago
Philippe Antoine d869f782f7 dnp3: fix off-by-one in array sizes
So that we can write a final zero without overflowing the array
and relying on padding to avoid further problems

Ticket: 8448
(cherry picked from commit 38d41e6fa6)
4 months ago
Philippe Antoine 2a4947f0c0 dnp3: bounds reassembly
Ticket: 8460
(cherry picked from commit 658684a252)
4 months ago
Philippe Antoine 31d3977720 frames: make sure we use a lowercase buffer name
Ticket: 8526

As some C protocols accepted case-insensitive frame names,
a rule using the same frame twice with different cases,
ended up using 2 different buffers,
which ended up in triggering a buffer overflow

(cherry picked from commit c977b2f31b)
4 months ago
Victor Julien 75a4641af6 http2: check for HTTP1 protocol during upgrade path
Ticket: 8492
(cherry picked from commit 6ebd0c3cc2)
4 months ago
Jason Ish 3e064d4796 lua: enforce allocation limit on first alloc
Instead of just on re-alloc.

Ticket: #8507
(cherry picked from commit 2d6c3213ae)
4 months ago
Philippe Antoine 97d6fa9e14 defrag: check tracker/packet family in compare
Ticket: 8510

Without this check, in case of a hash collision, and the other
fields are equal, we could end up consider adding an IPv6 packet
to a IPv4 tracker (or vice versa).

Doing so, we end up interpreting an IPv6 packet as an IPv4 one,
and we do not benefit from the bounds checks from ipv4/ipv6 decoder.

(cherry picked from commit 24527d662a)
4 months ago
Jason Ish 654f5fa64f datasets: fix path setup when load and save used with different paths
If load and save were used in the same rule with different paths, proper path
setup was skipped.

Ticket: #8546
(cherry picked from commit 74eb82a8a5)
4 months ago
Philippe Antoine c029c09585 nfs: bound file_additional_procs to 1
Ticket: 8418

As we only need to know we saw at least one NFSPROC3_COMMIT

(cherry picked from commit 10bde66586)
4 months ago
Philippe Antoine af37786ee4 nfs: bound namemap by using lru
Ticket: 8418
(cherry picked from commit aea7ee21b8)
4 months ago
Philippe Antoine f43d442251 nfs: bound requestmap and use lru
Ticket: 8418
(cherry picked from commit a50f494ef6)
4 months ago
Jason Ish 53e594ef46 ntp: expose logged fields to lua
This includes:
- version
- mode
- stratum
- reference_id

Ticket: #8533
(cherry picked from commit 899e9f045e)
4 months ago