Commit Graph

1986 Commits (870a09cb7b0becd4ec31cbc1189e776cfb2415d6)

Author SHA1 Message Date
Philippe Antoine 7635d88589 ldap: abandon request does not wait for a response
Ticket: 8356

As such, abandon request is a complete tx

(cherry picked from commit 76d2925bdf)
1 month ago
Philippe Antoine 2d5172aaf3 http2: bound number of http2 frames per tx
Ticket: 8289

If stream.reassembly.depth is unlimited,
an attacker controlling the 2 sides of a communication going through Suricata
can send a transition with an infinite number of headers, until suricata OOMs

Solution is to offer a configuration option to bound the number
of HTTP2 frames we store in a HTTP2 transaction, and produce an
anomaly if this bound is crossed

(cherry picked from commit 784e173278)
1 month ago
Philippe Antoine aa12b193d3 smtp/mime: fix urls finding in buffering case
We used to look for a full line, but as we look fot the last eol
we need to use the right index in the not-reversed list

(cherry picked from commit 49fd7001ff)
1 month ago
Philippe Antoine 7a670e9b7a smtp/mime: avoid quadratic complexity in mime_smtp_find_url_strings
Ticket: 8292

When we have buffered something in ctx.decoded_line,
we already looked for '\n' in it, so we do not need to run it again

Otherwise, callers that supply mime_smtp_find_url_strings with
a few bytes at a time without "\n", have a quadratic
complexity

(cherry picked from commit 8bba47aa09)
1 month ago
Lukas Sismis 1d7e58209f misc: time unit parsing function
(cherry picked from commit 3e4fdb2118)
1 month ago
Jason Ish 7a67024a15 psl: update to 2.1.197
Update the Mozilla public suffix list to 2.1.197.

Ticket: #8194
1 month ago
Victor Julien 2a113d4ea8 detect/transforms: update gunzip / zlib_deflate syntax
Use standard space separated syntax.

(cherry picked from commit b55be5a44f)
2 months ago
Giuseppe Longo 46954cddf4 ldap: set invalid_data event
Currently in parse_request function LdapEvent::InvalidData is not set when a
request is not parsed correctly.

Ticket #8258

(cherry picked from commit de46f4ba9d)
2 months ago
Philippe Antoine 254ba73e65 detect/transforms: add zlib_deflate transform
Ticket: 7846
(cherry picked from commit 539e4ee665)
2 months ago
Philippe Antoine 609a289e46 detect/transforms: add gunzip transform
Ticket: 7846
(cherry picked from commit dbea660729)
2 months ago
Victor Julien 592b294afa krb5: fix TCP record parsing
A logic error in multi-record parsing meant only the first record was parsed.

Bug: #8278.
(cherry picked from commit 336a9d05ca)
2 months ago
Philippe Antoine f5c8a8fdb9 rust: fix unnecessary_unwrap warnings
warning: called `unwrap` on `rd.pipe` after checking its variant with `is_some`
   --> src/smb/smb1.rs:858:28
    |
