Commit Graph

784 Commits (62d5cac1b8483d5f9d2b79833a4e59f5d80129b7)

Author SHA1 Message Date
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
Jason Ish 4c2d543022 mqtt: ensure we do not request extra data after buffering
This is a minimal backport of 5618273ef4
to address ticket 5018.

Uses the "complete" version of take instead of the macro which is thre
streaming variant.

Ticket #5018
4 years ago
Jason Ish e55fef32d9 smb: handle records in the wrong direction
If an SMB record is seen in the wrong direction, set an event on the PDU
frame and don't process the record in the state.

No error is returned, so the next record will be processed.

(cherry picked from commit 2341f47755)
4 years ago
Jason Ish e63795543f smb: expose smb1 request/reply flags with a method
Adds `.is_request()` and `.is_reply()` to check if a SMB record flags
say the message is a request or a reply.

(cherry picked from commit 09e2d3b216)
4 years ago
Jason Ish 12a8415326 smb: fix smb2 header flag parsing
The bits were being parsed in the order they're displayed in Wireshark,
rather than the order they were being seen on the wire, resulting in
direction and async being 0 more often than they should be.

Instead of bits, take the 4 bytes as an le_u32 and just use bit masks to
extract what we need into a struct, I think its easier to reason about
this way when comparing to the Microsoft documentation.

(cherry picked from commit 7b659489c8)
4 years ago
Victor Julien ce69f79f6a smb1: apply close to direction
Instead of closing files in both direction when receiving a close request,
close only toserver files for the request and close toclient on receiving
a response.

(cherry picked from commit b336882008)
5 years ago
Victor Julien 2075038390 nfs: clean up partial record handling
There should be no remaining data after parsing the partial
RPC record, so don't handle it but instead add a debug validation
bug on.

Successful processing for NFSv3 read/write records returns
AppLayerResult::ok() directly as all data is consumed.

(cherry picked from commit 07b1100713)
5 years ago
Victor Julien fb8f4ef849 nfs3: improve read validation; fix partial handling
(cherry picked from commit d85b77cad0)
5 years ago
Victor Julien 29468e60f5 nfs3: fix partial write record handling
Comment from Jason Ish: This was a bit more than a cherry pick as some
of the modifications weren't directly portable to the nom macros. So
instead bring in some of the nom function based parsers as they work
fine with nom 5.

(cherry picked from commit 4418fc1b02)
5 years ago
Victor Julien 8c09ba0508 nfs3: enforce more values
Enforce values of a number of u32's that are used as bools or for
really low values.

(cherry picked from commit 5baf94e40d)
5 years ago
Victor Julien 5bb752e65a rpc: enforce various field values
Minimal frag_len. Correct msgtype and others.

(cherry picked from commit 1c57e3c18d)
5 years ago
Victor Julien 98773d0985 nfs/rpc: update full record parsers to be more exact
Instead of 'take'ing all data for the RPC prog_data and then
letting the higher level parsers figure out which part to use
take the exact amount.

Comments from Shivani Bhardwaj: This is was more than a cherry pick and
some of the modifications were not directly portable to the nom macros.
So, parsers were changed to make sure the functionality remained same while
making the transition to nom5 while keeping the diff minimal.

(cherry picked from commit 64d8a1e16e)
5 years ago
Victor Julien 12beed09ae nfs: break out partial record handling
(cherry picked from commit bfb5ae867e)
5 years ago
Victor Julien 353bfd6d0a nfs/rpc: enforce length field limits
Limits based on the Linux kernel limits. Then multiplied a few times
to allow for other implementations to have higher limits.

(cherry picked from commit fe76ab1803)
5 years ago
Victor Julien 1fba08a27d nfs4: verify bool fields
(cherry picked from commit 5ecb626e50)
5 years ago
Philippe Antoine 18bf8c89d9 mqtt: parse properties with the right buffer's length
(cherry picked from commit f0e869b26b)
5 years ago
Eloy Pérez González 1556ea0ceb dcerpc: remove prev_tx_call_id and clear_bind_cache from DCERPCState
remove those fields since are not used because of the removal of
handle_bind_cache.

