Commit Graph

2343 Commits (e08a19a88ae5ce2962f87f7b2492807099e0b76a)

Author SHA1 Message Date
Philippe Antoine e08a19a88a detect/enip: cip_class and cip_instance are now a multi-integer
Ticket: 7929

One commit as they share the same code
1 month ago
Philippe Antoine 0bdfe3f571 detect/enip: cip_attribute keyword is now a multi-integer
Ticket: 7929
1 month ago
Jeff Lucovsky 5af13e3eb0 rdp: mark transactions single-directional
Mark the direction into RDP transactions at creation time,
so the tx carries SKIP_INSPECT for the direction it is
never seen in, matching DHCP and the other single-direction
parsers. This lets cleanup free completed transactions and
stops a tx from being inspected (and alerting) twice, once per
direction.

RDP bounds its transactions to connection setup and stops
parsing once bypass_parsing is set.

Issue: 8621
1 month ago
Jeff Lucovsky 3f86c56c80 dhcp: mark transactions single-directional to fix tx leak
DHCP is a stateless parser where each datagram is its own standalone,
single-direction transaction. It was creating transactions with
AppLayerTxData::new(), which leaves both SKIP_INSPECT bits clear, so the
engine treats every tx as still needing inspection in both directions.

For a flow that only ever carries one direction (broadcast DHCP, or a
relay seeing one side), the never-observed direction's inspect bit can
never be set, so AppLayerParserTransactionsCleanup() never frees the tx.
The per-flow transaction Vec then grows without bound and every packet
re-scans the whole list, giving O(n^2) CPU and unbounded memory on a
busy DHCP aggregation point.

Use AppLayerTxData::for_direction() like every other stateless parser
(DNS, SNMP, NTP, IKE, KRB5, MQTT, QUIC, SIP, WebSocket, bittorrent-dht)
so the tx carries SKIP_INSPECT for the direction it will never be seen
in. This lets cleanup free completed transactions and also stops the tx
from being inspected (and alerting) twice, once per direction.

Issue: 8621
1 month ago
Philippe Antoine a81031591e detect/krb5: move krb5.ticket_encryption to rust
Ticket: 8648
1 month ago
Philippe Antoine 8f0dbc0b63 detect/krb5: move krb5.cname and krb5.sname to rust
Ticket: 8648
1 month ago
Philippe Antoine 3327cf42f0 detect/krb5: move krb5_err_code to rust
Ticket: 8648

Make it a generic integer on the way
1 month ago
Jason Ish 5856ced29c ftp: support LIST and MLSD data channels
Support LIST and MLSD on the ftp data channel.

Ticket: #8664
1 month ago
Philippe Antoine 89dbce1b46 detect: convert tx_progress to uint8_t 1 month ago
Philippe Antoine 52490b8c26 ftp: do not error the flow on file before port
Ticket: 8659

If a client sends a SOTR/RETR command before doing a PASV/PORT
command, ther server may reply
425 Use PORT or PASV first.\r\n
and allow the client to continue sendinf other commands

So, Suricata should not put the whole flow into error, it just
sets an event, and continues to parse further
2 months ago
Jeff Lucovsky 5d007ef25e detect/xor: add inline variable key syntax
Extend the xor transform to accept a variable-position key using
the 'extract <nbytes> <offset>' syntax. The engine reads <nbytes> bytes
at buffer position <offset> at transform time.

The optional 'offset' parameter specifies where XOR decoding
starts in the buffer; bytes before that position are left unchanged.

Syntax:
  xor:"<hex_key>"
  xor:extract <nbytes> <offset>
  xor:offset <N>,"<hex_key>"
  xor:offset <N>,extract <nbytes> <offset>

Variable-key helpers (VariableKeyLocation, variable_key_bytes,
parse_key_location, strip_keyword_prefix) are imported from the new
varkey module.

The variable key bytes are copied out of the inspection buffer before
decoding, so an in-place transform cannot corrupt the key when the key
region overlaps the decoded range.

Issue: 8671
2 months ago
Jeff Lucovsky 385bd4416b detect/transforms: add varkey module for variable-key helpers
Introduce rust/src/detect/transforms/varkey.rs to centralise helpers
used by transforms that read key material directly from the inspection
buffer at transform time.

Exported items:
  VariableKeyLocation  { offset: u16, nbytes: u8 }
  variable_key_bytes   bounds-checked slice into an inspection buffer
  strip_keyword_prefix strip 'keyword<ws>' from option strings
  parse_key_location   parse '<nbytes> <offset>' into VariableKeyLocation

