Commit Graph

2373 Commits (88d2f67a3b5cae367cb69c6aec3d9cb77e46dadd)

Author SHA1 Message Date
Jason Ish 991e7f3b1d ntp: add ntp.mode keyword
This keyword also accepts strings for known mode names.

Ticket: #8429
4 months ago
Jason Ish c10c482290 ntp: add ntp.stratum keyword
Ticket: #8431
4 months ago
Jason Ish ec344fe68d ntp: add ntp.version keyword
SNMP was used as a template.

Ticket: #8430
4 months ago
Jason Ish 74bb525401 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
4 months ago
Jason Ish 879846e153 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.
4 months ago
Jason Ish 31b967b089 ntp: add transaction logging
Adds basic NTP transaction logging for the current supported message
types.

Includes small cleanups around reference ID.

Ticket: #8425
4 months ago
Victor Julien c7cd3b17c3 snmp: minor snmp.pdu_type type cleanup 4 months ago
Victor Julien 2cef1404bc detect/snmp: let generic keyword share the same list 4 months ago
Victor Julien 670fdabd32 detect/snmp: add snmp.trap_type keyword
Implemented as a U8 integer keyword.

Ticket: #8482.
4 months ago
Philippe Antoine 8ac9a62ec4 detect: enable snmp keywords for firewall mode
Ticket: #8395
4 months ago
Philippe Antoine 63603fe14a 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
4 months ago
Philippe Antoine 8f824458c2 detect: helper for buffer register requires progress
Ticket: 8395

For protocols where tx are complete at start, that is
the `tx_get_progress` function returns 1 inconditionnally,
we can use the progress 1, not losing time on detection in ips
mode, and getting ready for firewall mode

For the other protocols (where a tx needs both a request and response
for instance), keep progress 0 as was the case before
4 months ago
Jason Ish eb46d0129e rust/ffi: add eve callback handler
Wrap the EVE callback handler with a Rust friendly variant that allows
the user to register a callback as a closure which is provided an
already wrapped JsonBuilder object.

Ticket: #8477
4 months ago
Jason Ish 199e844a07 rust/ffi: add mark support to ffi::jsonbuilder
To support Rust friendly EVE callback registration (ticket 8477).
4 months ago
Philippe Antoine 58a71d94b0 rust/ffi: move conf_get helper to ffi crate
Ticket: 7666
4 months ago
Philippe Antoine 8d254f5630 dhcp/output: log app-layer metadata in alerts
Ticket: 6091

log as extended
4 months ago
Philippe Antoine db980daf5f dhcp: standardize output code
To prepare to add metadata in alerts

Ticket: 6091
4 months ago
Philippe Antoine d14af54b3b detect/transforms: constify some callbacks arguments
Ticket: 8298
4 months ago
Philippe Antoine 0a24f0afe2 smb: parse smb1 session setup with word count 13
Ticket: 5845
4 months ago
Jason Ish 98469b0f56 rust/ffi: fix clippy warnings
Remove the unneeded return.

The other option would be to allow it, but so far in the ffi crate we
don't have any non-default allows.
4 months ago
Philippe Antoine c53b9df5a2 rust/ffi: move detection helpers to ffi crate
Ticket: 7666
4 months ago
Philippe Antoine 4f4912c042 rust: bindgen SIGMATCH_ constants 4 months ago
Philippe Antoine 2fa10052cf 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.
4 months ago
Philippe Antoine 7b0528d85f http2: set response_frame_size
Ticket: 8410

Do not set only request_frame_size whatever the direction
4 months ago
Philippe Antoine 267c3baff7 rust/ffi: move STREAM_ constants to ffi crate
Ticket: 7666

reexport them in suricata crate
cbindgen them to C
4 months ago
Philippe Antoine 61c667400b rust: remove obsolete inclusions from cbindgen.toml 4 months ago
Philippe Antoine fd4c6d4e06 rust: remove obsolete struct exclusions in cbindgen
As these structs are now in suricata_sys crate
4 months ago
Philippe Antoine a10a818792 rust: remove obsolete constants exclusion from cbindgen.toml
Completes commit 71b59f6dbe

These const are no longer defined in rust suricata crate
4 months ago
Jason Ish dce2deee5e rust: pin unicode-segmentation crate to 1.12.0
unicode-segmentation (used by rustyline) was updated from 1.12.0 to
1.13.1 earlier and requires a newer version of Rust. Pin to 1.12.0 which
works with Rust 1.75.0.
4 months ago
Philippe Antoine 34ed8958a6 dcerpc: only log the tx interfaces
Not all the state ones

