Commit Graph

12247 Commits (67f5720885a64c56a7357dc00538ef2ddef53df4)
 

Author SHA1 Message Date
Jason Ish 67f5720885 release: 6.0.6; update changelog 4 years ago
Philippe Antoine 5df3973cc9 output: fix integer warnings
Ticket: 4516

(cherry picked from commit e3180e3248)
4 years ago
Philippe Antoine e55eeb3bde protocol: forbids concurrent protocol upgrades
Ticket: 5243

When switching from SMTP to TLS, and getting HTTP1 instead of
expected TLS, and HTTP1 requesting upgrade to HTTP2, we do not
overwrite the alproto_orig value so as not to have type confusion
in AppLayerParserStateProtoCleanup

(cherry picked from commit cedffdf14c)
4 years ago
Philippe Antoine 2c7c7cf315 output: skip files logging for ICMP packets
Ticket: #5408
(cherry picked from commit f8bf581775)
4 years ago
Philippe Antoine a71a474302 output: use flow's proto for file loggers
As there can be an ICMP packet which gets related to a TCP flow.

Ticket: #5408
(cherry picked from commit 5781631f85)
4 years ago
Eric Leblond 789b1ab4df output/alert: don't call basic logging twice
Issue: 4106
(cherry picked from commit 264eddb81f)
4 years ago
Philippe Antoine 84885c11c0 ftp: optimized tx iterator
To be more efficient with larger number of transactions.

Ticket: #5314
(cherry picked from commit 5a31b3508d)
4 years ago
Philippe Antoine ac6cdd973c event: only sets APPLAYER_UNEXPECTED_PROTOCOL once
If f->alproto == ALPROTO_UNKNOWN, we do not know the new protocol
yet, so we do not set the event yet.

(cherry picked from commit e692530021)
4 years ago
Philippe Antoine 48206f373d events: reset logged event
Otherwise, if we log a first app_layer_event, then reset
with AppLayerDecoderEventsResetEvents for a new packet,
then get another event, it does not get logged

Ticket: #5391
(cherry picked from commit b0298dd046)
4 years ago
Victor Julien c08a929de1 detect: impose limits on pcrexform
Impose match and recursion limits on pcrexform keywords.

Based on: 585e5e0d3c ("detect: impose limits on pcrexform")

Bug: #5414.
4 years ago
Victor Julien ac93f568eb fuzz/mime: fix call conditions and args
The SMTP parser should not supply lines w/o EOL chars to the mime
parser unless its in the BODY parsing stage. Mimic this in the fuzz
target by testing the state for inputs that have no EOL.

Additionally, make sure the delim cnt reflects the missing EOL.

(cherry picked from commit 816bbeb7dc)
4 years ago
Victor Julien 3384ca9be2 mime: fix and cleanup tests
Line count check was failing after recent delim handling updates.

(cherry picked from commit 074cfb5c68)
4 years ago
Victor Julien 7256445c21 mime: fix corner case
Fix a corner case where a base64 sequence including a space was followed
by a newline in the input data.

(cherry picked from commit d81582c4a2)
4 years ago
Victor Julien d15e0d5baf mime: add base64 related debug messages
(cherry picked from commit 5805ed47f5)
4 years ago
Victor Julien 9c25d10970 mime: improved empty line handling
Make sure a new body is not set up on empty lines unless it is
a body that is not encoded as base64/quoted printable.

(cherry picked from commit 41c2c1ed5a)
4 years ago
Victor Julien 7061dec732 smtp: fix passing a wrong delim len around
(cherry picked from commit 6e2c066ce1)
4 years ago
Victor Julien 58bce05764 mime: properly pass full lines to non-decoded body
Use actual delim count and make sure we also pass on empty lines
(so delim(s) only).

(cherry picked from commit b82b8825e7)
4 years ago
Victor Julien 420760a7ac mime/base64: fix final data not getting processed
If the last data of the body was not a multple of 4 and not padded
to be a multiple of 4, it would not be processed.

(cherry picked from commit 0d6ab727c5)
4 years ago
Victor Julien 909a3fdf42 stream: fix GAP check
Gap check would consider a GAP when the current data was in fact
exactly not a gap, but next segment(s) were already available.

(cherry picked from commit 100d821a9f)
4 years ago
Victor Julien 5740d10e34 mime: remove unused 'linerem' logic
(cherry picked from commit 0871029d17)
4 years ago
Victor Julien 0a6c61a564 smtp/mime: fix parsing edge case
Correctly track "remaining" bytes after partial base64 decoding.

