Commit Graph

17971 Commits (cba7fffefc91cdce00962b2017e753fefeb4128d)
 

Author SHA1 Message Date
Shivani Bhardwaj cba7fffefc tls/serial: use byte array instead of string
Bug 7887

(cherry picked from commit 24f5b7dab2)
3 months ago
Shivani Bhardwaj 8abb0d11ea tls/issuerdn: use byte array instead of string
TLS parsers use x509-parser crate which parses X.509 certificates that
use ASN.1 DER encoding that can allow arbitrary byte sequences. An
attacker could inject null byte in a certificate anywhere to stump the
common language parsers terminating the string at a null byte leading to
a bypass of a possibly malicious certificate.

So far, the rust TLS parser for "issuerdn" used a pattern that involved:
-> Get ASN.1 DER encoded raw data from the x509-parser crate
-> Convert this raw data to a decoded string (Rust)
-> Convert the Rust string to CString
-- The problem lies here. CString only accepts proper strings/byte
buffers and converts it into an owned C-compatible, null-terminated
string. However, if any null byte occurs in the string passed to the
CString then it panics.
In the rust TLS parser, this panic is handled by returning NULL.

This means that the parser will error out during the decoding of the
certificate. However, Suricata must be able to detect the null byte
injection attack being an IDS/IPS.

Hence, replace all such string patterns w.r.t. TLS IssuerDN with a byte
array.

Bug 7887

(cherry picked from commit f025e07191)
3 months ago
Shivani Bhardwaj 3f735e6d06 tls/subject: use byte array instead of string
TLS parsers use x509-parser crate which parses X.509 certificates that
use ASN.1 DER encoding that can allow arbitrary byte sequences. An
attacker could inject null byte in a certificate anywhere to stump the
common language parsers terminating the string at a null byte leading to
a bypass of a possibly malicious certificate.

So far, the rust TLS parser for "Subject" used a pattern that involved:
-> Get ASN.1 DER encoded raw data from the x509-parser crate
-> Convert this raw data to a decoded string (Rust)
-> Convert the Rust string to CString
-- The problem lies here. CString only accepts proper strings/byte
buffers and converts it into an owned C-compatible, null-terminated
string. However, if any null byte occurs in the string passed to the
CString then it panics.
In the rust TLS parser, this panic is handled by returning NULL.

This means that the parser will error out during the decoding of the
certificate. However, Suricata must be able to detect the null byte
injection attack being an IDS/IPS.

Hence, replace all such string patterns w.r.t. TLS Subject with a byte
array.

Bug 7887

(cherry picked from commit 77c21b05d2)
3 months ago
Shivani Bhardwaj b93b5c4ae3 tls-log: add common fn to create string from arr 3 months ago
Victor Julien 9c5fda18da datasets: fix compile warnings
datasets-string.c:53:20: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
        return len + 2;
        ~~~~~~ ~~~~^~~
1 error generated.

(cherry picked from commit 844f6011b1)
3 months ago
Victor Julien 0ae6ee2597 rust/htp: formatting fixup
(cherry picked from commit ff3def130c)
3 months ago
Shivani Bhardwaj 563066a6dd version: start development towards 8.0.4 3 months ago
Juliana Fajardini 3bd9f773bd release: 8.0.3; update changelog 3 months ago
Victor Julien f72f458e79 rust: update lru to 0.16.3; update lock
RUSTSEC-2026-0002

Ticket: #8210.
(cherry picked from commit b1fe6a4ceb)
3 months ago
Jason Ish bdbc38bca2 dnp3: bound the maximum number of objects per tx
Default to 2048, but provide a user configuration value.

Ticket: #8181
(cherry picked from commit 2c95f1ff44)
3 months ago
Jason Ish c03a8db521 dnp3: set a bound on the number of points per message
16384 is used as the max, but a configuration parameter has been
provided. The reason for setting an upper bound is that bit flags can
create a memory amplification as we parse them into individual data
structures.

Ticket: #8181
(cherry picked from commit 3a32bb5743)
3 months ago
Jason Ish 377c8fded8 dnp3: reduce flood threshold to 32 and make configurable
Lower the number of unreplied requests from 500 to 32 to consider a
flood. At the very least this is an anomaly given the DNP3 spec mentions
that DNP3 should only have one outstanding request at a time, with an
exception for unsolicited responses, so in practice no more than 2
should be seen.

Additionally make this value configurable by introducing the max-tx
parameter.

Ticket: #8181
(cherry picked from commit a16f087b93)
3 months ago
Jason Ish 50cac2e246 dnp3: check done state, not complete state for progress
Complete is a flag used to tell if the message was completely parsed,
as not all messages may be completely parsed if we don't know all
their objects. However, they are still "done".

In the alstate-progress callback, check the done flag, not the
complete flag.