Ticket: 8378
4 months ago
Philippe Antoine 05a11e2897 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
4 months ago
Jason Ish 9cab99fbd3 rust: rust fmt derive crate 5 months ago
Jeff Lucovsky 14ebba6382 gen/unused: Remove unused function
Remove unused function is_alphanumeric_or_slash
5 months ago
Jeff Lucovsky 98070a7ace misc/cleanup: remove rust if <cond> ....
Cleanup the few instances of rust where if cond return true else false
exist

rg = ripgrep

rg -n -U '^\s*if .* \{\s*\n\s*return true;\s*\n\s*\}\s*\n\s*return false;' rust/src/ --glob '*.rs'

rg -n -U '^\s*if .* \{\s*\n\s*return false;\s*\n\s*\}\s*\n\s*return true;' rust/src/ --glob '*.rs'
5 months ago
Philippe Antoine 6587e363a3 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
5 months ago
Philippe Antoine 2c2a3c800f 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
5 months ago
Philippe Antoine db51314478 rust: rustfmt dcerpc.rs 5 months ago
Philippe Antoine 55ad2953bf dcerpc: do not error the whole flow on unhandled packet type
Ticket: 5133
5 months ago
Jason Ish e9f8e17b16 rust/Makefile: add RUSTC and RUSTDOC to CARGO_ENV
And consistently use the CARGO_ENV for all cargo calls.

This allows a user to point to rust binaries that are not on their
path just during ./configure, for example:

  PATH=/usr/lib/rust-1.89/bin:$PATH ./configure ...

The full path to rustc and rustdoc will now be used, as discovered in
the PATH without the user have to carry the path over to the "make"
command. This was already done for cargo.

Related to ticket: #8381
5 months ago
Philippe Antoine ebe0ba4ebb rust: limit clap verson to 4.5.57
clap 4.5.58 and further requires edition2024 which is incompatible with MSRV
5 months ago
Philippe Antoine 76d2925bdf ldap: abandon request does not wait for a response
Ticket: 8356

As such, abandon request is a complete tx
5 months ago
Philippe Antoine 784e173278 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
5 months ago
Philippe Antoine 49fd7001ff 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
5 months ago
Philippe Antoine 8bba47aa09 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
5 months ago
Philippe Antoine 062f56ddde detect/http2: use ThreadCtx for all headers keywords
Instead of custom inefficient "escaped" Vec

Ticket: 8291
5 months ago
Philippe Antoine 4e538dfa3b detect/http2: use ThreadCtx for http.request_header
And also for http.response_header

Instead of custom inefficient "escaped" Vec

Ticket: 8291
5 months ago
Philippe Antoine 0933e944df detect/http2: use ThreadCtx for http.header.raw
Instead of custom inefficient "escaped" Vec

Ticket: 8291
5 months ago
Philippe Antoine 711de8a5ea detect/http2: use ThreadCtx for http.header
Instead of custom inefficient "escaped" Vec

Ticket: 8291
5 months ago
Philippe Antoine 52a2f2dd19 detect/http2: use ThreadCtx for http.header_names
Instead of custom inefficient "escaped" Vec

Ticket: 8291
5 months ago
Jason Ish 648a867049 psl: update to 2.1.197
Update the Mozilla public suffix list to 2.1.197.
5 months ago
Philippe Antoine 8e886a8ecd krb5: use app-layer incomplete support
Ticket: 3540
Ticket: 8305
5 months ago
Philippe Antoine d77c43c79b rust/ffi: move build_slice macro to ffi crate
Ticket: 7666
5 months ago
Philippe Antoine 4a0143c8d4 rust/ffi: move cast_pointer macro to ffi crate
Ticket: 7666
5 months ago
Shivani Bhardwaj d241237c0f Revert "dcerpc: fix consumed bytes post gap handling"
This reverts commit fc9da1c7a1.

That commit incorrectly used consumed as index of the slice passed to
the Frame API.
Found by oss-fuzz.
5 months ago
Jeff Lucovsky ed882ede68 output/ipv6: Utility function to compress IPv6 addrs
Issue: 7399