All four items are pub so any transform can import them. Unit tests
are included in the module.

Issue: 8671
2 months ago
Philippe Antoine e6ee69c7da rust: format all files
except the ones with #[rustfmt::skip]

Ticket: 3836
2 months ago
Philippe Antoine ca34fba00c rust: format smb files
Ticket: 3836
2 months ago
Philippe Antoine f8ac56c591 dcerpc: remove obsolete comment 2 months ago
Philippe Antoine aea9fd73b7 rust: format dcerpc files
Ticket: 3836
2 months ago
Philippe Antoine c6014a77a2 websocket: accepts config value with units
Ticket: 8552

As was the commented out example
2 months ago
Philippe Antoine a9e1dff4a6 conf: introduce SCConfGetNonNull
Ticket: 8651

Behaves like SCConfGet but returns 0 on null value
2 months ago
Philippe Antoine e0152178da rust: format detect files
Ticket: 3836
2 months ago
Giuseppe Longo 695b4f4a3d sip: remove incomplete data event
It's no longer useful to set an event when the data is incomplete,
since an error is returned.

Ticket #8524
2 months ago
Giuseppe Longo ba5e850264 sip: make pattern matching more robust
SIP and SSDP share method names like NOTIFY and SUBSCRIBE,
causing SSDP traffic to be misidentified as SIP.
Add a probing parser callback that checks for "SIP/" in the
payload before accepting a pattern match.

