Commit Graph

15195 Commits (suricata-7.0.4)
 

Author SHA1 Message Date
Shivani Bhardwaj 6b0ff3ef25 version: start development towards 7.0.4 1 year ago
Shivani Bhardwaj be68bbc4ab release: 7.0.3; update changelog 1 year ago
Philippe Antoine ce9b903269 http2: limit number of concurrent transactions
Ticket: 6481

Instead of just setting the old transactions to a drop state so
that they get later cleaned up by Suricata, fail creating new ones.

This is because one call to app-layer parsing can create many
transactions, and quadratic complexity could happen in one
single app-layer parsing because of find_or_create_tx

(cherry picked from commit 80abc22f64)
2 years ago
Philippe Antoine b0d762d267 pgsql: parse only PDU when type is unknown
A next PDU may already be in the slice to parse.
Do not skip its parsing, ie do not use rest, but take just
the length of the pdu

(cherry picked from commit 86de7cffa7)
2 years ago
Philippe Antoine 61a32360eb pgsql: parse auth message within its bound
If the next PDU is already in the slice next, do not use it and
restrict ourselves to the length of this PDU.
Avoids overconsumption of memory by quadratic complexity, when
having many small PDUS in one big chunk being parsed

Ticket: #6411
(cherry picked from commit f52c033e56)
2 years ago
Philippe Antoine cd731fcaf4 detect: fixes use-after-free with http.request_header
Ticket: #6441

This keyword and the response one use a multiple inspection buffer.
But the different instances point to the same memory address
that comes from HttpHeaderGetBufferSpace and is not owned
by the transaction, and is rebuilt, which is a functional
bug in itself.

As it gets crafted, it can get reallocated if one header
is over 1024 bytes, while the previous freed pointer will still get
used for the previous headers.

(cherry picked from commit bc422c17d6)
2 years ago
Philippe Antoine cd035d59e3 smtp: avoid creating empty transaction
Ticket: 6477

So as to avoid ending up with too many empty transactions.

This happens when Suricata sees a DATA command in the current
transaction but did not have a confirmation response for it.
Then, if Suricata receives another DATA command, it will
create another new transaction, even if the previous one
is empty. And so, a malicious client can create many empty
transactions by just sending a repeated amount of DATA commands
without having a confirmation code for them.

Suricata cannot use state->current_command == SMTP_COMMAND_DATA
to prevent this attack and needs to resort to a new boolean
is_data because the malicious client may send another dummy command
after each DATA command.

This patch leaves only one call to SMTPTransactionCreate

(cherry picked from commit 61f2e4e1e5)
2 years ago
Philippe Antoine f9de1cca61 smtp: config limit maximum number of live transactions
Ticket: #6477
(cherry picked from commit 8f73a0ac55)
2 years ago
Philippe Antoine e7e28822f4 http1: configurable max number of live tx per flow
Ticket: #5921

Co-authored-by: Jason Ish <jason.ish@oisf.net>
(cherry picked from commit 4175680a8a)
2 years ago
Philippe Antoine 97953998d2 http1: remove transactions from their list
instead of keeping a NULL pointer in an array

Ticket: #5921
(cherry picked from commit 8f63a8f3bf)
2 years ago
Philippe Antoine 478a2a38f5 http2: handle reassembly for continuation frames
Ticket: 5926

HTTP2 continuation frames are defined in RFC 9113.
They allow header blocks to be split over multiple HTTP2 frames.
For Suricata to process correctly these header blocks, it
must do the reassembly of the payload of these HTTP2 frames.
Otherwise, we get incomplete decoding for headers names and/or
values while decoding a single frame.

Design is to add a field to the HTTP2 state, as the RFC states that
these continuation frames form a discrete unit :
> Field blocks MUST be transmitted as a contiguous sequence of frames,
> with no interleaved frames of any other type or from any other stream.
So, we do not have to duplicate this reassembly field per stream id.

Another design choice is to wait for the reassembly to be complete
before doing any decoding, to avoid quadratic complexity on partially
decoding of the data.