Utility function to compress IPv6 addresses per RFC-5952
5 months ago
Giuseppe Longo de46f4ba9d ldap: set invalid_data event
Currently in parse_request function LdapEvent::InvalidData is not set when a
request is not parsed correctly.

Ticket #8258
5 months ago
Victor Julien b55be5a44f detect/transforms: update gunzip / zlib_deflate syntax
Use standard space separated syntax.
5 months ago
Philippe Antoine 71b59f6dbe rust/ffi: move IPPROTO_TCP to ffi
and reexport in suricata

Allows to reduce dependencies to full suricata crate

Ticket: 7666
5 months ago
Philippe Antoine d5ea973791 detect/ike: move ike.ike.chosen_sa_attribute keyword to rust
Ticket: 8310

And increases expressivity on the way by supporting other modes
than equality
6 months ago
Philippe Antoine 55333a6ca0 detect/ike: move ike.vendor keyword to rust
Ticket: 8310
6 months ago
Philippe Antoine 14edd66494 detect/ike: move ike.nonce_payload keyword to rust
Ticket: 8310
6 months ago
Philippe Antoine d1213e4440 detect/ike: move ike.key_exchange_payload keyword to rust
Ticket: 8310
6 months ago
Philippe Antoine f23169c924 detect/ike: move ike.nonce_payload_length keyword to rust
Ticket: 8310
6 months ago
Philippe Antoine e85bf5be4d detect/ike: move ike.key_exchange_payload_length keyword to rust
Ticket: 8310
6 months ago
Philippe Antoine 841fe44f34 detect/ike: move ike.exchtype keyword to rust
Ticket: 8310
6 months ago
Philippe Antoine 23032ebc65 detect/ike: move ike spi keywords to rust
Ticket: 8310
6 months ago
Philippe Antoine 539e4ee665 detect/transforms: add zlib_deflate transform
Ticket: 7846
6 months ago
Philippe Antoine dbea660729 detect/transforms: add gunzip transform
Ticket: 7846
6 months ago
Victor Julien 336a9d05ca krb5: fix TCP record parsing
A logic error in multi-record parsing meant only the first record was parsed.

Bug: #8278.
6 months ago
Jason Ish 6b850dddb8 rust/ffi: JsonBuilder wrapper around C JsonBuilder API
For use by plugins that need to work with JsonBuilder.
6 months ago
Jason Ish f6b11ac855 output-eve: finish exposing to bindgen
As all out output-eve.h is now exposed, merge output-eve.h and
output-eve-bindgen.h back into one file, output-eve.h.
6 months ago
Jason Ish f79158ae55 rust/sys: generate jsonbuilder bindings in sys
Bindgen the Rust bindings to the C JsonBuilder API along with the rest
of the Rust bindings to C. Breaking it out was probably the wrong
idea.

This should make it easier, and more correct to bindgen C functions
that use SCJsonBuilder types.
6 months ago
Jason Ish f951477461 rust/debug: use functions from ffi crate where possible
It's not possible to use all the functions and macros from the ffi crate
in the main Suricata crate, as there are conditionals around when
running in test mode, and "cargo test" doesn't propagate the "cfg(test)"
to test crates.

Which for now means duplicating the macros and some functions.
6 months ago
Jason Ish 8b69089cb8 rust/ffi: more rust friendly plugin registration
A plugin can now create a "Plugin" struct with Rust strings.  The
`into_raw` method converts it to a raw pointer suitable for returning
during plugin registration.
6 months ago
Jason Ish 0999530726 rust/ffi: rust wrapper around eve filetype registration 6 months ago
Jason Ish 2d0bf9a2ed output-eve: bindgen SCEveFileType callback types 6 months ago
Jason Ish b4db7bdaee rust/ffi: add logging (debug) wrappers
Mostly a copy of Suricata core's logging wrappers into the ffi crate.

These are not yet used by Suricata-core as they do require the
Suricata library to be available, which is not the case with tests. And
the `cfg(test)` parameter is not passed through to sub-crates.

However, this does allow a plugin (or library) to call the logging
macros without depending on the "suricata" crate.

Ticket: #7666
6 months ago
Jason Ish 2c51744ccc rust/ffi: stub out a rust ffi crate
This crate is for Rust wrappers around the -sys crate which includes
only raw bindings. This is the place to add nice wrappers around those
bindings, however it should remain clear of dependencies on the main
Suricata core crates.