Ticket: #8181
(cherry picked from commit d61eef9a8a)
3 months ago
Philippe Antoine b24db73f77 dcerpc: use saturating_add to count fragments
And do not overflow if we have traffic with more than 65K fragments

(cherry picked from commit a48200b9e5)
3 months ago
Shivani Bhardwaj 70655fa01e doc: add dcerpc.max-stub-size config param
(cherry picked from commit 6702791a9c)
3 months ago
Shivani Bhardwaj 39d8c302af dcerpc: add upper limit on stub data
DCERPC parsers had no upper bounds when it came to extending the stub
data buffer. Traffic can be crafted to bypass some internal parser
conditions to create an indefinite buffering in the stub_data array that
can make Suricata crash.

Add a default limit of 1MiB and make it configurable for the user.

Security 8182

Co-authored-by: Philippe Antoine <pantoine@oisf.net>
(cherry picked from commit e412215af9)
3 months ago
Philippe Antoine 018a377f74 http: limit the number of folded lines per header
Ticket: 8201

Limits the quadratic complexity if each packet, restarting the
header parsing, just adds a new folded line.
This was previously bounded by the configurable max header length

(cherry picked from commit fa5a4a994a)
3 months ago
Shivani Bhardwaj 549d7bf606 detect/alert: check alert queue capacity before expanding
So far, the alert queue was expanded by doubling in size w/o any
boundary checks in place. This led to situations where doubling
the alert_queue_capacity meant overflow of the very same value
stored in det_ctx.
This led to heap-use-after-free in some conditions where
det_ctx->alert_queue_capacity overflowed.

Fix this by capping the max of alert_queue_capacity by checking if its
expansion could result in an overflow.

Security 8190

(cherry picked from commit ac1eb39418)
3 months ago
Philippe Antoine 0dddac7278 http: do not use recursion in decompression
just loop and iterate

Ticket: 8185
(cherry picked from commit f2a45c4216)
3 months ago
Philippe Antoine 17c8eb496d output: use tx iterator for finding alert http xff
Ticket: 8156

Allows better performance.

(cherry picked from commit ab2e128176)
3 months ago
Philippe Antoine 754c4e9bde output: optimize loop for finding alert http xff
Ticket: 8156

In case of non-tx alerts, we try to loop over all the txs to find
the xff header. Do not start from tx_id 0, but from min_id
as AppLayerParserTransactionsCleanup to skip txs that were freed

(cherry picked from commit 3b1a6c1711)
3 months ago
Philippe Antoine d767dfadcd datasets: allocates on the heap if string base64 is long
Ticket: 8110
(cherry picked from commit d6bc718e30)
3 months ago
Philippe Antoine 32a1b9ae6a datasets: explicitly errors on too long string
Also avoids stack allocation

Ticket: 8110
(cherry picked from commit 0eff242137)
3 months ago
Victor Julien a81f8b7811 eve/tls: log client version if no server hello seen
Bug: #5713.
(cherry picked from commit 4cdf0a0549)
4 months ago
Shivani Bhardwaj 5eb629cbd6 detect/xbits: parse keywords w strtok_r
Ticket: 4820

Forward ported by Victor Julien from
2c5eead479 ("detect/xbits: parse keywords w strtok_r")

(cherry picked from commit 926ef4c49a)
4 months ago
Victor Julien 91c07f10bd frames: add --list-app-layer-frames option
Lists frames per ip proto and app-layer proto.

Ticket: #8174.
(cherry picked from commit 7ac5d7428e)
4 months ago
Jason Ish 98959d932a rust/psl: update to 2.1.175
Update to get the most recent Mozilla public suffix list.

Ticket: #8148
4 months ago
Giuseppe Longo 183b826223 flow: swap MACs when flow direction is swapped
When FlowSwap() reverses the direction of a flow, the MAC address sets
stored in the flow also need to be swapped to maintain consistency with
the new direction. Previously, MAC addresses were not swapped along with
other flow properties like packet/byte counters.

Ticket #8172

(cherry picked from commit f1b9669ed5)
4 months ago
Giuseppe Longo c677dc4b6f util/macset: fix code style
Code style fixed using clang-format.

Ticket #8172

(cherry picked from commit 8050738fea)
4 months ago
Victor Julien 8f91524c0f detect/luaxform: fix allowed lua rules check
Meant to be enabled by default, but wasn't.

(cherry picked from commit da87bd61d0)
4 months ago
Victor Julien d4217060ee detect/lua: exclude script setup from the max-bytes limit
Make sure the script can use all bytes configured. So exclude setup like
input buffers that are put on the lua state before script is executed.

Bug #8173.

(cherry picked from commit d7866495c2)
4 months ago
Victor Julien cf6c79ccc4 detect/luaxform: disable bytes limit during setup
During per inspection setup the buffer could already use up all the budget.

Bug #8173.

(cherry picked from commit 1f58bc1a07)
4 months ago
Victor Julien 761862f9ba lua/sandbox: allow disabling the bytes limit
Meant for setting up from C, where we may use more bytes than expected.