(cherry picked from commit aff54f29f8)
2 years ago
Philippe Antoine 3cdd50071b mqtt: fix logic when setting event
Especially sets transactions to complete when we get a response
without having seen the request, so that the transactions
end up getting cleaned (instead of living/leaking in the state).

Also try to set the event on the relevant transaction, instead
of creating a new transaction just for the purpose of having
the event.

Ticket: #6299
(cherry picked from commit 89936b6530)
2 years ago
Philippe Antoine f4910decbc detect: merge sorted lists instead of qsort
Ticket: #6299

Simply because it is faster (just linear).

This is for merging match_array into tx_candidates

(cherry picked from commit 5bb8800588)
2 years ago
Philippe Antoine f19b3a89e0 detect: avoids case of useless detection on txs
When a TCP flow packet has not led to app-layer updates,
it is useless to run DetectRunTx, as there cannot be new
matches.

This happens for instance, when one side sends in a row multiple
packets which are not acked (and thus not parsed in IDS mode).

Doing so requires to move up the call to
AppLayerParserSetTransactionInspectId
so that it is run the same times DetectRunTx is run, and not in the
case where the transaction was not updated.

Ticket: 6299
(cherry picked from commit 9240ae250c)
2 years ago
Jason Ish cc6319b37c doc: note what version "requires" was added in
(cherry picked from commit 8bf8131c31)
2 years ago
Jason Ish 1225c73a17 detect/requires: reset sigerror flags for each rule
"sigerror_ok" and "sigerror_requires" were not being reset after each
rule which could lead to a rule load error being incorrectly tracked
as skipped rather than failed.

Also initialize "skippedsigs" to 0 along with "goodsigs" and
"badsigs", while not directly related to this issue, could also throw
off some stats.

Ticket: #6710
(cherry picked from commit de3cbe4c90)
2 years ago
Jason Ish 8e2ab32dc5 requirements: use libhtp 0.5.x
Move to libhtp to the 0.5.x branch instead of 0.5.45.

(cherry picked from commit c3b3c11e30)
2 years ago
Lukas Sismis 203f80bf97 doc: remove references to prehistoric versions
Remove references that are mentioning Suricata 3 or less
As a note - only one Suricata 4 reference found:
(suricata-yaml.rst:"In 4.1.x")
Fast pattern selection criteria can be internally found by inspecting
SupportFastPatternForSigMatchList and SigTableSetup functions.

Ticket: #6699
(cherry picked from commit 6e4cc79b39)
2 years ago
Lukas Sismis aeb5564e89 dpdk: rework hugepage hints to use per-numa information
Previous integration of hugepage analysis only fetched data
from /proc/meminfo. However this proved to be often
deceiving mainly for providing only global information and
not taking into account different hugepage sizes (e.g. 1GB
hugepages) and different NUMA nodes.

Ticket: #6697
(cherry picked from commit ca6f7c2d00)
2 years ago
Vincent Li 4a7c6e0007 flow-bypass: Set bypass thread to running state
When running Suricata in XDP bypass mode (bypass: yes),

Suricata started up with error:
Error: threads: thread "FB" failed to start in time: flags 0003

"FB" thread does not transition from THV_INIT_DONE to THV_RUNNING.

Set "FB" thread THV_RUNNING state in BypassedFlowManager().

Bug: #6254

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
(cherry picked from commit f80d26db0b)
2 years ago
Gleb Smirnoff e6646c8f3f ipfw: close(2) instead shutdown(2) of the divert(4) socket
The shutdown(2) syscall would always return ENOTCONN for FreeBSD 11,
FreeBSD 12, FreeBSD 13 and FreeBSD 14.  It could do some action on the
socket in the kernel in FreeBSD 10 and before, did not test.

(cherry picked from commit b239e88c93)
2 years ago
Philippe Antoine 08dae40452 detect: case-insensitive comparison for requires
Ticket: 6656
(cherry picked from commit d3218385e9)
2 years ago
Stephen Donnelly c0247024bc source/erf-dag: compiler warnings
Bug: #6667.

Fix compiler warnings for function pointer parameters missing const with --enable-dag