Ticket: #7666
6 months ago
Jason Ish e9611a4d7c output-eve: bindgen SCRegisterEveFileType to Rust
Used by Rust output plugins.
6 months ago
Jason Ish 1b182025bc output-eve: expose SCEveFileType to Rust with bindgen
There is an unfortunate side-affect that one has to read
output-eve-bindgen.h for the documentation on this type, however, I
think we can resolve that in time.
6 months ago
Philippe Antoine 536242341b detect/smb: move smb.version keyword to rust
Ticket: 8267
6 months ago
Philippe Antoine df495d7e22 rust: bindgen SCDetectGetLastSMFromLists
to use it from rust keywords
6 months ago
Philippe Antoine 697c641400 detect/smb: move smb share and named_pipe keywords to rust
Ticket: 8267
6 months ago
Philippe Antoine 667f8b2eb7 detect/smb: move smb ntlmssp keywords to rust
Ticket: 8267
6 months ago
Victor Julien a2e9ac21f8 flow: turn flags field into uint64_t
Entire space is used.
6 months ago
Jason Ish b0c912588c mqtt/detect: fix mqtt_parse_bool return type
Previously we were boxing a u8 and returning it as a pointer to a
boolean. While this is probably not an issue itself, the value 2 was
allowed to be converted to a boolean, which is undefined behavior in
Rust.
6 months ago
Jason Ish b9e0f9cc8b rfb/detect: fix rfb_parse_sec_result return type
The data parsed is a u32, but returned as DetectUintData<u8>, then
later free'd as a DetectUintData<u32>.
6 months ago
Jason Ish 8b2a7ac47c nfs/detect: fix nfs_procedure_parse return type
Was returning DetectNfsProcedureData as a pointer to
DetectUintData<u32>, and free'ing it as such.
6 months ago
Jason Ish e474e45429 dns/detect: fix rcode return type
The parsed DNS rcode was being returned as a DetectUintData<u8>, but is
parsed, and free'd as a u16. So return a DetectUintData<u16>.
6 months ago
Jason Ish c7f806a728 rust/sys: allow unknown lints
allow(unpredictable_function_pointer_comparisons) is needed on newer
versions of Rust, but is unknown to our MSRV, so for now, allow unknown
lints.
6 months ago
Philippe Antoine 364d2c077d rust: bindgen SCAppLayerRegisterParser
Ticket: 7662
6 months ago
Philippe Antoine 8401417a84 app-layer: remove some obsolete forward declarations
and reorder definitions
6 months ago
Philippe Antoine 8857b78f6a rust: move AppLayerTxData definition to C
and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerTxData

Move also the free function to C SCAppLayerTxDataCleanup
As suricata-sys crate defines AppLayerTxData for rust,
It must itself implement the Drop trait, and thus,
We need to define a feature surest
6 months ago
Philippe Antoine 8eaced3c1e rust: move AppLayerResult definition to C
and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerResult

Keep From<> impl in sys crate that defines it
6 months ago
Philippe Antoine 06f78b2a22 rust: move StreamSlice definition to C
and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses StreamSlice
6 months ago
Philippe Antoine 41f543ca35 rust: move AppLayerGetTxIterTuple definition to C
and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerGetTxIterTuple
6 months ago
Philippe Antoine 64d29fcd1c rust: move AppLayerStateData definition to C
and bindgen it to rust, and use default trait instead of new

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerStateData
6 months ago
Philippe Antoine 76efb8af4d rust: move AppLayerGetFileState definition to C
and bindgen it to rust.

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerGetFileState
6 months ago
Philippe Antoine fc23e54c6d rust: bindgen with derive eq
As will be needed such as AppLayerTxData
6 months ago
Shivani Bhardwaj d4008a6508 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
6 months ago
Shivani Bhardwaj ed1bd8624e dcerpc: use fraglen from header
So far, the fraglen defined in the header was used inconsistently in
certain places to define bounds on input length. Make it consistent by
making sure that only a slice up until fraglen is passed around as that
is the maximum length the fragment should have.
With the help of Applayer::incomplete API, the case when the
stream_slice passed to the parser is smaller than the header defined
fraglen is already handled.