(cherry picked from commit 15f493f516)
5 years ago
Eloy Pérez González 0c400b2ddb dcerpc: avoid delete the rpc state interface context
The bug:
The dcerpc dce_iface keyword just match the packet following the bind. Only the
next request after the rpc is sent will match. However the expected behaviour it
that all the rpc requests/responses sent under the context of the given
interface would match.

In the Open Group c706 the following is indicated:

In 2.2.1 Binding-related Operations, indicates that one category of binding
operations are those that "operations that establish internal call routing
information for the server." (The other are to establish the protocol which is
not relevant here). And the following statement can be found:

Operations in the second category establish a set of mappings that the server
can use to route calls internally to the appropriate manager routine. This
routing is based on the interface and version, operation and any object
requested by the call.

It indicates that server routes (to call methods) are based on the operation,
interface and object.

- Operation: To indicate the method to call, and operation number is
             specified as indicated in the second step of 2.3.3.2 (Client
             Binding Steps).
- Interface: An interface is a set of remotely callable operations offered by a
             server and invokable by clients. (2.1.1.1)
- Object: Is the manager that implements the interface, as stated in section
          Interface and Manager Selection of 2.3.3.3. It is not mandatory, can
          be nil.

To call a method, a client must send a request message as defined in 2.6.4.9,
that contains these identifiers:

- opnum: The opnum field identifies the operation being invoked within the
         interface.
- p_cont_id (Context ID in Wireshark): The p_cont_id field holds a presentation
                                       context identifier that identifies the
                                       data representation and interface, as
                                       defined in 12.6.3.4 (Context Identifiers).
- object: The object field is contained if the PFC_OBJECT_UUID is set. (Could be
          interesting to create a keyword dce_object for matching this UUID)

Therefore, to get the correct method to invoke, the server must map the context
to the correct interface. This is negotiated by the bind request

Interfaces are first negotiated using the bind message (12.6.4.3), contained in
the p_context_elem array. Then they are accepted or rejected using the bind_ack
message (12.6.4.4).

Once these contexts are established, both client and server can use the context
id, which is the index of the p_context_elem array, to refer the interface they
are using.

Moreover, in the middle of the connection, the context can be changed with the
alter_context message.

This is way suricata shouldn't delete the bindack attribute, that contains
the contexts, used by match_backuuid. This is the only way to know the interface
a request message is referring to.

ticket: 4769
https://redmine.openinfosecfoundation.org/issues/4769

(cherry picked from commit 1aca2676a6)
5 years ago
Eloy Pérez González 3028bdadc5 smb/dce_iface: avoid deleting current ifaces from state
The smb dce_iface keyword must match for all those dcerpc requests
and responses sent in the context of the given interface. They are
not matching as the current bind interfaces are deleted by any
non bind message.

Ticket: 4767
(cherry picked from commit bff0774767)
5 years ago
Eloy Pérez González 9bc31affa4 smb/dce_iface: use DCERPC_TYPE_REQUEST
The smb dce_iface keyword must match for all those dcerpc requests and
responses sent in the context of the given interface. They are not
matching because in rs_smb_tx_get_dce_iface, x.req_cmd is erroneously
compared with 1. Fix this by comparing with DCERPC_TYPE_REQUEST instead.

Ticket: 4767
(cherry picked from commit 1ae22fd5de)
5 years ago
Eloy Pérez González 09c8b17bf7 smb/dce_opnum: move range if to outer context
The smb dce_opnum matches all the opnums that are higher that the
indicated opnum. This is due the range comparison if was put in the
exact comparison context, and in case the opnum doesn't match exactly,
then the range comparison is triggered (the upper limit is always true).

Move the erroneus if to the outer context, as else option of the block
checks if comparison should be exact or range.

Ticket: 4767
(cherry picked from commit 333db3b385)
5 years ago
Eloy Pérez González 97d90ea62c smb/dce_opnum: use DCERPC_TYPE_REQUEST
The smb dce_opnum keyword doesn't match the dcerpc requests/responses.
This occurs because in the rs_smb_tx_match_dce_opnum function, the
x.req_cmd is matched against the erroneous code 1. Fix this by using
DCERPC_TYPE_REQUEST for the comparison instead.

