Commit Graph

2002 Commits (f53a5d3b7a086fe4c11c193d0feb0da4a280acb8)

Author SHA1 Message Date
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)
3 weeks 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)
3 weeks ago
Philippe Antoine 831be60a57 dcerpc: only log the tx interfaces
Not all the state ones

Ticket: 8378
(cherry picked from commit 34ed8958a6)
4 weeks 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)
4 weeks 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)
4 weeks 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)
4 weeks 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)
4 weeks ago
Philippe Antoine 8e14f4872d dcerpc: do not error the whole flow on unhandled packet type
Ticket: 5133
(cherry picked from commit 55ad2953bf)
4 weeks ago
Shivani Bhardwaj 885a28f62a version: start development towards 8.0.5 1 month ago
Juliana Fajardini 6af634b19b release: 8.0.4; update changelog 1 month ago
Philippe Antoine 6484a012a3 detect/http2: use ThreadCtx for all headers keywords
Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 062f56ddde)
1 month ago
Philippe Antoine 029cc968c8 detect/http2: use ThreadCtx for http.request_header
And also for http.response_header

Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 4e538dfa3b)
1 month ago
Philippe Antoine 7b77edfa69 detect/http2: use ThreadCtx for http.header.raw
Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 0933e944df)
1 month ago
Philippe Antoine c0efcf559d detect/http2: use ThreadCtx for http.header
Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 711de8a5ea)
1 month ago
Philippe Antoine 94e5b1c90b detect/http2: use ThreadCtx for http.header_names
Instead of custom inefficient "escaped" Vec

Ticket: 8291
(cherry picked from commit 52a2f2dd19)
1 month ago
Philippe Antoine 1193019d3a krb5: use app-layer incomplete support
Ticket: 3540
Ticket: 8305
(cherry picked from commit 8e886a8ecd)
1 month ago
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