Commit Graph

11806 Commits (3d54a103d0f08bf189f62800e98b06144e44e698)

Author SHA1 Message Date
Lukas Sismis 3d54a103d0 dpdk: improve DPDK thread handling
Ticket: #6106
3 years ago
Shivani Bhardwaj 49ad38329a util/base64: fix tests for RFC2045 3 years ago
Shivani Bhardwaj c2ae87eecf util/base64: update test macro to use user data 3 years ago
Shivani Bhardwaj 62d782156c util/base64: check dest buf size to hold 3Bytes
The destination buffer should be able to hold at least 3 Bytes during
the processing of the last block of data. If it cannot hold at least 3
Bytes, then that may lead to dynamic buffer overflow while decoding.
3 years ago
Shivani Bhardwaj 0e8b451699 util/base64: check for dest buf size in last block
Just like the check for destination buffer size done previously for
complete data, it should also be done for the trailing data to avoid
goind out of bounds.
3 years ago
Shivani Bhardwaj 095c335c72 util/base64: fix padding bytes for trailing data
Padding bytes for the last remainder data should be as follows:

Case   |    Remainder bytes     |    Padding
----------------------------------------------
  I    |              1         |      3
  II   |              2         |      2
  III  |              3         |      1

However, we calculate the decoded_bytes with the formula:
decoded_bytes = ASCII_BLOCK - padding

this means for Case I when padding is 3 bytes, the decoded_bytes would
be 0. This is incorrect for any trailing data. In any of the above
cases, if the parsing was successful, there should at least be 1 decoded
byte.
3 years ago
Shivani Bhardwaj e46b0337e5 util/base64: skip any invalid char for RFC2045
RFC 2045 states that any invalid character should be skipped over, this
is the RFC used by mime handler in Suricata code to deal with base64
encoded data.
So far, only spaces were skipped as a part of implementation of this
RFC, extend it to also skip over any other invalid character. Add
corresponding test.
3 years ago
Shivani Bhardwaj 85ae1d25e4 util/base64: add test for long string w RFC4648 3 years ago
Philippe Antoine fb2fbafed2 http: remove obsolete checks for files
With libhtp having been improved, Suricata does not need to check
that there is either a response line or HTTP/0.9 as libhtp
will trigger the callbacks only in those cases
3 years ago
Jason Ish 4a28f07298 file-data: better error for conflicting keywords
Instead of just erroring out with "rule contains conflicting
keywords", give an error that says what is actually wrong.
3 years ago
Philippe Antoine 4f4651e360 output/file: http2 metdata is logged in http object
as is done for http2 events and alerts.
The http.version integer can help to determine if this is HTTP2

Ticket: #6165
3 years ago
Victor Julien 9b09b29350 detect/fileext: reimplement based on file.name
Ticket: #6194.
3 years ago
Victor Julien 74f095c915 detect/filename: switch to file.name implementation
Ticket: #6194.
3 years ago
Victor Julien 1f22b51848 detect/filemagic: switch to file.magic implementation
Replace implementation of the legacy `filemagic` keyword by the
implementation for the `file.magic` variant. This leads to better
performance and hooks the rules into the detection engine better.

Remove unittests that depended on the old logic.

Ticket: #6194.
3 years ago
Victor Julien ee68947460 detect/tls: minor fingerprint cleanup 3 years ago
Victor Julien c4ed599f9b detect/content: minor cleanup 3 years ago
Jeff Lucovsky b05375f22e config/af-packet: Warn/replace rollover usage
Issue: 6128

No longer permit rollover/cluster_rollover to be used. Usage will
generate a warning message and cluster_flow will be used instead.
3 years ago
Jeff Lucovsky cb30b7185f detect/stat: Display 0 instead of nan
This commit updates the summary message when Suricata terminates.
Without this commit, "nan" was displayed if there were no drops/packets
3 years ago
Juliana Fajardini e306bc6ecc exception: fix use of master switch with default
If an exception policy wasn't set up individually, use the GetDefault
function to pick one. This will check for the master switch option and
handle 'auto' cases.

Instead of deciding what the auto value should be when we are parsing
the master switch, leave that for when some of the other policies is to
be set via the master switch, when since this can change for specific
exception policies - like for midstream, for instance.

Update exceptions policies documentation to clarify that the default
configuration in IPS when midstream is enabled is `ignore`, not
`drop-flow`.

Bug #6169
3 years ago
Philippe Antoine a3168fda78 mime: compute full body md5
Previously, the problem was that nested headers/boundaries were not
used to compute the hash

Solution is to move up the call to the hash computation from
ProcessMimeBody to its caller ProcessMimeEntity, and add a set of
conditions to ensure that we are not in the principal headers.

Ticket: #6185
3 years ago
Philippe Antoine 2a768dfa95 smtp: avoid counting last eol in file
As it is part of the boundary

Ticket: #6023

On the way, look for urls even on incomplete lines
3 years ago
Jason Ish 8511ef5e2d pcap-log: close pcap_dead_handle on close
Fixes leaked handle on exit.
3 years ago
Jason Ish d2a5a55e0a log-pcap: one time errors on file open
If compression was not enabled, the open error was actually suppressed
by default by only being logged at info level, however with
compression it was logged as an error. As opening is retried as long
as it fails to open, make both log as error but wrap in a flag so the
error is logged once until success.
3 years ago
Jason Ish bf589f0812 log-pcap: only open dumper after successful file open (lz4)
When LZ4 compression is enabled, open the dumper after successful open
of the file. The dump handle is what forms the check if opening the
file needs to be retried.

