Commit Graph

8496 Commits (bc27511e1a068c9a8126657c1cefaff66f0a9c28)
 

Author SHA1 Message Date
Victor Julien 747f042ad6 detect/stream_size: apply rule to packets & stream
The use of stream_size in combination with raw content matches is an
indication that the rule needs to be evaluated per packet, not just
per reassembled stream chunk.
7 years ago
Eric Leblond bff3c662f5 util-random: fix detection of getrandom failure 7 years ago
Eric Leblond 60fc0f9433 util-random: workaround getrandom unavailability
getrandom syscall availability is detected at runtime. So it is
possible that the build is done on a box that supports it but
the run is done on a system with no availability. So a workaround
solution is needed to fix this case.

Also we have seen some issue in docker environment where the build
is detecting getrandom but where it does not work at runtime.

For both reasons, the code is updated to have a call to a fallback
function if ever the getrandom call returns that the syscall is
not available.
7 years ago
Elazar Broad 554ddab330 Fix segfault when the protocol is anything other than HTTP
When a file is transferred over anything other than HTTP, the previously hard-coded HTTP protocol would trigger a non-existent index into htp_list_array_get(), causing a segfault. This patch mimics the logic in detect-lua-extensions.c.
7 years ago
Pierre Chifflier 3f6d488262 Update ntp-parser to 0.2.0 7 years ago
Eric Leblond 96442ab6df util-ioctl: fix a typo in setter message 7 years ago
Eric Leblond b72731652a af-packet: dump counters when timeout occurs
When traffic is becoming null (mainly seen in tests) we reach the
situation where there is timeouts in the poll on the socket and
only that. Existing code is then just looping on the poll and
the result is that the packet iface counters are not updated.

This patch calls the dump counter function to be sure to get
the counter right faster (and not only right at exit).
7 years ago
Victor Julien 4af55a586b hyperscan: don't abort on payloads > 64k
SPM API was recently updated to accept 32 bit length fields instead of
16 bits. This could trigger a BUG_ON in the hyperscan implementation.
7 years ago
Maurizio Abba 578c5bfbdc detect: fix buffer length to uint32
There is a difference in the size of the buffer length as passed from
the content buffers (cfr HttpReassembledBody.buffer_len) and the buflen
variable passed to mpm primitives. This can cause a misdetection
whenever the bufferlen is multiple of 65536 (as uint16(X*65536) == 0).
Increasing the buflen variable type to uint32 solves the issue (this
does not cause any issue with primitives, they all accept uint32).
7 years ago
Victor Julien 10b3c840df mpm/ac-ks: coding style fixes 7 years ago
Victor Julien 31d53a84e2 unified2: address strict aliasing issue 7 years ago
Victor Julien 51691bab10 decode/ipv6: expose addr as 'struct in6_addr' as well 7 years ago
Victor Julien 11b244b399 configure: fix small issue with libevent check 7 years ago
Alexander Gozman b29ddde846 Bug #2466: map SC_LOG_CONFIG level to syslogs LOG_DEBUG 7 years ago
Alexander Gozman 346eff94b0 Print syslog format with SCLogDebug() instead of printf() 7 years ago
Victor Julien 97107a18c1 doc: add by_either to suppress explanation 7 years ago
Victor Julien 1f17d8e5d0 doc: minor fix 7 years ago
Renato Botelho 13d5a5d174 configure: allow to disable libnss and libnspr
Let user chose to disable libnss and libnspr support even if these
libraries are installed in the system. Default remains to enable when
libraries are found and disable parameter were not used
7 years ago
Victor Julien dcea07f8d6 nfs/rpc: fix reponse parsing 7 years ago
Victor Julien 69897af6f6 wirefuzz: add 'quiet' mode
Adds -q commandline option to force quiet operation.
7 years ago
Victor Julien c803656dcf htp: cleanup and fix test 7 years ago
Victor Julien b028207462 http: add tests for header folding
To test for https://github.com/OISF/libhtp/issues/159
7 years ago
Victor Julien 7b3ba37bac http: clean up unittest 7 years ago
Victor Julien 260095a41d pcap-log: don't divide by 0 on no traffic 7 years ago
Victor Julien 2c95f63d2a output: fix logging wrong direction in tls upgrade
When upgrading to TLS from HTTP logging of the final HTTP tx could
have the wrong direction. This was due to the original packet triggering/
finalizing the upgrade would be used as the base for both the toserver
and toclient pseudo packet meaning it was wrong in one direction.

This patch creates a pseudo packet in the same way as the flow timeout
code does, so it no longer takes the raw original packet in.

Bug #2430
7 years ago
Victor Julien 2eadd77e10 changelog: update for 4.0.4 7 years ago
Victor Julien add7b188f4 rust/nfs: fix memory leak 7 years ago
Victor Julien 19af022620 autogen/rust: remove Cargo.lock
Remove Cargo.lock to avoid issues when updating Cargo.toml
7 years ago
Victor Julien 2c40c34ad2 doc: fix http_header_names example 7 years ago
Jason Ish 29e20c08e9 conf/yaml: don't allow empty key values
When loading an empty file, libyaml will fire a single scalar
event causing us to create a key that contains an empty string.
We're not interested in this, so skip an empty scalar value
when expecting a key.

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/2418
7 years ago
Jason Ish 8d1739b972 rust/dns: fix overflow of event counter
Issue:
https://redmine.openinfosecfoundation.org/issues/2437