Ticket: 4767
(cherry picked from commit 8dca3d0416)
5 years ago
Jason Ish a3b803d150 dns: add dns flag to dns request logging
Ticket #4515

(cherry picked from commit 0861b66e15)
5 years ago
Odin Jenseg 4318e9726f dns: Logging of Z-bit
[Edit by Jason Ish: fix flag bit value]

Ticket #4515

(cherry picked from commit dfb6f105e8)
5 years ago
Jason Ish 6a55c14c77 dns: create transaction even if z-bit was set
It appears that DNS servers will still process a DNS request even if the
z-bit is set, our parser will fail the transaction. So create the
transaction, but still set the event.

Ticket #4924

(cherry picked from commit fcbdc30426)
5 years ago
Philippe Antoine 9d7630d142 mqtt: fix transaction completion
Ticket: 4862

A transaction to client is always considered
complete in the direction to server and vice versa.
Otherwise, transactions are never complete for
AppLayerParserTransactionsCleanup

(cherry picked from commit 1b10848d84)
5 years ago
Jason Ish 19d9a05549 dhcp: fix url in comment
rustdoc was complaining about the format of the URL in a comment
while trying to generate documentation. Convert the comment to a
non-rustdoc comment for now to satisfy rustdoc.

(cherry picked from commit eb6cc62937)
5 years ago
Philippe Antoine f5049041be ntp: fixes leak of de_state
Bug: #4752.
(cherry picked from commit 3212fa7d2b)
5 years ago
Philippe Antoine 7e8247164c snmp: fixes leak of de_state
Bug: #4752.
(cherry picked from commit 28a3181a2d)
5 years ago
Philippe Antoine 5c95c28387 smb: midstream probing checks for netbios message type
If it is available

Bug: #4620.
(cherry picked from commit f37240a3e2)
5 years ago
Philippe Antoine 8b54e8fdf0 rust: right condition for both uint to be zero
Theay can overflow leading to their addition to be zero

If a NFS read reply indicates a count of 0xFFFFFFFF

Bug: #4680.
(cherry picked from commit 8f8823b6f2)
5 years ago
Philippe Antoine f992e2adb1 style: remove latest warnings
about unused variables

(cherry picked from commit cb30772372)
5 years ago
Shivani Bhardwaj 2616afa625 ssh: fix match on ssh banner
Default detection handling of SSH should not be to pass in case the
direction was not a match but to treat it like it was meant to server.
5 years ago
Philippe Antoine e5ca0f7abb http2: better rust lifetimes
so that borrow check gets happy

(cherry picked from commit 56fae072b2)
5 years ago
Philippe Antoine 2b4be3187e http2: better rust style
(cherry picked from commit 596a4a9d6e)
5 years ago
Philippe Antoine 4f15d53f1f http2: concatenate one headers multiple values
For detection, as is done with HTTP1

(cherry picked from commit 48ed874dda)
5 years ago
Philippe Antoine ff698f522f http2: generic http2_header_blocks
so as not to forget continuation and push promise
when iterating over headers

(cherry picked from commit e3ff0e7731)
5 years ago
Philippe Antoine 9556b376f9 http2: http.header keyword now works for HTTP2
As well as http.header.raw

(cherry picked from commit 0b0649d98e)
5 years ago
Philippe Antoine 240f779b99 http2: http.header_names keyword now works for HTTP2
(cherry picked from commit 9b9f909d7d)
5 years ago
Philippe Antoine 629a8226a0 http2: http.host normalized keyword now works for HTTP2
(cherry picked from commit 547e9f4ab4)
5 years ago
Philippe Antoine 59a109c049 http2: turn Host header into authority during upgrade
HTTP1 uses Host, but HTTP2 uses rather :authority cf HPACK

