Commit Graph

19733 Commits (e16087fab426e1edbc1a3ea8a75ce7e0ee76a4e4)
 

Author SHA1 Message Date
Victor Julien 7517ba9f98 detect: give clear errors for http2 w/o substate
http2 states were not yet supported even if the built-in states could
already work. Clearly error out on a hook w/o substate.
4 months ago
Victor Julien e4176d2b9a detect/firewall: support substate in analyzer 4 months ago
Victor Julien 2511070a58 detect/firewall: support lte mode for substate 4 months ago
Victor Julien e1e24d6cb4 eve/alert: add sub state output 4 months ago
Victor Julien 7e60c3205e detect/alert: store sub-state in PacketAlert
In preparation of being able to log it.
4 months ago
Victor Julien 17a3e0d44f app-layer: use macro for progress ceiling 4 months ago
Victor Julien 2e1003a026 detect: add debug validation checks
Check that sub state handling is correct.
4 months ago
Victor Julien af1c72c37e detect/mpm: don't register engines for disabled protocols 4 months ago
Victor Julien 3b6b381f90 detect/firewall: add default alert signature to policy object
Now that there is a policy hash, make the alert signature object a
member of that to avoid another hash table lookup.
4 months ago
Victor Julien bffea309db detect/firewall: implement app policy as hash table
With substate support the fixed table approach for policies was no
longer a good fit, so convert to a hash table. The policies are stored
per alproto, sub_state, progress and direction.
4 months ago
Victor Julien eb87137471 detect/parse: allow bigger protocol/hook specifications 4 months ago
Victor Julien 6a3f9bc0b0 app-layer: for sub state API treat DOH2 as HTTP/2
Otherwise we'd have to re-register the relevant callbacks.
4 months ago
Victor Julien 956030452f detect/parse: don't setup sub states if protocol doesn't support it 4 months ago
Victor Julien bb41ef9caf http2: update push promise to account for stream id 0 filtering 4 months ago
Victor Julien c17ab6a65e http2: set event on frame types not allowed on stream id 4 months ago
Victor Julien 3ef0d2ce16 detect/parse: parse sub state hooks
Register a generic list for each sub state / progress combo.
4 months ago
Victor Julien 116a060092 detect/firewall: policy for substates
For the most part hard coded for HTTP/2 for now.
4 months ago
Victor Julien 63b8143577 http2: register names for states per sub-state 4 months ago
Victor Julien 14100d795c http2: mark HTTP2TxProgress and HTTP2TxGlobalProgress as AppLayerState 4 months ago
Victor Julien cedb836d01 output/dns: update for DOH2 change 4 months ago
Victor Julien 5735b87c3a detect: change how DOH2 inspection works
DNS/HTTP2 no longer automatically registers all keywords also for DOH2.

Instead, the DNS keywords and HTTP/2 stream keywords are registered for
DOH2 explicitly as well.

- flow alproto DOH2 + engine DOH2  -> inspect inner DNS
- flow alproto DOH2 + engine HTTP2 -> inspect outer HTTP/2
- flow alproto DOH2 + engine UNKNOWN -> inspect outer HTTP/2
4 months ago
Victor Julien 17953d2355 detect/http: register keywords for HTTP/2
Now that HTTP keywords are no longer automatically registered for
HTTP/2, register them manually.
4 months ago
Victor Julien b36ec146aa detect/dns: register keywords for DOH2 as well
Now that DNS keywords are no longer registered for DOH2, the keywords
need to manually registered for DOH2.
4 months ago
Victor Julien 1bb843d83f detect/http2: don't double register engines
Each keyword supporting DOH2 must register explicitly
4 months ago
Victor Julien 416b9c12ae detect/file: register http/2 with sub-state 4 months ago
Victor Julien c943de4fac detect/parse: initial http2 substate support
Hard coded for now.
4 months ago
Victor Julien 7ebc699df0 http2: split transaction state machines
Split into 2 sub-states:
- stream, which has the "HTTP" requests and responses, including DOH2
- global, which has the settings and other global or control handling

Introduce a simpler progress tracking for the global sub state:
- HTTP2ProgGlobalStart and HTTP2ProgGlobalComplete.

The stream sub state uses the same state machine as before.

Ticket: #8386.
4 months ago
Victor Julien 2f41e0ef2d output/tx: support substate completion flags 4 months ago
Victor Julien 67e2cb538a detect/app-layer-event: support sub-state progress handling 4 months ago
Victor Julien 59e2c5a40c detect/parse: initial substate support 4 months ago
Victor Julien 95365ce05b detect: support per tx sub states
Support for per transaction sub states: different state machines per
transaction type.

Skip engines not belonging to our substate.

Store tx_type in DetectTransaction.

Each protocol supporting sub states will register states from 1 and up.

To support:

Ticket: #8386.
4 months ago
Victor Julien b6bc025789 app-layer: start of substate API support
Allow registration of per substate progress name mappings.

Implement logic for getting sub-state names, id's.

Add transaction type and end of progress values to AppLayerTxData.