857 |             if rd.pipe.is_some() {
    |             -------------------- help: try: `if let Some(<item>) = rd.pipe`
858 |                 let pipe = rd.pipe.unwrap();
    |                            ^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_unwrap
    = note: `#[warn(clippy::unnecessary_unwrap)]` on by default

(cherry picked from commit 02cb0f2ac2)
3 months ago
Philippe Antoine c6d9b573a0 nfs: log read/write/rename whatever the nfs version
These were previously logged correctly only for nfs v3

Now, the correct opcodes are used for v2 and v4 as well

Ticket: 8222
(cherry picked from commit 1832b50506)
3 months ago
Shivani Bhardwaj 89ce3f2565 tls/subjectaltname: use byte arr 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 "subjectaltname" 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 SAN with a byte
array.

Bug 7887

(cherry picked from commit 1d7b0d9b7a)
3 months ago
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
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
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 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
Philippe Antoine 0dddac7278 http: do not use recursion in decompression
just loop and iterate

Ticket: 8185
(cherry picked from commit f2a45c4216)
3 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
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
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
Jhonny Sousa 07c7f91094 nfs: Fix NFSv2 STATFS procedure parsing
Ticket: #5140
(cherry picked from commit 257ed82dbd)
5 months ago
Victor Julien 8d933536a8 pop3: AUTH command handling improvements
Better track the state so it's known when to expect a base64 request
message. Also better validate the base64.

Ticket: #7994.
(cherry picked from commit 80d5afe91b)
5 months ago
Philippe Antoine f1e1acfcb5 pop3: count retr_data into consumed
for later AppLayerResult::incomplete

Fixes: acef961645 ("pop3: improve parsing")

https://issues.oss-fuzz.com/u/1/issues/451112373

Ticket: 7994
(cherry picked from commit 3babd68af4)
5 months ago
Victor Julien 20f14726e3 pop3: improve parsing
Improve multiline commands and SASL auth.

Work around missing support in crate for empty server challenge and SASL base64 data.

Ticket: #7709.
(cherry picked from commit acef961645)
5 months ago
Jeff Lucovsky dc2faaa895 nfs: Support EXCLUSIVE4_1 flag
Issue: 8006

Support the EXCLUSIVE4_1 create mode added to NFS 4.1

(cherry picked from commit e1bf5cb1f3)
5 months ago
Shivani Bhardwaj 2cfc2f4dc0 version: start development towards 8.0.3 5 months ago
Shivani Bhardwaj 79db7b1ad4 release: 8.0.2; update changelog 6 months ago
Philippe Antoine 00f04daa3a htp: bound decompression
Ticket: 7980

Usage of Vec<u8> instead of Box<u8> gave the ability to callers
to grow the buffer (indefinitely)
This was regressed in 16fee33368

Additionnaly, use rust WriteZero instead of WouldBlock as a more
fitting error when cursor is full, as that error kind is the
one tested by callers.

(cherry picked from commit f2b6540c52)
6 months ago
Li Heng 002bd1f1ee snmp: can be set to detection-only
Realloc alp_ctx.ctxs when a dynamic alproto is registered and
g_alproto_max increases. So dynamic alproto can be treated as
real/normal ones. And app-layer switch can be set to any value
of no/deteciton-only/yes.

Ticket: 8000
(cherry picked from commit c141c55bc6)
6 months ago
Philippe Antoine 647bfad14d output/jsonbuilder: helper function SCJbSetPrintAsciiString
To replace C PrintStringsToBuffer and avoid a stack alloc
+ copy

Ticket: 8004
(cherry picked from commit 7447651fa0)
6 months ago
Jason Ish 35464150de ike: don't log duplicate attributes
Track what attributes have been logged and skip over duplicate
attributes to avoid having duplicate fields in the JSON object, which
is invalid JSON.

This is lossy, subsequent attributes are lost.

Ticket: #7923
6 months ago
Jason Ish 7e6084e44f ike/detect: info log message should be debug
(cherry picked from commit b543e28402)
6 months ago
Philippe Antoine 77057e1cd8 http2: add INTERNAL_ERROR for http2.error_code keyword 6 months ago
Philippe Antoine 77d5c7c324 http2: fix parsing of goaway frames
There was a last stream id before the error code
As per section 6.8 of RFC 7540

Ticket: 7991
(cherry picked from commit 9a4a29e218)
6 months ago
Philippe Antoine eef5794e5a mime: retain some stateful data for quoted-printable
In case a sequence like =3D is split over 2 calls to SCSmtpMimeParseLine

Ticket: 7950
(cherry picked from commit 56e08c9134)
7 months ago
Shivani Bhardwaj 0d65d35c92 version: start development towards 8.0.2 7 months ago
Jason Ish 2444feed0d release: 8.0.1; update changelog 7 months ago
Jason Ish 6d74656bef rust: respect RUSTC and CARGO env vars like CC
To support alternative cargo and rustc programs (such as cargo-1.82),
respect CARGO and RUSTC environment variables during ./configure much
like CC.

RUSTFMT is also respected as that is required for the tests, and Cargo
can't figure this out like it can for rustc (perhaps a bug in the
packaging).

For cbindgen, we have also have to make sure the cargo environment
variable is set for each invocation.

To build with Ubuntu's Rust 1.82 packaging:

  CARGO=cargo-1.82 RUSTC=rustc-1.82 RUSTDOC=rustdoc-1.82 \
      ./configure

Note that setting RUSTDOC is only required for commands like "make
check" to pass.

Ticket: #7877
8 months ago
Jason Ish db945aec83 rust: bindgen requires rustfmt
Bindgen will use rustfmt after generating the bindings, but this will
fail if rustfmt is not installed. Only run bindgen if rustfmt is
installed.
8 months ago
Jason Ish 4d4198dccc rust: update tracing-subscriber
Address https://rustsec.org/advisories/RUSTSEC-2025-0055.
8 months ago
Jason Ish 3b9dfe620d rust: pin time crate to 0.3.41
0.3.42 introduces dependencies that require Rust 1.81.
8 months ago