Commit Graph

730 Commits (2b02abfa75b3f7ee895637ba13b57a3bb063d30d)

Author SHA1 Message Date
Jason Ish 2b02abfa75 rfb: remove duplicate logging of depth
The "depth" field in the "pixel_format" object was being logged twice.

Issue: 5813

(cherry picked from commit f15f092a69)
4 years ago
Jason Ish 0e0ce39190 smb: remove duplicate tree_id logging
Remove the second occurrence of tree_id logging which appears to
always be a duplicate of the first tree_id logged, even though they
come from different data structures.

Issue: 5811

(cherry picked from commit 67baab573b)
4 years ago
Philippe Antoine 70a4587a9b dns: remove unused events field from state
found overflowing by oss-fuzz

(cherry picked from commit 26dc70648c)
4 years ago
Philippe Antoine 95009e4411 smb: handles records with trailing nbss data
If a file (read/write) SMB record has padding/trailing data
after the buffer being read or written, and that Suricata falls
in one case where it skips the data, it should skip until
the very end of the NBSS record, meaning it should also skip the
padding/trailing data.

Otherwise, an attacker may smuggle some NBSS/SMB record in this
trailing data, that will be interpreted by Suricata, but not
by the SMB client/server, leading to evasions.

Ticket: #5786
(cherry picked from commit 233ab11148)
4 years ago
Philippe Antoine 0bf3ab9e6d smb: checks against nbss records length
When Suricata handles files over SMB, it does not wait for the
NBSS record to be complete, and can stream the payload to the
file... But it did not check the consistency of the SMB record
length being read or written against the NBSS record length.

This could lead to an evasion where an attacker crafts a SMB
write with a too big Length field, and then sends its evil
payload, even if the server returned an error for the write request.

Ticket: #5770
(cherry picked from commit c1b7befb18)
4 years ago
Victor Julien 6c7bdd7aca smb: set defaults for file transfer limits
Ticket: #5782.
(cherry picked from commit 37f13a4fc7)
4 years ago
Philippe Antoine fa4dedc1d4 nfs2: improve READ parsing
Inspired by commit ddf14e51dc

But keeping old nom version
4 years ago
Philippe Antoine ffb2e38ae0 smb/ntlmssp: parse fields independently of order
Instead of relying on the usual ordering...

Ticket: #5258
(cherry picked from commit 1db8685848)

Manual conflict fixes to use nom instead of nom7
4 years ago
Victor Julien ba4a533797 smb: fix post-trunc chunk behavior
After a gap in a file transaction, the file tracker is truncated. However
this did not clear any stored out of order chunks from memory or stop more
chunks to be stored, leading to accumulation of a large number of chunks.

This patches fixes this be clearing the stored chunks on trunc. It also
makes sure no more chunks are stored in the tracker after the trunc.

Bug: #5781.
(cherry picked from commit a24d7dc45c)
4 years ago
Philippe Antoine b5131da355 dcerpc: store consumed_bytes as i32
As it can grow bigger than u16

(cherry picked from commit 704bc878ea)
4 years ago
Jason Ish 6b6709c9d9 rust: fix for loop over option
As of Rust 1.66 with strict mode enabled, a for loop over an option is
now an error. Replace the last occurrence of this pattern with an "if
let" statement.
4 years ago
Philippe Antoine 938597691c nfs4: fix write record handling
Ticket: #5280
(cherry picked from commit 95f0424423)
4 years ago
Victor Julien d607c9295b smb: fix file reopening issue
Fuzzing highlighted an issue where a command sequence on the same file
id triggered a logging issue:

file data for id N
close id N
file data for id N

If this happened in a single blob of data passed to the parser, the
existing file tx would be reused, the file "reopened", confusing the
file logging logic. This would trigger a debug assert.

This patch makes sure a new file tx is created for the file data
coming in after the first file tx is closed.

Bug: #5567.
(cherry picked from commit 45eb038e63)
4 years ago
Philippe Antoine a567305240 dcerpc: fix integer underflow
as input.len() can be 65536, it cannot be directly cast to u16

Ticket: #5557
Ticket: #5602
4 years ago
Philippe Antoine 05509b52f6 smb: do not use tree id to match request and response
Completes commit e94920b49f