(cherry picked from commit 75f75e1eb0)
5 years ago
Philippe Antoine cf04608992 dns: improve probing parser
Checks opcode is valid
Checks additional_rr do not exceed message length
Better logic for incomplete cases

(cherry picked from commit 9e7ea631b2)
5 years ago
Philippe Antoine c42b81b769 nfs: improve probing parser
Checks credentials flavor is known

(cherry picked from commit b3c1f2ab48)
5 years ago
Philippe Antoine 8704057df0 http2: better file tracking
If an HTTP2 file was within only ont DATA frame, the filetracker
would open it and close it in the same call, preventing the
firther call to incr_files_opened

Also includes rustfmt again for all HTTP2 files

(cherry picked from commit bb98a18b3d)
5 years ago
Victor Julien 12e71ed090 smb: add debug validation on file counts
(cherry picked from commit c9cee7af49)
5 years ago
Victor Julien c7da7215db smb: count files in tx
(cherry picked from commit 114d3ba730)
5 years ago
Victor Julien f8a50a66ca http2: support per-tx file accounting
(cherry picked from commit c1dfb619c4)
5 years ago
Victor Julien bed74c7fbc nfs: add debug validation on file counts
(cherry picked from commit 1b3c3225cd)
5 years ago
Victor Julien e9ff5e2c6e nfs: support per-tx file accounting
(cherry picked from commit 1d48601c25)
5 years ago
Victor Julien 8f2f2b55ee nfs: don't reuse file transactions
After a file has been closed (CLOSE, COMMIT command or EOF/SYNC part of
READ/WRITE data block) mark it as such so that new file commands on that
file do not reuse the transaction.

When a file transfer is completed it will be flagged as such and not be
found anymore by the NFSState::get_file_tx_by_handle() method. This forces
a new transaction to be created.

(cherry picked from commit 67759795c6)
5 years ago
Victor Julien 717c6b021e filestore: track files getting stored per tx
Avoid evicting a tx before the filedata logger has decided it is
done.

(cherry picked from commit 56d3e28a3a)
5 years ago
Victor Julien 4151173e1a app-layer/transactions: track files opens and logs
To make sure a transaction is not evicted before all file logging is complete.

(cherry picked from commit c78f5ac316)
5 years ago
Philippe Antoine a900dea72e http2: support deflate decompression
cf #4556

(cherry picked from commit 1378b2f451)
5 years ago
Victor Julien b46b2936f2 http2: set Debug on structs
(cherry picked from commit 20e8f90981)
5 years ago
Philippe Antoine 9d9209b65f rust: bump bitflags dependency version
So that lexical-core, needed by nom, and using bitflags
is used with version 0.7.5 instead of version 0.7.0
which fixed the fact that BITS is now a reserved keyword
in nightly version

(cherry picked from commit 0105d4f017)
5 years ago
Jason Ish c37f4b7e54 rust/ike: suppress some compile warnings when not debug
Due to ef5755338f, the variables
that are only used for debug output now emit unused variable
warnings when Suricata is not built with debug. Prefix these
variables with _ to suppress these warnings.
5 years ago
Shivani Bhardwaj 6a53185797 ikev2: remove transforms fields 5 years ago
Philippe Antoine d70bbb24f4 rust: SCLogDebug is real nop when built as release
Before, even if there were no outputs, all the arguments
were evaluated, which could turn expensive

All variables which are used only in certain build configurations
are now prefixed by underscore to avoid warnings

(cherry picked from commit ef5755338f)
5 years ago
Philippe Antoine 234cafdcfe detect: use u32 for InspectionBufferMultipleForList
So that we do not have an endless loop casting index to
u16 and having more than 65536 buffers in one transaction

Changes for all protocols, even ones where it is impossible
to have such a pattern, so as to avoid bad pattern copy/paste
in the future

(cherry picked from commit 7d0a39412b)
5 years ago
Philippe Antoine 80c3bc4827 dcerpc: handles bigger inputs than 2^16
By comparing integers with the largest size