Ticket: #5022
3 years ago
Jason Ish dd786cd6e4 eve/alert: warn on obsolete flags
Log a warning but otherwise ignore obsolete flags under
eve-log.alert. This also prevents accidentially turning off app-layer
logging by attempting to disable a single protocol.

These flags have been deprecated since 5.0, time to stop respecting
them.

Ticket: #6175
3 years ago
Philippe Antoine d99cbc5e0b detect/http: request/response header support multi buffer
Ticket: #6163

That means that we can have rules matching different contents
on different headers.
3 years ago
Philippe Antoine f31ea90836 http: event on chunk extension
Chunks extension are defined in rfc2616 section-3.6.1

Ticket: #6159
3 years ago
Victor Julien 643e674cb2 bpf: remove OpenBSD guards
libpcap bpf functions are supported now.
3 years ago
liaozhiyuan a748164d58 dpdk: support multiple same EAL arguments
DPDK apps can specify multiple arguments of the same
type. YAML format only allows unique keys within a single
node. This commit adds support for multiple EAL arguments
of the same type to be used within suricata.yaml.

Ticket: #5964
3 years ago
Philippe Antoine e75956717d detect/files: centralize definition of protocols
Protocols supporting files are only defined in one place, which
gets used by all keywords, which can handle some exceptions
(like HTTP2 not having file names)
3 years ago
Philippe Antoine 71bab65496 detect/files: reuse AppLayerParserSupportsFiles
rather than relisting the protocols
3 years ago
Juliana Fajardini feb47f9a89 exceptions: fix 'auto' for master switch in IDS
If the master exception policy was set to 'auto' in IDS mode, instead of
just setting the master switch to the default in this case, which is
'ignore', the engine would switch a warning saying that auto wasn't a
valid config and then set the policy to ignore.

This makes 'auto' work for the master switch in IDS, removes function
for setting IPS option and handles the valid IDS options directly from
the function that parses the master policy, as this was the only place
where the function was still called.

Bug #6149
3 years ago
Victor Julien ab667d4d19 pcap: fix reopen logic
Bug: #6081.
3 years ago
Victor Julien 5f187cba82 pcap/runmodes: silence some info messages 3 years ago
Victor Julien 3049151bc2 pcap: free per thread resources
Bug: #4750.
3 years ago
Victor Julien 6c1408c3c2 pcap/file: minor code cleanup 3 years ago
Victor Julien 25396dcd09 threads: cleanup decode_pq handling 3 years ago
Jason Ish 93b64939d1 datasets: flag to disable "write" actions
Add a new configuration flag, "datasets.rules.allow-write" to control
if rules can contain "save" or "state" rules which allow write access
to the file system.

Ticket: #6123
3 years ago
Jason Ish fd79b337ca datasets: don't allow absolute or paths with directory traversal
For dataset filenames coming from rules, do not allow filenames that
are absolute or contain a directory traversal with "..". This prevents
datasets from escaping the define data-directory which may allow a bad
rule to overwrite any file that Suricata has permission to write to.

Add a new configuration option,
"datasets.rules.allow-absolute-filenames" to allow absolute filenames
in dataset rules. This will be a way to revert back to the pre 6.0.13
behavior where save/state rules could use any filename.

Ticket: #6118
3 years ago
Jason Ish f119b29701 lua: disable lua rules by default
To protect against possible supply chain attacks, disable Lua rules by
default. They can be enabled under the "security" section of
suricata.yaml.

Ticket: #6122
3 years ago
Philippe Antoine 0d0f6cde6e fuzz: fuzz HTTP1 target
As we use the name taken from list-app-layer-protos output,
we want http to translate to HTTP1
3 years ago
Shivani Bhardwaj 3aaf37b749 smtp: handle long lines per direction
Issue:
Currently, while handling of long lines, if the line exceeded the limit,
we'd set a variable state->discard_till_lf which will be reset in the
later stages based on the data that arrives. However, because there was
one variable per state, this meant that a later stage in the other
direction could also modify it which is incorrect.

Fix:
Use separate variables for each direction.

Bug 6053
3 years ago
Shivani Bhardwaj 046a192c1f smtp: handle following cmd if LF was found in long line
If a long line had LF post the limit, it should be considered complete
and not wait for the next line to complete it. However, currently, any
following lines were skipped which could sometimes also be important
commands for the entire transaction.

Fix this by setting a flag in case we're truncating a long line but
after having found the LF character.

Bug 5989
3 years ago
Shivani Bhardwaj d83a34397b smtp: add function docs 3 years ago
Shivani Bhardwaj 073f616feb smtp: handle DATA mode in middle of input parsing
Before:
If the input was such that we'd enter DATA mode in the middle, the
entire data would be passed through SMTPGetLine fn and be processed with
line limits etc in place.

After:
Since we don't want any limits to be enforced on DATA, we pass it to
SMTPPreProcessCommands fn to take care of it differently from the
commands.

Bug 5981
3 years ago
Victor Julien 6b5da30d9d streaming/buffer: set errno in allocators
Add wrappers for the default allocators to set SC_ENOMEM.

The stream reassembly wrappers can set both SC_ENOMEM (alloc failed)
and SC_ELIMIT (memcap reached).
3 years ago
Victor Julien 55c6c45ea7 streaming/buffer: turn BUG_ON's into validate checks 3 years ago
Victor Julien db1cb2a032 stream: update insert error checking 3 years ago
Victor Julien 06419cecbc streaming: use error codes to indicate error reason 3 years ago
Victor Julien c3ee3d513f error: SC_ELIMIT for when a limit is reached 3 years ago