Example of a misidentified flow before the fix:
{"timestamp":"2014-02-27T19:44:43.164211+0100","flow_id":986757542077835,"event_type":"flow","src_ip":"192.168.1.1","src_port":9489,"dest_ip":"239.255.255.250
","dest_port":1900,"ip_v":4,"proto":"UDP","app_proto":"sip","flow":{"..."}}

After the fix:
{"timestamp":"2014-02-27T19:44:43.164211+0100","flow_id":986757542077835,"event_type":"flow","src_ip":"192.168.1.1","src_port":9489,"dest_ip":"239.255.255.250
","dest_port":1900,"ip_v":4,"proto":"UDP","app_proto":"failed","flow":{"..."}}

Ticket #8355
2 months ago
Shivani Bhardwaj 0345b91ddd rust: exclude DETECT_BYTEMATH_ENDIAN_DEFAULT from bindings
to deal with the failure due to cbindgen updates and mismatches in
generated bindings.

detect-bytemath.c:61: error: "DETECT_BYTEMATH_ENDIAN_DEFAULT" redefined [-Werror]
   61 | #define DETECT_BYTEMATH_ENDIAN_DEFAULT (uint8_t) BigEndian
      |
In file included from rust.h:34,
                 from detect-bytemath.c:32:
./../rust/gen/rust-bindings.h:5071: note: this is the location of the previous definition
 5071 | #define DETECT_BYTEMATH_ENDIAN_DEFAULT BigEndian
      |
2 months ago
Giuseppe Longo 88f17d7b20 detect/sctp: add sctp.chunk_type keyword
Add a U8 numeric keyword to match the first SCTP chunk type in a packet
with prefilter support.

Ticket #4251
2 months ago
Philippe Antoine 4144d9c709 rust: format snmp files
Ticket: 3836
2 months ago
Jason Ish 546209ff12 bindgen: fix include ordering
At some point, bindgen include ordering changed such that
AppLayerGetFileState was being bindgen'd as opaque, as the definition of
StreamBufferingConfig was not available when bindgen hit
AppLayerGetFileState, and bindgen processes in order.

Move the util includes before the app-layer includes to fix the ordering
problem, but still keep util includes grouped.

The sys diff is large as many things have been re-ordered.
2 months ago
William Ling 30628e45bc rust: replace helper with built-in
Replace custom u32_as_bytes with built-in to_be_bytes

Issue: 5785
2 months ago
Philippe Antoine 9318bbfbdb rust: format tftp files
Ticket: 3836
2 months ago
Philippe Antoine 9ec200e834 rust: format x509 files
Ticket: 3836
2 months ago
Philippe Antoine dd66276f82 rust: format telnet files
Ticket: 3836
2 months ago
Philippe Antoine 709ad1bdf4 rust: format sip files
Ticket: 3836
2 months ago
Samaresh Kumar Singh f06bb7d43e dhcp: support option 52 overload
Per RFC 2132 the BOOTP sname and file fields can hold extra DHCP
options when option 52 is present, but the parser ignored them. After
parsing the main options we now look up option 52 and walk sname or
file as additional option streams, appending what we find to the same
options vector so the logger and detection keywords see the
overloaded values too.

Bug: #8538.
2 months ago
Philippe Antoine 26bb18cfaa http2: replace state todrop with a dedicated boolean
Ticket: 8518
2 months ago
Philippe Antoine 8eed90ca9d http2: global txs are unidirectional
Ticket: 8518

Meaning they will now match only once per tx instead of twice:
once for each direction
2 months ago
Philippe Antoine daf68dc36f http2: split progress per direction
Ticket: 8518

Keywords that work for HTTP2 headers match now as soon as possible

A push promise is now considered like a headers frame with regards
to the progress (no dedicated "reserved" progress/state)

http.protocol and http.stat_msg keywords are now registered at
earliest progress, since these are synthetic like "HTTP/2" and
not really seen on the wire.

http.request_line and http.response_line match only on data,
and not on headers, since we must wait the end of headers
to be sure to have the full line

http2.size_update now matches at headers progress as it should

http2.frametype, http2.errorcode, http2.priority now match like
http2.window, when the tx is complete from both sides, as a
half-closed client may still send priority, rst_stream
or window_update frames
2 months ago
Philippe Antoine 8217c51126 rust: format sdp files
Ticket: 3836
2 months ago
Philippe Antoine 9d9d8df4cd rust: format rdp files
Ticket: 3836
2 months ago
Philippe Antoine 7352bae890 smb: avoid unsigned overflow debug assertion
As we compute a padding, we can use wrapping_add as we only
care about the low-weight bit anyways
2 months ago
Giuseppe Longo 8f205bb34f llmnr: implement logger
This adds an LLMNR protocol logger that reuses existing DNS functions,
following the same approach as the mDNS logger:

- No grouped logging
- Rdata is logged in a field that is named after the rdata type
- Types are logged in lower case
- Flags are logged as an array

Ticket #8366
2 months ago
Giuseppe Longo 13df0f7a06 llmnr: implement parser
This adds a parser for LLMNR protocol over both UDP and TCP.

The parser reuses the existing DNS functions since LLMNR shares
the same wire format as DNS, but implements its own protocol-specific
validation:

- LLMNR-specific flag checks (C, TC, T bits)
- Opcode validation (only standard query opcode 0 is valid)
- An Event is set if Z-flag is set, since it's must be zero per RFC4795

LLMNR transactions inherit DNS behavior where each packet creates a new state
with one transaction.

Ticket #8366
2 months ago
Jason Ish 3dc8b154f3 rust/ffi: add safe thread storage wrapper
Add a typed ThreadStorage<T> wrapper around the thread storage bindings.

Ticket: #8445
2 months ago
Jason Ish 9f40968bba rust/ffi: bindgen thread storage
Ticket: #8445
2 months ago
Jason Ish 5e0abf1572 rust/ffi: use ThreadVars wrapper in flow callbacks
Update the flow init, update and finish callback registrations to pass the
safe ThreadVars wrapper instead of a raw pointer.

Ticket: #8598
2 months ago
Jason Ish 1cac242948 rust/ffi: use ThreadVars wrapper in eve callback
Update the EVE callback registration to pass the safe ThreadVars wrapper
instead of a raw pointer.

Ticket: #8598
2 months ago
Jason Ish 45762aa644 rust/ffi: use ThreadVars wrapper in thread init callback
Update the thread init callback registration to pass the safe ThreadVars
wrapper instead of a raw pointer.

Ticket: #8598
2 months ago
Jason Ish 5fe88212c3 rust/ffi: add wrapper around ThreadVars
A Rust wrapper around ThreadVars to enforce Rust lifetimes to ThreadVars when
used in a callback.

Ticket: #8598
2 months ago
Philippe Antoine 73193c7e6a rust: format pgsql files
Ticket: 3836
2 months ago
Philippe Antoine 3bfe6cf4b9 rust: format nfs files
Ticket: 3836
2 months ago
Juliana Fajardini 372cb8c692 rust/sys: update bindgen SIGMATCH_ constants
Part of
Ticket #8551
2 months ago
Jason Ish 144f824f17 rust/ffi: add thread init callback wrapper
Ticket: #8605
2 months ago
Jason Ish c689af0bbb rust/ffi: bindgen thread lifecycle callbacks
Ticket: #8605
2 months ago