(cherry picked from commit c28cc93e23)
2 years ago
Stephen Donnelly ab57fb9513 endace: Fix source-dag timestamps
Bug: #6618.

Fix Endace ERF to SCTime_t timestamp conversion

Fix typo preventing compilation with --enable-dag

(cherry picked from commit 879db3dbc3)
2 years ago
Jason Ish 6e9d790581 stats: add rules skipped
Rule skipped is a count of the number of rules that are skipped due to
missing requirements.

Feature: #6637
(cherry picked from commit b453eea150)
2 years ago
Jason Ish 1a7e88319a detect-parse: parse sid in pre-scan
During the pre-scan for "requires", also parse the SID if possible. If
the rule fails high level parsing (syntax), the SID will not be
parsed.

But every keyword other than "sid" and "requires" should expect to be
provided with a parsed sid.

(cherry picked from commit 71bbba9248)
2 years ago
Jason Ish e683e7604c requires: pre-scan rule for requires expressions
Add a "pre-scan" rule parse that will check for requires statement. It
will return a special error code (-4) if the requires fails due to
missing requirements.

Syntactic errors will also abort parsing here.

Feature: #5972
(cherry picked from commit 435c03172e)
2 years ago
Jason Ish 09fc36713f requires: add requires keyword
Add a new rule keyword "requires" that allows a rule to require specific
Suricata versions and/or Suricata features to be enabled.

Example:

  requires: feature geoip, version >= 7.0.0, version < 8;
  requires: version >= 7.0.3 < 8
  requires: version >= 7.0.3 < 8 | >= 8.0.3

Feature: #5972

Co-authored-by: Philippe Antoine <pantoine@oisf.net>
(cherry picked from commit 5d5b0509a5)
2 years ago
Jason Ish ea78420d02 feature: provide a Rust binding to the feature API
As the feature module is not available for Rust unit tests, a mock
version is also provided.

(cherry picked from commit 15ed51f9b8)
2 years ago
Jeff Lucovsky 40234b255d htp/swf: Remove flash deprecation notice
Issue: 6605

Flash decompression will remain so the deprecation notice is not needed.

(cherry picked from commit 995f5fc8c5)
2 years ago
Jeff Lucovsky 55772c39fe log/sguil: Issue deprecation notice if sguil mode
Issue: 6688
2 years ago
Jason Ish 98e72a793e userguide: remove old css files
In our conf.py we reference some ReadTheDocs stylesheets that appear to
be old and break formatting of some items like bulletted lists.

Bug: #6589
(cherry picked from commit cc0adaaf4a)
2 years ago
Eric Leblond e1f2555900 detect/stream_size: fix prefiltering registration
Ticket: #6551
(cherry picked from commit 180459eeb6)
2 years ago
Philippe Antoine 2a86df53f2 detect: strip_pseudo_headers transform
Ticket: 6546
(cherry picked from commit adf5e6da7b)
2 years ago
Philippe Antoine f2e83e420d doc: fix byte_test examples
As this keyword has 4 mandatory arguments, and some examples
had only three...

Ticket: 6629
(cherry picked from commit 4933b817aa)
2 years ago
Juliana Fajardini 2e6322bc36 pgsql: fix u16 overflow in query data_row
Found by oss-fuzz with quadfuzz.

Cf https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63113