Rust will panic if this value is incremented over the max
value for a u16. Instead, use a bool as the Rust DNS code
was never decrementing this counter, effectively using
it as a bool.
7 years ago
Jason Ish 3e0a1c8c5d dnp3: regenerate object decoding code 7 years ago
Jason Ish c19ac42979 dnp3-gen: require jinja2 v2.10 or later
Previous versions, but not all, have issues tracking
variables.
7 years ago
Philippe Antoine 3196142411 dnp3-gen: fix heap buffer overflow in generated code
Due to missing check before memcpy.
7 years ago
Victor Julien f767c0c5b0 der: fix recursion depth not being handled correctly
In a mix of sequences the 'depth reached' error would not
be fully propagated.

Found with AFL.
7 years ago
Victor Julien 60bab318c9 der: warn if null passed to decoders
Remove null checks for errcode.
7 years ago
Victor Julien 2dc344edb0 detect: fix out of bounds write in thread space creation 7 years ago
Victor Julien 2b9d242033 thresholds: fix issues with host based thresholds
The flow manager thread (that also runs the host cleanup code) would
sometimes free a host before it's thresholds are timed out. This would
lead to misdetection or too many alerts.

This was mostly (only?) visible on slower systems. And was caused by a
mismatch between time concepts of the async flow manager thread and the
packet threads, resulting in the flow manager using a timestamp that
was before the threshold entry creation ts. This would lead to an
integer underflow in the timeout check, leading to a incorrect conclusion
that the threshold entry was timed out.

To address this,  check if the 'check' timestamp is not before the creation
timestamp.
7 years ago
Victor Julien 660c1de7ba stream: set event for suspected data injection during 3whs
This rule will match on the STREAM_3WHS_ACK_DATA_INJECT, that is
set if we're:
- in IPS mode
- get a data packet from the server
- that matches the exact SEQ/ACK expectations for the 3whs

The action of the rule is set to drop as the stream engine will drop.
So the rule action is actually not needed, but for consistency it
is drop.
7 years ago
Victor Julien 97ebd3b05a stream: handle data on incomplete 3whs
If we have only seen the SYN and SYN/ACK of the 3whs, accept from
server data if it perfectly matches the SEQ/ACK expectations. This
might happen in 2 scenarios:

1. packet loss: if we lost the final ACK, we may get data that fits
   this pattern (e.g. a SMTP EHLO message).

2. MOTS/MITM packet injection: an attacker can send a data packet
   together with its SYN/ACK packet. The client due to timing almost
   certainly gets the SYN/ACK before considering the data packet,
   and will respond with the final ACK before processing the data
   packet.

In IDS mode we will accept the data packet and rely on the reassembly
engine to warn us if the packet was indeed injected.

In IPS mode we will drop the packet. In the packet loss case we will
rely on retransmissions to get the session back up and running. For
the injection case we blocked this injection attempt.
7 years ago
Victor Julien 8f20318481 stream: still inspect packets dropped by stream
The detect engine would bypass packets that are set as dropped. This
seems sane, as these packets are going to be dropped anyway.

However, it lead to the following corner case: stream events that
triggered the drop could not be matched on the rules. The packet
with the event wouldn't make it to the detect engine due to the bypass.

This patch changes the logic to not bypass DROP packets anymore.
Packets that are dropped by the stream engine will set the no payload
inspection flag, so avoid needless cost.
7 years ago
Victor Julien c5e345f5b8 nfs: remove old test code 7 years ago
Victor Julien e6936c34fa pcre: don't leak memory in data extraction 7 years ago
Victor Julien e238277830 rust/nfs: explicitly handle GAPs from C
It seems that Rust optimizes this code in such a way that it
passes the null ptr along as real data.

    if buf.as_ptr().is_null() && input_len > 0 {
7 years ago
Victor Julien a83c9a376d rust/filetracker: if file API return error, trunc file 7 years ago
Victor Julien 06c47a7bd7 rust/nfs: fix read reply handling
READ replies with large data chunks are processed partially to avoid
queuing too much data. When the final chunk was received however, the
start of the chunk would already tag the transaction as 'done'. The
more aggressive tx freeing that was recently merged would cause this
tx to be freed before the rest of the in-progress chunk was done.

This patch delays the tagging of the tx until the final data has been
received.
7 years ago
Victor Julien 10b53ad597 file: minor cleanups 7 years ago
Victor Julien d2b7b08a0f file: use enum for state
Makes debugging easier.
7 years ago
Victor Julien 9fec31fb0f rust/file: handle file open errors 7 years ago
Victor Julien 95acbf4a58 rust/file: change return type for FileOpenFileWithId
Make it int so we can easily check it in Rust. No consumer used the
File pointer that was returned before anyway.
7 years ago