(cherry picked from commit 6f03ee2e47)
5 years ago
Jason Ish 0e8a248b99 rust/template: suppress unread variable warning
Suppress the warning about an unused variable in the template
parser. As this is just a template I think this is OK, however
master should make sure this variable is used, if only to be
more self documenting.
5 years ago
Sascha Steinbiss b6fd5e0c2d rust: fix warnings with nightly 5 years ago
Philippe Antoine 41054a68ef http2: http.cookie keyword now works for HTTP2
(cherry picked from commit 999327ba1f)
5 years ago
Philippe Antoine 7d5dd8b5b2 http2: makes all HTTP1 header keywords work
(cherry picked from commit 017e39d8fd)
5 years ago
Philippe Antoine f81985596b http2: http.host.raw keyword now works for HTTP2
(cherry picked from commit df039555bc)
5 years ago
Philippe Antoine 9c1349ac18 http2: http.method keyword now works for HTTP2
(cherry picked from commit 1e82d0b3c8)
5 years ago
Philippe Antoine a79b784edd http2: http.user_agent keyword now works for HTTP2
(cherry picked from commit 47928babfc)
5 years ago
Philippe Antoine 00eadac277 http2: http.uri keyword now works for HTTP2
cf #4067

(cherry picked from commit a98d0fe6ed)
5 years ago
Philippe Antoine 9aa5c6aff0 rust: fix app-layer parser flags
This especially allows for SSH bypass to work

(cherry picked from commit fdab22d924)
5 years ago
Philippe Antoine 437b7d3348 ftp: completely parses pasv and epsv responses
(cherry picked from commit ca6e434e0b)
5 years ago
Philippe Antoine e0764e1e12 http2: make decompression a configure-time option 5 years ago
Philippe Antoine 56bda0f9cb http2: have filecontainer for both directions
(cherry picked from commit 6fe8bce3b0)
5 years ago
Philippe Antoine 2504b96c48 http2: adds check about dynamic headers table size
(cherry picked from commit 3de0123ffb)
5 years ago
Victor Julien a3f94435d3 http2: remove dead code
(cherry picked from commit de280c47d9)
5 years ago
Philippe Antoine eb250e5512 http2: remove assertion which can be wrong
Brotli decoder stops consuming input it it reaches the
end of its input

(cherry picked from commit b3c502d572)
5 years ago
Philippe Antoine 6109855bca http2: pass data through when decompression fails
as is done for HTTP1

(cherry picked from commit 1ca4f041bb)
5 years ago
Philippe Antoine 899a9b8e17 http2: decompression for files
gzip and brotli decompression for files

(cherry picked from commit d861228214)
5 years ago
Philippe Antoine 0e6ffb966f rust: BIT_U16 macro utility
(cherry picked from commit 2e46b5d100)
5 years ago
Philippe Antoine 9287f6ae7f rust: better panic message for missing file config
(cherry picked from commit aee8e60149)
5 years ago
Jason Ish a8e1172e7f rust: pin memchr to ~2.3
2.4+ requires a newer version of Rust.
5 years ago
Philippe Antoine 76a981f7a2 rdp: correctly returns incomplete in parse_tc
Adding the already consumed bytes
In case an incomplete tls handshake is handled with/after
a refular rdp t123_tpkt

(cherry picked from commit 6da9a37285)
5 years ago
Philippe Antoine effa7ac54f kerberos: fix probing parser tag condition
according to the comment

(cherry picked from commit cb150e97d0)
5 years ago
Philippe Antoine 90fdb53439 smb: relax probing parser to handle first NBSS message
cf dcerpc-udp S-V test :
First message is Message Type: Session request (0x81)
Second message is SMB

(cherry picked from commit 8307010255)
6 years ago
Philippe Antoine bfa66c6d6c smb: probing parser for start and midstream
The probing parser is more strict at the start of the stream

(cherry picked from commit 1b6e81cd72)
6 years ago
Philippe Antoine fe50461346 smb: split probing function for code style
Introduces rs_smb_probe_tcp_midstream

(cherry picked from commit 9dc5258a21)
6 years ago
Philippe Antoine 2c9a2cc895 protodetect: rename direction to flags
And use whole flags in AppLayerProtoDetectPPGetProto

