Commit Graph

18213 Commits (497a69c5a80c33bf1e4c3bc4f408adfc7a243d92)
 

Author SHA1 Message Date
alinse-pltzr 59ebaf41b1 ftp: add rule for too many transactions
Issue: 8489
(cherry picked from commit c48bb1b26c)
4 months 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)
4 months 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)
4 months 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)
4 months 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)
4 months 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)
4 months 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.
4 months 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)
4 months 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)
4 months 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)
4 months 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)
4 months ago
Victor Julien 7424cf21e2 conf/yaml-loader: fix compile warning
conf-yaml-loader.c:87:8: error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
   87 |     ep = strrchr(filename, '\\');
      |        ^ ~~~~~~~~~~~~~~~~~~~~~~~
conf-yaml-loader.c:89:12: error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
   89 |         ep = strrchr(filename, '/');
      |            ^ ~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
4 months ago
Victor Julien 0ab10e7da9 smtp: fix compile warning
app-layer-smtp.c:566:14: error: initializing 'uint8_t *' (aka 'unsigned char *') with an expression of type 'const void *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  566 |     uint8_t *lf_idx = memchr(input->buf + input->consumed, 0x0a, input->len);
      |              ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

(cherry picked from commit 5aee5ff6ed)
4 months ago
Victor Julien 823c615d63 ftp: fix compile warnings
app-layer-ftp.c:278:14: error: initializing 'uint8_t *' (aka 'unsigned char *') with an expression of type 'const void *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  278 |     uint8_t *lf_idx = memchr(input->buf + input->consumed, 0x0a, input->len);
      |              ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
app-layer-ftp.c:1392:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
 1392 |     char *c = strchr(buffer, '\n');
      |           ^   ~~~~~~~~~~~~~~~~~~~~
2 errors generated.

(cherry picked from commit c21275cab3)
4 months ago
Victor Julien 79d1341a4f util/logopenfile: fix compile warnings
util-logopenfile.c:837:11: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  837 |     char *dot = strrchr(base, '.');
      |           ^     ~~~~~~~~~~~~~~~~~~
util-logopenfile.c:848:13: error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  848 |         dot = strrchr(original_name, '.');
      |             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

(cherry picked from commit cd1c5967a5)
4 months ago
Philippe Antoine bb90304746 snmp: add snmp-events.rules file
Add a file containing rules to match SNMP protocol events.

Ticket: 8421
(cherry picked from commit cff3d6417a)
4 months ago
Philippe Antoine 7df9862d41 bittorrent: add bittorrent-events.rules file
Add a file containing rules to match bittorrent protocol events.

Ticket: 8421
(cherry picked from commit 42123cc8d9)
4 months ago
Lukas Sismis 33ab5ccc1a configure: move -march=native flag insertion at the end
When libraries add their own -march flags to CFLAGS, let them.
But if -march=native should be added (it should by default),
add it as the last -march flag to "win".
This ensures, that even if a library brings their own minimal -march,
it will not downgrade the instruction set for the whole Suricata.
This happened with DPDK which, when enabled, downgraded the instruction
set to -march=corei7 or -march=haswell.

When building packages with --disable-gccmarch-native, the instruction set
is auto-upgraded to instruction set requested by libraries.
E.g. from RPM builds: `CFLAGS="-march=x86_64" ./configure --enable-dpdk`
upgrades instruction set to DPDK's corei7 architecture.

Ticket: 8169
(cherry picked from commit 0cb88d6260)
4 months ago
Jason Ish 07555b97fc psl: update to 2.1.206
Update the public suffix list to the latest release.

Ticket: #8360
4 months ago
Jeff Lucovsky 2841bcf330 doc/config: Update flushing description
Update output flushing description to reflect EVE based approach in
documentation and config template.

Added: Provide update callout for out-of-tree output plugins.

Issue: 8286
(cherry picked from commit e7dc0d885b)
4 months ago
Jeff Lucovsky 9376742dc8 output/flush: Remove flush functions/registration
Remove log flush functions and update registration logic as
context-based flushing doesn't require it.

Issue: 8286
(cherry picked from commit 1923ca1aa0)
4 months ago
Jeff Lucovsky e1e43fd8f7 output/flush: Remove pkt-based flush logic
Remove packet-based flush logic in favor of simpler solution

Issue: 8286
(cherry picked from commit d0ba1c4c5e)
4 months ago
Jeff Lucovsky 9ca03cdf99 output/flush: Add EVE flushing logic
Add flushing logic driven off of the file contexts. This is a simpler
solution that removes the need for logger registration changes.

Overview:
Use the heartbeat-driven thread to periodically flush all registered EVE
contexts via a global flush list.