Introduce helpers to keep logic clean.
4 months ago
Shivani Bhardwaj 06db2e2698 detect/flowbits: add max usage per signature limit
Add a limit on the maximum number of times flowbits keyword that can be used in a
signature.

Task 8596
4 months ago
Shivani Bhardwaj 3462b126a3 detect: add max_flowbits option
Also move field around to pack holes and align the struct better.

Task 8596
4 months ago
Jason Ish 842b14ee1f smtp: don't create transaction for trailing quit
Also ensures that a quit or rset without a helo still creates a tx.

Ticket: #8728
4 months ago
Jason Ish e2a62dd1c0 smtp: handle pipelined replies on owning tx
Track the transaction id for each queued SMTP command so replies can update the
transaction that created the command instead of always using the current
transaction.

Ticket: #8393
4 months ago
Jason Ish 7b31f41878 smtp: complete transactions by progress state
Add directionality to completion states, and replace tx->done by checking for
both directions being complete.

This means that the transaction is now not complete until the server responds
to the clients of data marker, previously the tx was completed when the client
send end of data without waiting for the server response.

This keeps smtp:response_complete from being exposed before the server response
is parsed.

Ticket: #8393
4 months ago
Jason Ish c2728eee01 smtp: add firewall progress states
Add minimal SMTP progress states to support envelope validation before
moving to data.

Update SMTP, file and email keywords to hook into the appropriate
states.

Purposefully kept minimal for now as to not break the current idea of an
SMTP transaction, which is probably not ideal for firewall mode.

Ticket: #8393
4 months ago
Philippe Antoine 9c244c978a snmp/detect: add snmp.trap_address keyword
Ticket: 8486
4 months ago
Philippe Antoine 08b0adf09d snmp/detect: add snmp.trap_oid keyword
Ticket: 8485
4 months ago
Philippe Antoine 752dae89ea detect: add progress argument to SCDetectRegisterMpmGeneric
Will be needed by snmp
4 months ago
Philippe Antoine 7d024a840c rust: bindgen detect ThreadCtx keyword functions 4 months ago
Philippe Antoine 5fe920ec42 detect: make Http2ThreadBuf a generic DetectThreadBuf
to be used by snmp and other
4 months ago
Philippe Antoine b84f26ef0a jsonschema: add existing snmp keywords 4 months ago
Jason Ish 4e642b9f06 rust/ffi: specify sys crate dependency version
This is required for crates.io publishing, and we also use this for
other internal crate dependencies, for example suricata depending on
derive, etc.
4 months ago
Yash Datre 43bc2db41e detect: extend app-layer-protocol to accept a pipe-separated value list
Extend the app-layer-protocol keyword to accept a pipe-separated list of
protocol values, so a single rule can match any of several protocols:

    app-layer-protocol:[!]<proto1>|<proto2>[|...][,<qualifier>]...;

A non-negated list matches when the flow's protocol equals any listed value
(OR); a negated list matches when it equals none of them (NOR). The
single-value form and the trailing mode qualifier are unchanged.

Matching keeps the historical AppProtoEquals() equivalences by default
(dns/doh2, http/http1/http2, dcerpc/smb, ...). An `exact` qualifier selects
strict identity matching with no equivalences and no http umbrella; it
combines with a direction mode in any order. Because a flow is never the
generic ALPROTO_HTTP, `http,exact` is rejected at load.

Values are expanded once at rule load into an effective match-set bitmask, so
the per-packet match is a single bitmask test. Single-value rules remain
prefilterable; multi-value rules are excluded from prefiltering and an
explicit prefilter on them is rejected. Conflicting keyword combinations
(duplicate or overlapping negations, mixed positive/negated) are rejected at
load. Engine-analysis reports the effective match set.

Ticket: 7705
4 months ago
Philippe Antoine 1731805967 doh2: clear the buffer after processing it
Ticket: 8725

So that multiple HTTP2 DATA frames with EndOfStream flag set,
do not make the buffer grow, while processing it each time,
resulting in quadratic complexity
4 months ago
Philippe Antoine 7ec9d72d28 stream: disrupt never seen direction with async-oneside
Ticket: 8629

When we are in async-oneside mode, we see only one direction
of the traffic, and should not wait for the other direction
before cleaning up a transaction.
4 months ago
Jeff Lucovsky c8f68b0e4f smb: fail transaction creation once the limit is reached
new_tx() now refuses to create a transaction when the list is already at
SMB_MAX_TX, returning None instead of a transaction. Every creation path --
the new_*_tx helpers and their callers across smb1/smb2/dcerpc/session/
files/ioctl -- propagates that, so no single input can create more than the
limit, including a compound SMB2 request that chains many PDUs in one
record. When the list is full the parser puts the flow into an error state
and stops processing it.

This replaces the previous force-completion of old transactions, which did
not reliably bound the list and could leave transactions unreclaimable on
asymmetric flows. The now-unused tx_index_completed bookkeeping is removed.

Issue: 8629
4 months ago
Philippe Antoine 392b6aee29 http1: limit the number of compression bombs per flow
Ticket: 8694

Otherwise, a flow full of small compression bombs is too slow
to process.

When the threshold is reached, decompression is skipped for the
rest of the flow.
4 months ago