Add comment clarifications and debug validation checks.

(cherry picked from commit 5953a7d2eb)
4 years ago
Victor Julien b4fd4c048b smtp: skip preprocessing for mime headers
Mime parser doesn't expect partial lines, which preprocessing can
provide. Add a check to let mime headers be handled by regular line
parsing.

(cherry picked from commit a38f2f2a52)
4 years ago
Victor Julien bf5d9d542b detect: set drop reason for rule based drops
Call `PacketDrop` with drop reason for drops, keep old logic
in place for the rest.

(cherry picked from commit a89840929b)
4 years ago
Victor Julien a32b02fb65 detect/tests: improve detection entry
Lots of tests still use SigMatchSignatures as their main detection
entry function, which bypassed some logic. Make it match main logic
more closely.

(cherry picked from commit e36b9b89a1)
4 years ago
Victor Julien 5fcbc8bb50 tests: fix drop test; cleanup
SigTestDropFlow04 was incorrectly expecting an alert in the packet
following a "drop" packet. The first drop is applied to the flow, so
it should lead to the 2nd packet being dropped before inspection is
run.

Clean up the test as well.

(cherry picked from commit 3874d08015)
4 years ago
Victor Julien 660484404f exceptions: initial exception-policy implementation
Adds a framework for setting exception policies. These would be called
when the engine reaches some kind of exception condition, like hitting
a memcap or some traffic processing error.

The policy gives control over what should happen next: drop the packet,
drop the packet and flow, bypass, etc.

Implements the policy for:

    stream: If stream session or reassembly memcaps are hit call the
    memcap policy on the packet and flow.

    flow: Apply policy when memcap is reached and no flow could be
    freed up.

    defrag: Apply policy when no tracker could be picked up.

    app-layer: Apply ppolicy if a parser reaches an error state.

All options default to 'ignore', which means the default behavior
is unchanged.

Adds commandline options: add simulation options for exceptions. These
are only exposed if compiled with `--enable-debug`.

Ticket: #5214.
Ticket: #5215.
Ticket: #5216.
Ticket: #5218.
Ticket: #5194.
(cherry picked from commit 8580499ded)
4 years ago
Victor Julien 3a55873eb8 eve/drop: log drop reason
Ticket: #5202.
(cherry picked from commit 0035673208)
4 years ago
Victor Julien aa66765253 flow: log action applied to all packets
Log if action applied to whole flow is drop or pass.

(cherry picked from commit 9a09fe454b)
4 years ago
Victor Julien 38744135ef detect: enforce flow drops earlier
Enforcing flow drops is now done earlier in the detection engine and
moved out of the IP-only engine where it didn't belong.

(cherry picked from commit 802c1ffee3)
4 years ago
Victor Julien d8b5d3d34a clang-format: disable for option table 4 years ago
Lukas Sismis 4c4b1de168 bypass: fix memory leak - reassign of FlowBypassInfo
In some situations bypass callback is called on already bypassed
flow. This allocates FlowBypassInfo structure for the flow but
does not check if the flow already has one.

Issue: #5368
(cherry picked from commit 05797c45bb)
4 years ago
Lukas Sismis 8fa5f3bdd4 bypass: af-packet: fix memory leak - reassign of EBPFBypassData
AF-Packet bypass function in some situations allocates EBPF bypass data
for an already bypassed flow and assigns it to the flow without any checks

Issue: #5368
(cherry picked from commit 8845c07a90)
4 years ago
Victor Julien e9b084e8ca detect/threshold: fix offline time handling issue
Due to the TIMEVAL_DIFF_SEC calculating the delta into an unsigned
integer, it would underflow to a high positive value leading to
and incorrect result if the packet timestamp was below the timestamp
for the threshold entry. In normal conditions this shouldn't happen,
but in offline mode each thread has its own concept of time which
might differ significantly based on the pcap. In this case the
overflow would be very common.

Changing it to a signed value calculation triggered fuzz undefined
behavior if the packet timeval was very high, so this patch takes a
new approach where it no longer calculates a diff but sets up the
"seconds" value we compare against as a timeval itself, and uses
that to compare.

Fixes: 9fafc1031c ("time: Add TIMEVAL_EARLIER and TIMEVAL_DIFF_SEC macros.")
Fixes: 82dc61f4c3 ("detect/threshold: Refactor threshold calculation to handle by_rule and by_both.")