Bug 7546
6 months ago
Shivani Bhardwaj fc9da1c7a1 dcerpc: fix consumed bytes post gap handling
The parser could receive an input that consists of arbitrary data post
gap. This is handled in the beginning of the fn handle_input_data.
However, the rest of the calculation does not take into account the
bytes that were consumed at this stage. Fix the indices and calculations
to consider a new DCERPC fragment beginning post these consumed bytes.
6 months ago
Philippe Antoine 9a52bbcbe9 detect/quic: move quic.cyu.hash to rust
Ticket: 8255
6 months ago
Philippe Antoine 01610aabe7 detect/quic: move quic.cyu.string to rust
Ticket: 8255
6 months ago
Philippe Antoine ee4d4a14d5 detect/quic: move quic.ua to rust
Ticket: 8255
6 months ago
Philippe Antoine 9ba9fdcb87 detect/quic: move quic.sni to rust
Ticket: 8255
6 months ago
Philippe Antoine 907e71a984 detect/quic: move quic.version to rust
Ticket: 8255
6 months ago
Philippe Antoine 7dbe033ae0 app-layer: function to register ci pattern + probe
Ticket: 6591
6 months ago
Philippe Antoine 2cf9a327d5 detect/ssh: move ssh.hassh to rust
Introduces helper SCDetectRegisterBufferLowerMd5Callbacks
6 months ago
Philippe Antoine 83360cfce0 detect/ssh: move ssh.hassh string to rust
bindgen needed SCSigMatchSilentErrorEnabled on the way
6 months ago
Philippe Antoine 02cb0f2ac2 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
6 months ago
Philippe Antoine cafc398355 dcerpc: consume bytes after gap resync
Ticket: 7567

Re-applies commit 8c3bd3e8a0
which was reverted in f64aec9d11
6 months ago
Philippe Antoine 54cc752cf9 ssh: hassh can be truly disabled
Rules will not re-enable it

Ticket: 8223
7 months ago
Philippe Antoine 458211dcf2 detect/ssh: move ssh.proto to rust 7 months ago
Philippe Antoine 9cfc1cc557 detect/ssh: move obsolete keywords to rust 7 months ago
Philippe Antoine ea8ac2a02a detect/ssh: move ssh.software to rust
Adds helper function SCDetectHelperBufferProgressMpmRegister on the way
7 months ago
Philippe Antoine c0d6747e82 app-layer: GetTxIteratorFn uses a AppLayerGetTxIterState
Even if every current rust parser uses the u64 variant of the C union
7 months ago
Philippe Antoine 4b541b39f2 rust: move AppLayerEventType definition to C
and bindgen it to rust.

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerEventType
7 months ago
Philippe Antoine c960b7d7c1 app-layer: AppLayerParserFPtr uses a mut pointer to local storage
So, fix the fn prototype in rust ParseFn
7 months ago
Philippe Antoine f470ee448b quic: use standard tx iterator code
Will make bindgen life easier

As the fn prototype should not have istate: &mut u64
but a *mut AppLayerGetTxIterState which is an union with a u64
7 months ago
Philippe Antoine 076fcd61cd bittorrent: use standard tx iterator code
Will make bindgen life easier

As the fn prototype should not have istate: &mut u64
but a *mut AppLayerGetTxIterState which is an union with a u64
7 months ago
Philippe Antoine 1a546936c7 rust: AppLayerTxConfig uses Default impl 7 months ago
Philippe Antoine 4e64de3b3b rust: remove wrapper LoggerFlags struct definition
just use an u32 out of the box.
Will make bindgen like easier
7 months ago
Philippe Antoine f663be5983 rust: define every RustParser fn pointer unsafe
That is what bindgen will do
7 months ago
Lukas Sismis 3e4fdb2118 misc: time unit parsing function 7 months ago
Philippe Antoine 5bb9a0c3af dcerpc/tcp: fix fragmentation handling
Really count the fragments, and set it done when last was received
7 months ago
Philippe Antoine f64aec9d11 dcerpc: use different header for different directions
Header handling is wrong in the case
packet A to server is fragmented (return AppLayerResult::incomplete)
packet B is to client, but uses the header of the to_server packet

Bug 7547
7 months ago
Philippe Antoine 1832b50506 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
7 months ago
Philippe Antoine b0850efd67 rust: from_str implementation for EncryptionHandling
To move non-specific quic code to the right place
7 months ago
Philippe Antoine 89b6ab6730 rust: rename EncryptionHandling
as it is no longer specific to SSH
7 months ago
Philippe Antoine 7acfea57a9 rust: move EncryptionHandling definition to its own file
as it is not specific to ssh anymore
7 months ago
Philippe Antoine 7422c97bf2 quic: encryption-handling config parameters
Ticket: 8116
7 months ago
Victor Julien ff3def130c rust/htp: formatting fixup 7 months ago
Victor Julien b1fe6a4ceb rust: update lru to 0.16.3; update lock
RUSTSEC-2026-0002