The global flush list is a mutex-protected TAILQ of LogFileFlushEntry
nodes; each node points to a LogFileCtx. Mutex = log_file_flush_mutex

Periodic flushing performed by a thread according to the
heartbeat.output-flush-interval [1,60]. LogFileFlushAll() is invoked to
initiate flushing of registered LogFileCtx structs; each struct's
fp_mutex is obtained while the flush occurs to synchronize with
LogFileWrite activity.

Interacts with file-rotation via the fp_mutex.

Deadlock prevention: the log_file_flush_mutex must be obtained before
the fp_mutex.

Issue: 8286
(cherry picked from commit a78911fce7)
4 months ago
Philippe Antoine 12d4cc73f9 detect: (m)dns keywords even with "alert udp"
Ticket: 8501

(m)dns.*.rrname keywords required the rules to start with
alert (m)dns
and refused to load if the rule started with generic alert ip or
alert udp, with error message
Error: detect-parse: invalid alproto 0

(cherry picked from commit 7e326f291a)
5 months ago
Philippe Antoine e40775d68a detect/http2: fix progress for headers
Ticket: 8451

Do not wait to see a data frame to run detection on http2 headers

(cherry picked from commit 40c8620184)
5 months ago
Philippe Antoine b80d5f7517 detect/doh2: prefilter does not use dns engine progress
to update HTTP2 tx progress

Ticket: 8454
(cherry picked from commit 898446aee8)
5 months ago
Victor Julien e71c54a149 eve/drop: always enable verdict in firewall mode
(cherry picked from commit f9b25dc6ec)
5 months ago
Victor Julien 8f8cd4fdf5 detect/firewall: fix 'last_for_progress' logic
If the last signature in the candidates list is also the last for the
current progress value, it needs to be considered as the last for that
progress, so that if it doesn't match the default policy is applied.

(cherry picked from commit ff6fb068c7)
5 months ago
Victor Julien e55197d103 detect/snmp: let generic keyword share the same list
(cherry picked from commit 2cef1404bc)
5 months ago
Victor Julien 7f7ab9299c detect/snmp: add snmp.trap_type keyword
Implemented as a U8 integer keyword.

Ticket: #8482.
(cherry picked from commit 670fdabd32)
5 months ago
Victor Julien 6c0673374a eve/schema: add snmp trap fields
(cherry picked from commit c94cb8e098)
5 months ago
Philippe Antoine df625bd32f detect: enable snmp keywords for firewall mode
Ticket: #8395
(cherry picked from commit 8ac9a62ec4)
5 months ago
Philippe Antoine 80c6145478 detect/snmp: sticky buffers at progress 1
Since snmp txs are created at progress 1 which is the completion,
this does not change detection, except allowing firewall mode
to use these keywords with generic hook like
snmp:request_complete

Ticket: 8395
(cherry picked from commit 63603fe14a)
5 months ago
Philippe Antoine 7ce6fd6b21 detect: adds helper function SCDetectHelperBufferProgressMpmRegister
Taken from ea8ac2a0
5 months ago
Philippe Antoine efc5075a4f detect: new helper for buffer register with required progress
Ticket: 8395

Not a cherry-pick of 8f824458 which replaces, so as not to change
the current API, just extending it
5 months ago
Eric Leblond 9f82c45b81 etc/schema: add http_request_body
Ticket: 8161
(cherry picked from commit e4e5413478)
5 months ago
Jason Ish 5d050a456b rust: suppress cargo audit for RUSTSEC-2026-0097
Per https://rustsec.org/advisories/RUSTSEC-2026-0097,
this issue it not applicable unless the "log" and "thread_rng"
features of rand are enabled.  "log" is not enabled in our
dependency chain.

Updating to the fixed version of rand requires an MSRV of 1.85.

Ticket: #8467
(cherry picked from commit be36e67f52)
5 months ago
Victor Julien de84f580b4 detect: enable pcre and urilen for firewall mode
Ticket: #8397.
(cherry picked from commit facbb04915)
5 months ago
Victor Julien 3239f6b24f qa: add nfq based firewall test with live reload
(cherry picked from commit 49b1382a8b)

Include suricata config not part of original commit.

Ticket: #8409.
5 months ago
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)
5 months 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)
5 months ago
Jason Ish 995ad5dc4e examples: fix run mode name in live example
Ticket: #8439
5 months 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)
5 months 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)
5 months ago
Philippe Antoine 831be60a57 dcerpc: only log the tx interfaces
Not all the state ones

Ticket: 8378
(cherry picked from commit 34ed8958a6)
6 months 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)
6 months 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)
6 months 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)
6 months 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)
6 months 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)
6 months ago