Bug: #8173.
(cherry picked from commit 7bc4b7d713)
4 months ago
Victor Julien 23862ea633 tcp/tfo: set PKT_STREAM_EST flag
Detection and logging skip a lot of work if PKT_STREAM_EST is not set. When
a TFO packet with data comes in the TCP state is not yet established, but
the data still needs to be considered.

So for this case set the PKT_STREAM_EST flag.

Bug #6744.

(cherry picked from commit cc2287beb4)
4 months ago
Philippe Antoine 3f0725b34c http: do not use a loop to find the tx count
As we want the last tx

Ticket: 8156

The generic function AppLayerParserGetTxCnt calls for HTTP1
Transactions.size()

This function has some specific code, as we may have pre-created
a tx that we do not want to count.
This used to get the last tx by iterating over all the transactions
waiting to find the one with max index.
So, instead of using the Transactions.get function, we get the last
tx out of the VecDeque and check its index.

(cherry picked from commit af246ae7ab)
4 months ago
Juliana Fajardini a1f59cb950 userguide: highlight exceptions interactions
In corner cases, we assume that a midstream exception policy could be
triggered by a prior exception policy in effect. Explain this in the
docs.

Task #5830

(cherry picked from commit 0ca874b678)
4 months ago
Jeff Lucovsky 8e75f21e4f doc/luaxform: Clarify luaxform calling convention
Issue: 8135

Clarify the calling convention for the Lua transform's `transform`
function.

(cherry picked from commit 845544aad3)
4 months ago
Jason Ish b3934140d8 rust: fix clippy warning for implicit cast
Fix provided by "cargo clippy --fix" for error:

error: implicitly casting the result of `from_raw_parts_mut` to `*mut [u8]`
   --> src/ftp/response.rs:107:31
    |
107 |           let _ = Box::from_raw(std::slice::from_raw_parts_mut(
    |  _______________________________^
108 | |             response.response,
109 | |             response.length,
110 | |         ));
    | |_________^ help: replace_with: `std::ptr::slice_from_raw_parts_mut(response.response, response.length)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#cast_slice_from_raw_parts
4 months ago
Jason Ish 5db8c5cd79 rust: fix clippy warning for unused import
While debug_validate_bug_on is still used, it does not need to be
imported directly, as that macro is marked with `macro_export`, making
it globally available to the crate.

(cherry picked from commit 50224f2ee5)
4 months ago
Victor Julien fb1d52f1bd mpm: remove remaining ac-bs references
(cherry picked from commit 08d625bb10)
4 months ago
Victor Julien c9b730a123 doc/af-packet: document disable-hwtimestamp option
Ticket: #1954.
(cherry picked from commit be2c40bde7)
4 months ago
Victor Julien dccfc4fc2e af-packet: add disable-hwtimestamp option
HW timestamping is not always reliable, so add an option to disable it.

Bug: #1954.
(cherry picked from commit 18a6a079da)
4 months ago
Victor Julien 6aa4659aa2 app-layer: only register flow counter for detection-only
Other counters are never incremented if no parser is active.

(cherry picked from commit 72e4275456)
4 months ago
Victor Julien 6ba11cd1c3 unix-socket: don't doubly setup stats private area
(cherry picked from commit 33589e6079)
4 months ago
Victor Julien b5997184b7 counters: minor code cleanup
(cherry picked from commit 13d2fa6092)
4 months ago
Victor Julien dac48f54d8 counters: remove unused id var in local stats counter
Ticket: #5613.
(cherry picked from commit fd9ce24fa3)
4 months ago
Victor Julien e24f1734b6 counters: fix comment for set function
Handles u64, not a double.

(cherry picked from commit 888b415257)
4 months ago
Victor Julien 6c3fe544cf decode: register decoder.erspan and decoder.nsh counters correctly
These are regular counters, not 'max' counters.

(cherry picked from commit 2eb2926cd2)
4 months ago
Philippe Antoine 2f9762ccb1 detect/ssl: properly handle negation in ssl_version keyword
Ticket: 3220

DetectSslVersionMatch did not handle properly negation.
It could never match on a signatrue with ssl_version: !tls1.3
That is because, if we had such a signature and network traffic
with tls1.1, we were looking into DetectSslVersionData field
for tls1.1, which was not set, instead of looking at field
for tls1.3 which was set with negated flag.

Previous DetectSslVersionData was holding redundant information.
It did not need to have it for each ssl version, but just globally.
Also, it did not need to hold the version as a value in the array,
as it was redundant with the index of the array.

(cherry picked from commit c93e69830a)
4 months ago
Juliana Fajardini c2e82ece8b devguide: update backports policy for Suricata 7.0
Also remove mentions to `master` and `6.0x`.

Task #7937

(cherry picked from commit 6c06ab6144)
5 months ago