Ticket: #8210.
7 months ago
Philippe Antoine a48200b9e5 dcerpc: use saturating_add to count fragments
And do not overflow if we have traffic with more than 65K fragments
7 months ago
Shivani Bhardwaj e412215af9 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>
7 months ago
Philippe Antoine fa5a4a994a 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
7 months ago
Philippe Antoine f2a45c4216 http: do not use recursion in decompression
just loop and iterate

Ticket: 8185
7 months ago
Shivani Bhardwaj 1d7b0d9b7a 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
7 months ago
Shivani Bhardwaj 24f5b7dab2 tls/serial: use byte array instead of string
Bug 7887
7 months ago
Shivani Bhardwaj f025e07191 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
7 months ago
Shivani Bhardwaj 77c21b05d2 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
7 months ago
Shivani Bhardwaj 06eafb79d6 detect/flow-pkts: check for both dir
The functionality of "both" can already be easily achieved by using both
"toclient" and "toserver" in a rule. This just adds the ease of
expression in rule. As it is added now, check the direction for the
pre-existing users of direction as well.
7 months ago
Shivani Bhardwaj 77abcde9ee rust/flow: add public wrapper for dir
in order to be able to use it on the C side for elephant flow detection.
7 months ago
Jason Ish d89b35db56 conf: add SCConfNodeChildValueIsFalse to check for false value
New function to check is a value is actually set to a false value.
8 months ago
Philippe Antoine af246ae7ab 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.
8 months ago
Jeff Lucovsky 9c81f817e8 rust: bindgen update
Issue: 7389

Update bindgen with `make update-bindgen`
8 months ago
Jason Ish 50224f2ee5 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.
8 months ago
Philippe Antoine 455b7d1b3b rust: use snake case for applayer_register_protocol_detection 8 months ago
Philippe Antoine b4d8aea0ae rust: bindgen SCAppLayerRegisterProtocolDetection
Ticket: 7662

Changing the struct passed to it to have the minimal number
of useful fields.
8 months ago
Philippe Antoine 1329786f84 detect: new command line option : list-rule-protos
To list the protocols we can use a in a rule header

Ticket: 635
8 months ago
Philippe Antoine 2349f19977 nfs: use nfsv2 procedure names with nfs_procedure keyword
Ticket: 5140
8 months ago
Jhonny Sousa 257ed82dbd nfs: Fix NFSv2 STATFS procedure parsing
Ticket: #5140
8 months ago
Philippe Antoine 15b1bf4865 rust: bindgen SCHTPFileCloseHandleRange
Ticket: 7762
8 months ago
Philippe Antoine cddbd0b906 rust: bindgen more file functions
Ticket: 7762
8 months ago
Philippe Antoine 327b8b04a9 rust: bindgen with default derive
Ticket: 7762
8 months ago
Victor Julien 80d5afe91b 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.
8 months ago
Victor Julien 2973eded56 pop3: convert to nom 8
Ticket: #8127.
8 months ago
Victor Julien da2db65f62 pop3: rustfmt 8 months ago
Jason Ish 83d8b1d2f8 quic: update to nom 8.0
Ticket: #8140
8 months ago
Philippe Antoine 32ce3d29be detect/krb: use flag u32 for krb5_msg_type 9 months ago
Jason Ish a9eee5dfd9 rust/htp: convert to nom 8
Ticket: #8090
9 months ago
Jason Ish ef9cd7beff rust/smb: convert to nom 8
Ticket: #8089
9 months ago
Jason Ish 02045e1d62 rust/dcerpc: convert to nom 8
Ticket: #8093
9 months ago
Jason Ish 25c98af0e8 rust/detect: convert remaining detection rule parsers to nom 8
Ticket: #8051
9 months ago
Jason Ish dea3f9e260 rust/detect: convert error.rs and dependent parsers to nom 8
Ticket: #8051
9 months ago
Jason Ish efc32dea41 rust/detect: convert uint nom 8
And users of uint directly impacted by this change.