Uses add `timeradd` specific version where available.

Bug: #5386.
(cherry picked from commit df2e408d96)
4 years ago
Victor Julien 643d502d9e stream/midstream: fix double flow reverse case
In the case of midstream SYN/ACK pickup, we reverse the flow based on
the SYN/ACK. If we then later get traffic that appears to be in the
reverse direction based on the app-layer, we would reverse it again.
This isn't correct. When we have the SYN/ACK we know the flow's real
direction.

(cherry picked from commit fea374626a)
4 years ago
Victor Julien 1f31eb9e58 app-layer: don't switch dir if proto already known
(cherry picked from commit 86e8611f5e)
4 years ago
Victor Julien 91ea80291f detect/dcerpc: simplify keyword validation
Now that the engine understands the relation between SMB and DCERPC better
we can get rid of some of the special case handling in keywords.

(cherry picked from commit 84e26d670e)
4 years ago
Victor Julien e65ab0fc90 detect/dcerpc: apply dcerpc to smb as well
So 'alert dcerpc' also matches if the DCERPC is over SMB.

Explicitly refuse smb keywords for the 'dcerpc' app proto setting:
`alert dceprc ... smb.share; ...` is rejected.

Remove a now useless special case in the stateless rule processing
matching for dcerpc/smb.

Bug: #5208.
(cherry picked from commit 7d38f5667d)
4 years ago
Victor Julien b588c8623f github/workflows: add cargo for all Ubuntu jobs
(cherry picked from commit 7ced8de6c4)
4 years ago
Victor Julien e9b88f67cc file: consistently track size of gaps
Until now only the size of gaps counted in the regular append, not
close and open.

Bug: #5392.
(cherry picked from commit 71ef62bfc5)
4 years ago
Michael Tremer aeee505ff2 stream: tcp: Handle retransmitted SYN with TSval
For connections that use TCP timestamps for which the first SYN packet
does not reach the server, any replies to retransmitted SYNs will be
tropped.

This is happening in StateSynSentValidateTimestamp, where the timestamp
value in a SYN-ACK packet must match the one from the SYN packet.
However, since the server never received the first SYN packet, it will
respond with an updated timestamp from any of the following SYN packets.

The timestamp value inside suricata is not being updated at any time
which should happen. This patch fixes that problem.

Bug: #4376.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
(cherry picked from commit f50af12068)
4 years ago
Victor Julien 9ab4c98430 detect/content: fix FNs due to bad depth calc
When trying to propegate the depth/offset, within/distance chains
a logic error would set too a restrictive depth on a pattern that
followed more than one "unchained" patterns.

Bug: #5162.
(cherry picked from commit 8d20b40cdd)
4 years ago
Victor Julien df0cca4537 detect/content: simplify int bounds checking
Use a macro to validate the ranges for overflows. This removes
the clutter of all the checks and warnings, and also no longer
puts the state machine in an undefined state when hitting such
a condition.

(cherry picked from commit 50d02ebc05)
4 years ago
Philippe Antoine 301af290ca detect: fix integer warnings for content
Ticket: #4516
(cherry picked from commit ac8fb553a1)
4 years ago
Philippe Antoine 249a3b5677 detect: parsing avoiding infinite loop
by comparing size_t to strlen result
Instead of uint16_t which would loop

Ticket: #5310
(cherry picked from commit ced96a8aad)
4 years ago
Jason Ish 6ba16e883e detect: introduce "like" ip-only signature type
Rules that look like they should be IP-only but contain a negated rule
address are now marked with an LIKE_IPONLY flag. This is so they are
treated like IPONLY rules with respect to flow action, but don't
interfere with other IPONLY processing like using the radix tree.

Ticket: #5361
(cherry picked from commit c8a5207083)
4 years ago
Victor Julien 5ed73e839f detect/iponly: remove unused code
(cherry picked from commit 51ef6f4e3a)
4 years ago
Victor Julien 0ffd310180 detect/iponly: include postmatch in determination
(cherry picked from commit beecc1890f)
4 years ago
Victor Julien ca3be76e23 smtp: remove defunct check for line with single LF
Don't fix it as DATA processing needs all the bytes.

(cherry picked from commit 96bb67f474)
4 years ago
Victor Julien 45083caf81 smtp: turn assertions in to debug asserts
(cherry picked from commit 77fae275ef)
4 years ago
Victor Julien 35145c1c6f smtp: simplify preprocess loop
(cherry picked from commit 3a631085bb)
4 years ago