(cherry picked from commit c6aadf0dfa)
6 years ago
Shivani Bhardwaj dd2285724e dcerpc: trigger raw assembly on record completion
(cherry picked from commit 0ac5c5376a)
6 years ago
Shivani Bhardwaj 772b8f61e7 rust/context: add AppLayerParserTriggerRawStreamReassembly
(cherry picked from commit c77c8e7005)
6 years ago
Shivani Bhardwaj a0fce7bb4e dcerpc/udp: improve detection
Lately, Wireguard proto starting w pattern |04 00| is misdetected as
DCERPC/UDP which also starts with the same pattern, add more checks
to make sure that it is the best guess for packet to be dcerpc/udp.

(cherry picked from commit f967a49104)
6 years ago
Shivani Bhardwaj d7a633a684 dcerpc: add probe function
(cherry picked from commit 3641f1b522)
6 years ago
Shivani Bhardwaj f8f0c2534e rust/applayer: split EOF flag per direction
(cherry picked from commit d7a3523b12)
6 years ago
Shivani Bhardwaj 6801590aa1 dcerpc/udp: remove transmute
The book defines transmute as "This is really, truly, the most horribly unsafe
thing you can do in Rust. The guardrails here are dental floss."
Transmute can result into mind boggling undefined behaviors. Get rid of
it wherever possible.

(cherry picked from commit 0ca8591994)
6 years ago
Victor Julien 5c940c363c rust: require test-case 1.0.1; don't use 1.1 6 years ago
Philippe Antoine f574663352 http2: files inspection API fixes
uses right transaction id for file tracker
uses FILE_USE_DETECT for good matches with keyword startswith
6 years ago
Philippe Antoine a63ee5adbd http2: allow multiple size updates in one headers batch
cf RFC 7541 section 4.2
6 years ago
Philippe Antoine 6181459086 smb: do not rely on one valid NBSS byte for probing
Need to have the SMB header so as to validate
6 years ago
Jason Ish f3c59ef8a6 rust: handle windows naming change from .lib to .a
Prior to Rust 1.44, Cargo would name static libs with the .lib
extension. 1.44 changes this extension to .a when running under
a GNU environment on Windows like msys to make it more similar
to other unix environments.

Now assume static library name to be the same on Windows and
unix, but rename the .lib if found to still support older
versions of Rust on Windows.
6 years ago
Victor Julien ba781265a4 dcerpc/udp: fix transaction handling and logging
Implement missing transaction handling.

Fix logging wrongly casting 'state' to DCERPCState instead of
DCERPCUDPState leading to crashes and malformed output.

Remove unused fields from DCERPCUDPState.
6 years ago
Philippe Antoine 8db78208f9 rust: fix warnings found by nightly compiler
warning: getting the inner pointer of a temporary `CString`
this `CString` is deallocated at the end of the statement,
bind it to a variable to extend its lifetime
6 years ago
Jason Ish 2f81f3fbe9 rust/log: clarify comment in non-debug mode SCLogDebug 6 years ago
Jason Ish a453d28bc6 rust/log: order log macros in descending order
Readability cleanup.
- error, notice, ... debug
6 years ago
Jason Ish 411a5d41c1 rust/log: expand macros after checking log level
Expand macros in the do_log macro after checking the log level
instead of each log macro (ie: SCLogDebug) expanding the macros
then passing off to do_log to have the log level check.

Will eliminate any expense of expanding macros if this log level
does not permit the given message to be logged.

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/4114
6 years ago
Shivani Bhardwaj 269324e84d dcerpc/log: Log fields particular to an RPC version
Log fields that only are meant to be in a PDU for a particular RPC
version. Since DCERPC/UDP works on RPC version 4 and DCERPC/TCP works on
RPC version 5, there are certain fields that are particular to each
version.
Remove call_id from the logger for UDP.
Add activityuuid and seqnum fields to the logger for UDP.
call_id and (activityuuid + seqnum) fields are used to uniquely pair a
request with response for RPC versions 5 and 4 respectively.
6 years ago
Ilya Bakhtin 2033f386f9 rust/dcerpc: Remove redundant fields 6 years ago
Ilya Bakhtin 2840a2e064 rust/dcerpc: Make tx_id u64 6 years ago
Ilya Bakhtin 6916b63f09 dcerpc/udp: Fix pairing of request response
So far, request and response were paired with serial number fields in
the header. This is incorrect. According to
https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm,
"Together, the activity UUID and the sequence number uniquely identify
a remote procedure call."

