Commit Graph

18152 Commits (suricata-8.0.5)
 

Author SHA1 Message Date
Shivani Bhardwaj 5611b60c61 release: 8.0.5; update changelog 4 weeks 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 weeks 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 weeks ago
Philippe Antoine 4253b82db7 detect/engine: helper to know if a transform happens in-place
(cherry picked from commit 4c42998feb)
4 weeks 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 weeks 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 weeks ago
Philippe Antoine 3a6414eb6a ikev2: remove unused field
Ticket: 8415
(cherry picked from commit 614c48d3c3)
4 weeks 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 weeks ago
Philippe Antoine 69107199d6 http2: code refactoring to split big function
(cherry picked from commit 29e4b08647)
4 weeks 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 weeks ago
Philippe Antoine 09c45d91a5 lua: add bounds checks for flowints and flowvars
Ticket: 8556
(cherry picked from commit 0b239c4848)
4 weeks ago
Philippe Antoine 82cf3d67b1 ldap: bound the number of responses
Ticket: 8405
(cherry picked from commit e98d419d96)
4 weeks ago
Jason Ish d62b7cd980 dnp3: bound response reassembly
Ticket: 8460
(cherry picked from commit 078c08d84b)
4 weeks 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 weeks ago
Philippe Antoine 2a4947f0c0 dnp3: bounds reassembly
Ticket: 8460
(cherry picked from commit 658684a252)
4 weeks 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 weeks ago
Victor Julien 75a4641af6 http2: check for HTTP1 protocol during upgrade path
Ticket: 8492
(cherry picked from commit 6ebd0c3cc2)
4 weeks 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 weeks 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 weeks 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 weeks 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 weeks ago
Philippe Antoine af37786ee4 nfs: bound namemap by using lru
Ticket: 8418
(cherry picked from commit aea7ee21b8)
4 weeks ago
Philippe Antoine f43d442251 nfs: bound requestmap and use lru
Ticket: 8418
(cherry picked from commit a50f494ef6)
4 weeks 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 weeks ago
Jason Ish bc05d40d70 rust/lua: add method for pushing bytes
Much like pushstring, but accepts an &[u8] as an argument instead of an &str.

In support of ticket #8533.

(cherry picked from commit 81692dd2c1)
4 weeks ago
Jason Ish 1ceea76ac4 schema: map NTP fields to keywords
(cherry picked from commit 18f742fdbd)
4 weeks ago
Jason Ish c8d95f20db ntp: enable keywords for firewall mode
Ticket: #8394

Backport note: main-8.0.x does not have the keyword information flag
constants from main, so keep SIGMATCH_SUPPORT_FIREWALL and omit the
informational SIGMATCH_INFO_* flags.

(cherry picked from commit fd31e50954)
4 weeks ago
Jason Ish 587e4871b8 ntp: convert reference_id to buffer and add keyword
Store the NTP reference ID as raw network-order bytes so it can be
exposed as a sticky buffer and matched with payload keywords. The
reference ID is often a 4 character string, or an IP address and not
just an integer identifier.

Updates the log reference ID to be a string of colon separated hex
digits as this matches what tshark does.

Ticket: #8488
(cherry picked from commit 713e4eb900)
4 weeks ago
Jason Ish 2a9a57378c ntp: add ntp.mode keyword
This keyword also accepts strings for known mode names.

Ticket: #8429
(cherry picked from commit 991e7f3b1d)
4 weeks ago
Jason Ish 545070ad61 ntp: add ntp.stratum keyword
Ticket: #8431
(cherry picked from commit c10c482290)
4 weeks ago
Jason Ish 4f427c30be ntp: add ntp.version keyword
SNMP was used as a template.

Ticket: #8430
(cherry picked from commit ec344fe68d)
4 weeks ago
Jason Ish e2b2737e8e ntp: create tx for all modes; log version, mode and stratum
Add logging for version, mode and stratum as these will be the first
keywords we will add.

Ticket: #8425
(cherry picked from commit 74bb525401)
4 weeks ago
Jason Ish 21c7adf071 ntp: remove unused event types
NotRequest and NotResponse event type have never been used.

Unsolicited is also unused, however there is a rule for it so removing
support would be a breaking change at this time.

(cherry picked from commit 879846e153)
4 weeks ago
Jason Ish fd742034a6 ntp: add transaction logging
Adds basic NTP transaction logging for the current supported message
types.

Includes small cleanups around reference ID.

Ticket: #8425
(cherry picked from commit 31b967b089)
4 weeks ago
Philippe Antoine 902fd118bd frames: do not free on log+flush packet
As we expect a second log+flush packet in the other direction

Ticket: 8336
(cherry picked from commit cb62d6d73d)
1 month ago
Philippe Antoine 825975d0b3 stream: log flush packets in the other order
Ticket: 8336

At the end of a TLS handshake, in IDS mode, the client acks,
and we parse the server hello and use tls.encryption-handling
to know what to do next (for example bypass)