Ticket: #8051
9 months ago
Jason Ish cf604751de rust/util: convert to nom 8
Ticket: #8088
9 months ago
Jason Ish 1e01d5adca rust/conf: convert to nom 8
Ticket: #8087
9 months ago
Jason Ish c6e8932740 rust/asn1: convert to nom 8
Ticket: #8086
9 months ago
Jason Ish 59f8fb30a8 rust/ftp: fix clippy warning
error: implicitly casting the result of `from_raw_parts_mut` to `*mut [u8]`
        --> src/ftp/response.rs:107:31
9 months ago
Philippe Antoine cba13ed9b1 rust: bindgen functions needed for datasets
Ticket: 7762
9 months ago
Philippe Antoine 12892ba010 rust: bindgen functions neede for features
Ticket: 7762
9 months ago
Jeff Lucovsky e1bf5cb1f3 nfs: Support EXCLUSIVE4_1 flag
Issue: 8006

Support the EXCLUSIVE4_1 create mode added to NFS 4.1
9 months ago
Philippe Antoine 79e66f76e6 detect: icmp_id is now a generic integer
Ticket: 7889
9 months ago
Philippe Antoine 85fa894425 detect: dnp3.func is now a generic integer
Ticket: 7889
9 months ago
Philippe Antoine f2b6540c52 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.
9 months ago
Philippe Antoine c61f1cb6d0 detect/integers: rename index all1 to all
And all to all_or_absent

Ticket: 7929
9 months ago
Philippe Antoine eb5a2d646b detect/vlan: move vlan.id keyword to generic integer
Ticket: 7929
9 months ago
Li Heng c141c55bc6 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
9 months ago
Philippe Antoine 439f96dea7 rust: bindgen frames functions
Ticket: 7667
9 months ago
Philippe Antoine 92c7be1cb6 rust: bindgen SCSRepCatGetByShortname
Ticket: 7667
9 months ago
Philippe Antoine 7447651fa0 output/jsonbuilder: helper function SCJbSetPrintAsciiString
To replace C PrintStringsToBuffer and avoid a stack alloc
+ copy

Ticket: 8004
9 months ago
Li Heng 1106323ae1 rust/sip: delete redundant computing codes
Delete call of is_alphanumeric where is_alphanumeric and
is_token_char are called together. Four places are modified.

Ticket: 8003
9 months ago
Jason Ish 1efe70a234 rust/ike: convert to nom 8
Ticket: #8050
9 months ago
Jason Ish f368324e87 rust/mime: convert to nom 8
Ticket: #8048
9 months ago
Jason Ish c5ef615953 rust/mqtt: convert to nom 8
Ticket: #8047
9 months ago
Jason Ish 2289069f74 rust/websocket: convert to nom 8
Ticket: #8046
9 months ago
Jason Ish 9eeefd0684 rust/bt-dht: convert to nom 8
Ticket: #8045
9 months ago
Jason Ish 399f96b07d rust/rdp: convert to nom 8
Ticket: #8044
9 months ago
Jason Ish 7c70f74942 rust/telnet: convert to nom 8
Ticket: #8043
9 months ago
Jason Ish 2ff2eb1325 rust/ssh: convert to nom 8
Ticket: #8042
9 months ago
Jason Ish baa22287b8 rust/rfb: convert to nom 8
Ticket: #8041
9 months ago
Jason Ish dcfe247467 rust/pgsql: convert to nom 8
Ticket: #8039
9 months ago
Jason Ish d25286e77a rust/enip: convert to nom 8
Ticket: #8038
9 months ago
Jason Ish d74f8522ee rust/tftp: convert to nom 8
Ticket: #8037
9 months ago
Jason Ish 4b09622ebc rust/dhcp: convert to nom 8
Ticket: #8036
9 months ago
Philippe Antoine 772bd9ca53 rust: reduce visibility of detect_parse_uint_notending
It is meant as an internal function

Also document the function
9 months ago
Philippe Antoine b636dffd5b detect: urilen keyword fails on trailing junk
Fails especailly on 1<>2 which looks like a range, but is invalid
as too small, and ended up being accepted as =1

Ticket: 8028
9 months ago
Philippe Antoine 2e9027fd5a plugins: update SC_API_VERSION to 9
So that plugins built for 8 will fail to load with 9 as there
were already breaking changes in the structures and functions
prototypes
9 months ago