Hence, add activity uuid and sequence number to the transaction and pair
the request accordingly. Remove incorrect handling of this and fix
tests.
6 years ago
Ilya Bakhtin e9b21553cc rust/dcerpc: Add UDP flag definitions 6 years ago
Victor Julien 51f4e4d0b7 dcerpc/udp: add missing tx free logic 6 years ago
Victor Julien 9f9c29a14a dcerpc: fix stream flag handling
Only hardcoded direction flags were passed to the parser, not the
full range.

Handle receiving an EOF flag w/o data.

Bug: #3856
6 years ago
Victor Julien f31372ad1d dcerpc/tcp: fix compile warning
warning: variable does not need to be mutable
    --> src/dcerpc/dcerpc.rs:1036:42
     |
1036 |                     let tx = if let Some(mut tx) = self.get_tx_by_call_id(current_call_id, core::STREAM_TOCLIENT) {
     |                                          ----^^
     |                                          |
     |                                          help: remove this `mut`
     |
     = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
    --> src/dcerpc/dcerpc.rs:1061:30
     |
1061 |                         Some(mut tx) => {
     |                              ----^^
     |                              |
     |                              help: remove this `mut`
6 years ago
Victor Julien 67b5295bbc dcerpc/tcp: add missing detect state cleanup 6 years ago
Philippe Antoine 1fd6f5bc61 http2: asymetric sizes for headers tables
The headers table from client to server
and the one from server to client
may have different maximum sizes
(even if both endpoints have to keep both tables)
6 years ago
Philippe Antoine aaa69fe3c5 smb: resistance against padding evasions
Scenario is use of dummy padding in write AndX request
or other similar commands using a data offset.

Parsing skips now these dummy bytes, and generates one event
6 years ago
Philippe Antoine caa7946888 smb: adds file overlap event against evasions
Evasion scenario is
- a first dummy write of one byte at offset 0 is done
- the second full write of EICAR at offset 0 is then done
and does not trigger detection

The last write had the final value, and as we cannot "cancel"
the previous write, we set an event which is then transformed into
an app-layer decoder alert
6 years ago
Philippe Antoine 3e96f96153 rdp: fix incomplete result
Aggregating the consumed bytes
6 years ago
Jason Ish 0529a00ffd dhcp: set unidirection transaction flag 6 years ago
Jason Ish 3036ec4db0 ikev2: set unidirection transaction flag 6 years ago
Jason Ish ff674d0cd0 mqtt: set unidirection transaction flag 6 years ago
Jason Ish 54d5f336d4 sip: set unidirection transaction flag 6 years ago
Jason Ish 1d40d0c5f9 rdp: set unidirection transaction flag 6 years ago
Jason Ish f7dee602e9 krb5: set unidirection transaction flag 6 years ago
Jason Ish 984d3c7f20 ntp: set unidirection transaction flag 6 years ago
Jason Ish fc7d59d92f snmp: set unidirectional transaction flag 6 years ago
Philippe Antoine 64fcba228b http2: complete parsing of priority frames 6 years ago
Philippe Antoine c300a859a0 http2: keep track of dynamic headers table size
And evict entries accordingly to maximum size
6 years ago
Philippe Antoine 1a21eea0e9 http2: variable size integers decoded everywhere 6 years ago
Philippe Antoine b21acfbf21 http2: StreamIdReuse frame types exceptions
Also handles better the state so as not to revert from
HTTP2StateHalfClosedClient to HTTP2StateDataServer and not
go to final HTTP2StateClosed
6 years ago
Philippe Antoine 89573060d9 http2: use variable integer for headers lengths 6 years ago
Shivani Bhardwaj 97c67cd5ce dcerpc: fix gap handling
This patch addresses issues discovered by redmine ticket 3896. With the
approach of finding latest record, there was a chance that no record was
found at all and consumed + needed became input length.

e.g.
input_len = 1000
input = 01 05 00 02 00 03 a5 56 00 00 .....

There exists no |05 00| identifier in the rest of the record. After
having parsed |05 00|, there was a search for another record with the
leftover data. Current data length at this point would be 997. Since the
identifier was not found in the data, we calculate the consumed bytes at
this point i.e. consumed = current_data.len() - 1 which would be 996.
Needed bytes still stay at a constant of 2. So, consumed + needed = 996
+ 2 = 998 which is lesser than initial input length of 1000 and hence
the assertion fails.

There could be two fixes to this problem.
1. Finding the latest record but making use of the last found record in
   case no new record was found.
2. Always use the earliest record.

This patch takes the approach (2). It also makes sure that the gap and
current direction are the same.
6 years ago
Philippe Antoine 4f963717f8 fuzz: better configure checks for MSAN building
More compatible check for rust nightly
Checks for CARGO_BUILD_TARGET
Builds release or debug mode independently
6 years ago
Victor Julien 5d985c4271 dcerpc: implement tx free function 6 years ago
Victor Julien 8b2886635f dcerpc/tcp: implement trunc logic
When one side of the connection reaches the STREAM_DEPTH condition the
parser should be aware of this. Otherwise transactions will forever be
waiting for data in that direction.
6 years ago
Victor Julien 4da0d9bdea applayer/rust: expose truncate callback 6 years ago
Shivani Bhardwaj 301454e9e4 dcerpc: fix datatypes while handling stub data 6 years ago
Shivani Bhardwaj 3fd9a3d420 dcerpc: fix datatype for stub data len 6 years ago
Philippe Antoine 222b386102 rust: rebuilds std when building fuzzers
so as to have MSAN working
6 years ago
Philippe Antoine 15447cc672 dceprc: signature rust check with is_char_boundary
before calling split_at which would panic
6 years ago
Philippe Antoine 6694737fcf http2: settings from http1 upgrade 6 years ago
Philippe Antoine 7011bddf84 http2: mimic HTTP1 request from upgrade 6 years ago
Philippe Antoine 9d1b030ff0 http2: first connection upgrade from http1 6 years ago
Philippe Antoine 547d6c2d78 applayer: pass parameter to StateAlloc
This parameter is NULL or the pointer to the previous state
for the previous protocol in the case of a protocol change,
for instance from HTTP1 to HTTP2

This way, the new protocol can use the old protocol context.
For instance, HTTP2 mimicks the HTTP1 request, to have a HTTP2
transaction with both request and response
6 years ago
Sascha Steinbiss ed9fed4958 mqtt: add some extra tests for varint parsing 6 years ago
Philippe Antoine 1a88df7e88 http2: handles incomplete frames after banner
To signal incomplete data, we must return the number of
consumed bytes. When we get a banner and some records, we have
to take into account the number of bytes already consumed by
the banner parsing before reaching an incomplete record.
6 years ago
Philippe Antoine 7ab9a01db2 mqtt: limit size of variable integer 6 years ago
Philippe Antoine e3b28bcf2a http2: returns error in case of index 0
As is documented in RFC 7541, section 6.1
The index value of 0 is not used.  It MUST be treated as a decoding
error if found in an indexed header field representation.
6 years ago
Jason Ish e9fec043b5 rust/util: expose function to test strings for valid UTF-8
rs_check_utf8 will check that the provided string is valid
UTF-8 by converting it to a Rust string and returning true
or false.
6 years ago
Simon Dugas 7f26246ce1 dns: parse and log fields for SOA record type
Added `dns_parse_rdata_soa` to parse SOA fields into an `DNSRDataSOA`
struct.

Added logging for answer and authority SOA records in both version
1 & 2, as well as grouped formats.
6 years ago