According to PostgreSQL documentation the maximum number of rows can be
the maximum of tuples that can fit onto max u32 pages - 4,294,967,295 (cf
https://www.postgresql.org/docs/current/limits.html). Some rough
calculations for that indicate that this could go over max u32, so
updating the data_row data type to u64.

Bug #6389

(cherry picked from commit 8d3de85edd)
2 years ago
Victor Julien ba3f1f8c6f github/action: fix Debian 12 intermittent failures
Parallel builds caused issues during `cargo vendor`. So do just a single
thread build.

 make[4]: Entering directory '/__w/suricata/suricata/rust'
cbindgen --config /__w/suricata/suricata/rust/cbindgen.toml \
	--quiet --output /__w/suricata/suricata/rust/dist/rust-bindings.h
CARGO_HOME="/github/home/.cargo"  /usr/bin/cargo vendor
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
ERROR: Couldn't execute `cargo metadata` with manifest "/__w/suricata/suricata/rust/Cargo.toml": Metadata(Output { status: ExitStatus(unix_wait_status(25856)), stdout: "", stderr: "    Blocking waiting for file lock on package cache\n    Blocking waiting for file lock on package cache\nerror: failed to download `adler v1.0.2`\n\nCaused by:\n  unable to get packages from source\n\nCaused by:\n  failed to parse manifest at `/github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/adler-1.0.2/Cargo.toml`\n\nCaused by:\n  no targets specified in the manifest\n  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n" })
ERROR: Couldn't generate bindings for /__w/suricata/suricata/rust.
make[4]: *** [Makefile:597: dist/rust-bindings.h] Error 1
make[4]: *** Waiting for unfinished jobs....

(cherry picked from commit c82d93490c)
2 years ago
Victor Julien 77f3964d74 detect/bytejump: don't reuse content flag
To avoid future problems with overlapping flag values, give bytejump
its own DETECT_BYTEJUMP_OFFSET_VAR flag.

The values are currently not overlapping, so this patch should have
no side effects.

(cherry picked from commit 101452056d)
2 years ago
Victor Julien 9bd629021b detect/analyzer: print int keyword values correctly
To avoid negative values to be misrepresented.

Bug: #6615.
(cherry picked from commit de5b8ae0b4)
2 years ago
Victor Julien eb5a430154 jsonbuilder: add set_int for signed ints
Bug: #6615
(cherry picked from commit b8440a0917)
2 years ago
Philippe Antoine eff4af46fa rust: allow clippy::items_after_test_module
As clippy began to complain about jsonbuilder.rs

(cherry picked from commit 673d13d445)
2 years ago
Victor Julien 1d3302240a detect/profiling: improve pcap reading performance
When reading a pcap, packet time can move much faster than wall
clock time. This would trigger many more profile syncs than before.

As the sync is using a lock to synchronize with other threads, this
is an expensive operation.

Bug: #6619.

Fixes: b591813b86 ("profiling/rules: reduce sync logic scope")
(cherry picked from commit bcb2b50cfc)
2 years ago
Victor Julien 4db3f8f83d detect/content: fix offset for negative distance
Fix offset calculation on sigs with negative distance. Can lead to FN
in certain cases.

Bug: #6661.
(cherry picked from commit 2911656d6c)
2 years ago
Victor Julien fa391a884a eve/email: improve logging binary data
Use jb_append_string_from_bytes() as it works better than
BytesToString+jb_append_string when logging binary data.

Bug: #6664.
(cherry picked from commit f5565f42e7)
2 years ago
Philippe Antoine 3aa9ff52a8 stats: incr app-proto flow counter for detection-only
Ticket: 6633
(cherry picked from commit 3103505cb0)
2 years ago
Juliana Fajardini 046a18b81a pgsql: remove unused msg field
The `ConsolidatedDataRow` struct had a `length` field that wasn't truly
used.

Related to
Bug #6389

(cherry picked from commit 1afb485dfa)
2 years ago
Jeff Lucovsky 32160f4a12 detect/transform: Clarify transformation validation
Issue: 6439

Clarify the transform validation step. When a transform indicates that
the content/byte-array is not compatible, validation will stop.

Content is incompatible is some cases -- e.g., following the
to_lowercase transform with content containing uppercase characters.
An alert is not possible since the content contains uppercase and the
transform has converted the buffer into all lowercase.

(cherry picked from commit a46779d866)
2 years ago
Jeff Lucovsky 89d7ece05f detect/transform: Register case-change transforms
Issue: 6439
(cherry picked from commit 1110a86cb9)
2 years ago
Jeff Lucovsky 062d9ea9fd doc/transform: Document case-changing transforms.
Issue: 6439
(cherry picked from commit 9ee55d2394)
2 years ago
Jeff Lucovsky d67b7c1505 detect/transform: Add case changing transforms
This commit adds the implementation for the case changing transforms:
to_lowercase and to_uppercase

Issue: 6439
(cherry picked from commit e5c2f9a56d)
2 years ago