This must be true for access to state ssn2vecoffset_map

Ticket: #5161
4 years ago
Philippe Antoine d84eee39a8 smb: do not use tree id to match create request and response
As an SMB2 async response does not have a tree id, even if
the request has it.

Per spec, MessageId should be enough to identifiy a message request
and response uniquely across all messages that are sent on the same
SMB2 Protocol transport connection.
So, the tree id is redundant anyways.

Ticket: #5508
(cherry picked from commit e94920b49f)
4 years ago
Victor Julien acec24a816 rust/files: open file without trackid as pointer
(cherry picked from commit cade6046c5)
4 years ago
Victor Julien 304fd1796f rust/filecontainer: remove unused declaration
(cherry picked from commit ad869e1c52)
4 years ago
Philippe Antoine 0324a9b20b http2: fix decompression buffering
It was not enough to set Cursor position to 0,
also its inner Vec should be cleared.

This way, a new input gets written at the beginning of the
Cursor and its inner Vec...

Ticket: #5691
(cherry picked from commit 086b28da3d)
4 years ago
Philippe Antoine 9cc92b8dd5 http2: support padded data frames
Ticket: #5691
(cherry picked from commit c6349d3cfc)
4 years ago
Philippe Antoine 0ca12493e3 mime: handles multiple sections for a parameter
Ticket: 4386

as per RFC2231.
For instance filename can be split between filename*0,
filename*1, etc...

(cherry picked from commit 784558df2e)
4 years ago
Philippe Antoine 55781229d7 mime: move FindMimeHeaderTokenRestrict to rust
Also fixes the case where the token name is present
in a value

(cherry picked from commit 8feb9c35ae)
4 years ago
Philippe Antoine 40d1bb3422 mqtt: remove quadratic time complexity
When having many transactions in a single parsing call...

Fix has overhead of having one more field in the mqtt state.

Completes commit a8079dc978

Ticket: #5399
(cherry picked from commit e160917bcf)
4 years ago
Jeff Lucovsky ba37574ca5 mqtt: convert transaction list to vecdeque
Ticket: 5430
4 years ago
Philippe Antoine 18c616394e mqtt: make max transactions configurable
Allows users to find balance between completeness of decoding
and increases resource consumption, which can DOS suricata.

(cherry picked from commit e42094f238)
4 years ago
Philippe Antoine e029f80af2 mqtt: limits the number of active transactions per flow
Ticket: 4530

So, that we do not get DOS by quadratic complexity, while
looking for a new pkt_id over the ever growing list
of active transactions

(cherry picked from commit a8079dc978)
4 years ago
Philippe Antoine 16da02cfbd http2: remove to_vec for comparisons
Ticket: #5454
(cherry picked from commit 9b4a133777)

Conflict fixed by Philippe Antoine
4 years ago
Philippe Antoine eae0aadab8 http2: fix clippy warning about &Vec<u8>
Using &[u8] instead in function prototype

(cherry picked from commit d011b468da)

Conflict fixed by Philippe Antoine
4 years ago
Philippe Antoine ed15b0d6ab http2: check overflow before it happens
instead of checking afterwards if value got smaller

(cherry picked from commit b86beb9b68)

Manually adapted to make it work with MSRV
4 years ago
Jason Ish b8875d4a22 rust/nfs: add a maximum number of operations per compound
This is a backport of ea1d03f8e3 by Pierre
Chifflier adapted for 6.0.x.

> The `count` combinator preallocates a number of bytes. Since the value
> is untrusted, this can result in an Out Of Memory allocation.
> Use a maximum value, large enough to cover all current implementations.

Ticket: #5448
4 years ago
Jeff Lucovsky aa396f4f5e rust: Unused doc comment warning fixup
Since rustdoc does not generate documentation for extern blocks, Fedora
35 builds flagged 2 occurrences where doc comments existed on extern C
blocks.
4 years ago
Philippe Antoine 9bc690897a smb: ntlmssp domain_blob_offset underflow check
Ticket: 5246
(cherry picked from commit e72036f12f)
4 years ago
Philippe Antoine d80fbfd4c6 smb: check on param parsing
Ticket: 5246

so as not to overflow u16