Everything is parsed, but we have not run detection yet on neither
side.

So, in IDS mode, we need to first flush the client side, as the
comment on the function already stated.

(cherry picked from commit cefd134461)
1 month ago
Philippe Antoine bef72178dd detect: do not wait for more in log_flush
Ticket: 8336

When a packet has flag PKT_PSEUDO_DETECTLOG_FLUSH, we do not
expect to rerun detection on the same tx and direction again

So, do not set mpm_in_progress whose purpose is to not store
the state as we will run again.

Allows transactional bidirectional signatures to work on
thse log+flush pair of packets

(cherry picked from commit 1ba411458c)
1 month ago
Jason Ish 1a09a059dc eve: add rule generation source to alert record
When an alert is generated from firewall context, add an engine value of
"fw", otherwise "td" (for threat detect).

The engine field is only added when firewall mode is enabled.

Ticket: #8456
(cherry picked from commit 029fd1be59)
1 month ago
Sergey Pinaev 69e829b082 reputation: remove unused code
Remove useless while() that led to buffer underflow

Ticket: #8500
(cherry picked from commit 2e22ba65e7)
1 month ago
alinse-pltzr 59ebaf41b1 ftp: add rule for too many transactions
Issue: 8489
(cherry picked from commit c48bb1b26c)
1 month ago
alinse-pltzr 32546c91c9 conf: add comment for ftp.max-tx
Add missing FTP configuration value to suricata.yaml.in showing the
default value.

Issue: 8489
(cherry picked from commit 86fe20dd48)
1 month ago
Jeff Lucovsky d45dfe4ebd ftp: don't halt the flow when raising too_many_transactions
The first version of the event set done=true on state->curr_tx and
returned NULL when the limit hit. curr_tx is usually the active
command just received — marking it done mid-request throws off
response matching, and subsequent commands in the flow stop getting
logged.

SMB behavior is mirrored here:
Walk the tx list, find the oldest tx that isn't done, mark
it done and tag it with the event, then fall through and
create the new tx so the flow parsing continues. One stale tx gets
reaped per overflow so memory stays bounded.

Issue: 8489
(cherry picked from commit 5ddd808e9b)
1 month ago
Jeff Lucovsky 9162048a93 ftp: raise too_many_transactions event on overflow
Other parsers (SMB, POP3, ENIP) already raise a too_many_transactions
event when a flow exceeds its per-flow transaction limit. FTP had
the limit wired up through app-layer.protocols.ftp.max-tx but just
dropped the excess transaction on the floor with a "FTP does not set
events yet..." TODO, so no event was raised when the limit was
reached.

Add the FtpEventTooManyTransactions variant, a stock rule at
sid 2232002, and raise the event from FTPTransactionCreate when the
live-tx count goes past ftp_config_maxtx.

Issue: 8489
(cherry picked from commit 9ea2e29581)
1 month ago
Philippe Antoine ad9d979f92 detect/dcerpc: avoids FP on dcerpc.iface keyword
When we got a bind without the first fragment flag, and did not
set any_frag in the signature, the signature always matched,
whatever the uuid value

Ticket: 8457
(cherry picked from commit e38888810d)
1 month ago
Victor Julien abf9985205 util/path: fix compile warning
util-path.c:251:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  251 |     char *final = strrchr(path, DIRECTORY_SEPARATOR);
      |           ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

(cherry picked from commit 72e3d7ad08)
1 month ago
Victor Julien aa08604044 magic: fix compile warning
util-magic.c:436:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  436 |     char *str = strstr(result, "OpenDocument Text");
      |           ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
1 month ago
Victor Julien d3a7e600bf detect/pcre: fix compile warnings
detect-pcre.c:419:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  419 |     char *fcap = strstr(regexstr, "flow:");
      |           ^      ~~~~~~~~~~~~~~~~~~~~~~~~~
detect-pcre.c:420:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  420 |     char *pcap = strstr(regexstr, "pkt:");
      |           ^      ~~~~~~~~~~~~~~~~~~~~~~~~
detect-pcre.c:421:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  421 |     char *acap = strstr(regexstr, "alert:");
      |           ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.

(cherry picked from commit 0a4685f2ab)
1 month ago
Victor Julien 16d227b620 detect/app-layer-protocol: fix compile warning
detect-app-layer-protocol.c:160:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  160 |     char *sep = strchr(arg, ',');
      |           ^     ~~~~~~~~~~~~~~~~
1 error generated.

(cherry picked from commit 3564f2f928)
1 month ago
Victor Julien b08996771e decode: fix compile warning
decode.c:767:19: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  767 |             char *dot = strchr(DEvents[i].event_name, '.');
      |                   ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

(cherry picked from commit a45a70babd)
1 month ago
Victor Julien 8fc2c6ba7b datasets: fix compile warning
datasets.c:159:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  159 |     char *got_colon = strchr(line, ':');
      |           ^           ~~~~~~~~~~~~~~~~~
1 error generated.

(cherry picked from commit 90ce1c54c4)
1 month ago