(cherry picked from commit 817a5001a5)
4 years ago
Philippe Antoine dfe3da7765 rust: RustParser same fields as AppLayerParser
So that there is no problem when crossing FFI

(cherry picked from commit c78722a671)
4 years ago
Philippe Antoine 5924869f5d dcerpc: use wrappingadd for padding parsing
As we compute a modulo, we can safely wrap around even if there
is an overflow

Ticket: #5301
(cherry picked from commit d2f00ac824)
4 years ago
Jason Ish eeb8c17e0f dns: don't parse a full request during probe if not enough data
If there is more data than a header, but not enough for a complete DNS
message, the hostname parser could return an error causing the probe to
fail on valid DNS messages.

So only parse the complete message if we have enough input data. This is
reliable for TCP as DNS messages are prefixed, but for UDP its just
going to be the size of the input buffer presented to the parser, so
incomplete could still happen.

Ticket #5034

(cherry picked from commit 27679a12aa)
4 years ago
Jason Ish fa04c1bc57 dns: better error handling when parsing names
The DNS name parser will error out with an error even if the
error is incomplete. Instead of manually generating errors,
use '?' to let the nom error ripple up the error handling chain.

The reason this wasn't done in the first place is this code
predates the ? operator, or we were not aware of it at the time.

This prevents the case where probing fails when there is enough data to
parse the header, but not enough to complete name parser. In such a case
a parse error is returned (instead of incomplete) resulting in the
payload not being detected as DNS.

Ticket #5034

(cherry picked from commit 0623ada24d)
4 years ago
Jason Ish 947cb09e5b smb: protocol detection on pattern without midstream
To recognize a protocol, Suricata first looks for
patterns, which can be confirmed by a probing parser.
If this does not work, Suricata can try to run
some probing parsers on some ports.

This is the case for SMB.

This commit makes handling the confirming and the probing
paser differently even if they share much code.

The confirmation parser knows that a pattern has been found.
So, it must not do the midstream case of looking for this
pattern in the whole buffer, but only check it at the beginning.
But it must reverse direction if needed.

Ticket #4849

Backported manually by jason.ish@oisf.net.

(cherry picked from commit 464ff80c6a)
4 years ago
Philippe Antoine 8498999c6a tftp: use destate
And avoids memory leaks on it

Ticket #4848
4 years ago
Victor Julien 20b379d92a smb: fix read queue exceeded event and rules 4 years ago
Victor Julien 788d8abea3 smb: log max read/write sizes
(cherry picked from commit 90d4b8e438)
4 years ago
Victor Julien 65f24b2e84 smb2: validate negotiate read/write max sizes
Raise event if they exceed the configured limit.

(cherry picked from commit fc9b65d8d3)
4 years ago
Victor Julien 8510031e6c smb2: allow limiting in-flight data size/cnt
Allow limiting in-flight out or order data chunks per size or count.

Implemented for read and writes separately:

app-layer.protocols.smb.max-write-queue-size
app-layer.protocols.smb.max-write-queue-cnt
app-layer.protocols.smb.max-read-queue-size
app-layer.protocols.smb.max-read-queue-cnt

(cherry picked from commit 4be8334c9e)
4 years ago
Victor Julien 5b38b97181 filetracker: track total queued data (in_flight)
As well as expose number of chunks.

(cherry picked from commit 2c5ad8858e)
4 years ago
Victor Julien 502db40240 smb2: add options for max read/write size
Add options for the max read/write size accepted by the parser.

(cherry picked from commit 5bcc4162f7)
4 years ago
Victor Julien 9f969e2545 smb2: track max read/write size and enforce its values
(cherry picked from commit f28888513a)
4 years ago
Victor Julien 2ba9ad53eb smb: minor function cleanup
Remove used argument from `filetracker_newchunk()`. We're not
using fill_bytes with smb.

(cherry picked from commit 594acec5dc)
4 years ago
Victor Julien 02c3bd00fa filetracker: make FileChunk private
(cherry picked from commit c7a474c725)
4 years ago
Philippe Antoine f3a6d15034 mqtt: fix consumed bytes computation for truncated msg
Ticket: 5268
(cherry picked from commit 3b13008c1b)
4 years ago
Sascha Steinbiss 084b16a63b mqtt: raise event on parse error 4 years ago