Commit Graph

10904 Commits (7691fc4f9e797444e3509ecde404847aad26be80)
 

Author SHA1 Message Date
Todd Mortimer 50e5b80463 detect/threshold: Add a common function to (re)allocate the by_rule threshold table.
Ensure that the by_rule threshold table is initialized if a rule
is thresholded by_rule. Replace manual table reallocaton with calls
to the common function.
5 years ago
Todd Mortimer 82dc61f4c3 detect/threshold: Refactor threshold calculation to handle by_rule and by_both.
The only difference between threshold calculations for by_src/by_dst,
by_rule or by_both is which table stores the DetectThresholdEntry.
Refactor the ThresholdHandlePacket* functions to do table lookup and
storage individually, but calculate thresholds in a common function.
5 years ago
Todd Mortimer 9fafc1031c time: Add TIMEVAL_EARLIER and TIMEVAL_DIFF_SEC macros.
Make it easy to compare 'struct timeval's and get their difference.
5 years ago
Todd Mortimer e945dea244 detect/threshold: Parse by_rule and by_both in rules.
Also add tests for parsing them.
5 years ago
Victor Julien ed8f48b053 app-layer/proto-detect: minor cleanup
Make sure the mask calculation is u32.
5 years ago
Victor Julien aba4e19548 detect/pktvar: fix memory leaks 5 years ago
Philippe Antoine 240df05af5 fuzz: limit input size for protocol detection consistency check 5 years ago
Jeff Lucovsky 6bffe0bd35 detect/ssl: Fix memory leak in version parsing
This commit fixes a memory leak in the SSL version handling that
manifests when the version identifier is incomplete or incorrect.
5 years ago
Philippe Antoine 91b2930891 fuzz: build compatibility with oss-fuzz flags
ie C define FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
5 years ago
Jeff Lucovsky 5f71e7a371 doc/devguide: Submission and style
This commit adds code submission and coding style guidelines to the
devguide. Most of the material is a straight port from the wiki but
there have been some content modifications and additions.
5 years ago
Jason Ish 752e4828d7 devguide: include sources in EXTRA_DIST
Required for distcheck to pass, and required to build docs
from a dist archive.
5 years ago
Jason Ish 211b193e08 github-ci: on centos-8 build, use distcheck
And verify that man page is built.
5 years ago
Jason Ish bcbd8c2ac0 github-ci: build documentation on Ubuntu 18.04 5 years ago
Jason Ish 7c0c2e76ee github-ci: build documentation on Fedora-31 build
Install sphinx and latex tools to test the building
of documentation on the Fedora 31 build, including
the PDF.
5 years ago
Philippe Antoine 9b5ccbe4d7 ci: adds a build with make tags 5 years ago
Eric Leblond 752fc77cdc configure: correctly display nss/nspr status
If autodiscovery of libnss was used (default), then the line
 libnss support:                          yes
was never set to no.

Same behavior for libnspr.

Broken by commit 'configure: fix nspr check logic' (7ea269a212)
5 years ago
Victor Julien 09a21545ce flow: cleanup expectations first
Make sure to cleanup expectations for a flow as the first step, before
parts of the flow itself are getting cleaned/freed.

Also indicate use unlikely as flows with expectations should be relatively
rare.
5 years ago
Eric Leblond fcfeeeb694 app-layer-expectation: update copyright date 5 years ago
Eric Leblond 1ddd77fae0 app-layer-expectation: clean expectation at flow end
When a flow timeout, we can have still existing expectations that
are linked to this flow. Given that there is a delay between the
real ending of the flow and its destruction by Suricata, the
expectation should be already honored so we can assume the risk
to clean the expectations that have been triggered by the
to-be-deleted flow.
5 years ago
Eric Leblond 6c9d1c0861 app-layer-expectation: limit number of expectations
This patch introduces a limitation in term of number of
expectations attached to one IPPair. This is done using
a circle list so we have a FIFO approach on expectation
handling.

Circleq list code is copied from BSD code like was pre existing code
in queue.h.
5 years ago
Eric Leblond 03e4bfeb02 app-layer-expectation: remove unused parameter 5 years ago
Jeff Lucovsky 0ae6b0b250 tests/bsize: Fuzzing test case added
This commit adds a test case to validate the issue found during fuzz
testing.
5 years ago
Jeff Lucovsky 5b38bc9894 detect/bsize: Ensure numeric values fit
This commit ensures that the numeric values will not exceed the size of
the containers used to hold them.
5 years ago
Victor Julien 095981cb2a detect/parse: fix crash on 'internal' keyword use
When keyword __flowvar__postmatch__, an internal keyword, is used
in a rule the 'Setup' func ptr will be NULL. This caused a crash.
5 years ago
Victor Julien 1e71eecf47 fuzz/siginit: fix leak in case of bidir sig 5 years ago
Victor Julien 5430141f7a fuzz/siginit: minor improvements
Enable detect engine 'quiet' mode to generate less output.

Set a fake filename so that datarep doesn't hit a reachable assert.
5 years ago
Victor Julien 13c9d0ca7e detect/pkt_data: error on unconsumed transforms
If a rule has transforms w/o consuming them (e.g. a content keyword),
don't consider 'pkt_data' valid.
5 years ago
Victor Julien e1c474a1b0 detect/pkt_data: code and test cleanup 5 years ago
Victor Julien 7f19da1cc0 detect: more robust against transform issues
In case of transform issues (transform not consumed before pkt_data
for example), the code would hit an ugly BUG_ON.

Address this by a more graceful error message, that will still
invalidate the sig but not crash the engine.
5 years ago
Sascha Steinbiss 713c379427 rfb: make sure size calculations do not overflow
Addresses #3570 by extra checking of calculated size requests.

With the given input, the parser eventually arrived at
parser::parse_failure_reason() which parsed from the remaining four
bytes (describing the string length) that the failure string to follow
would be 4294967295 bytes long. While calculating the total size of the
data to request via AppLayerResult::incomplete(), adding the four bytes
for the parsed but not consumed string length caused the u32 length to
overflow, resulting in a much smaller value triggering the bug condition.

This problem was addressed by more careful checking of values in each step
that could overflow: one subtraction, one addition (which could overflow
the usize length values), and a final check to determine whether the result
still fit into the u32 values required by AppLayerResult::incomplete().
If so, we would safely convert the values and pass them to the result type.
If not, we simply return AppLayerResult::err() but do not erroneously and
silently request the wrong amount.
5 years ago
Jeff Lucovsky 2823bc5aed detect/tls: Use pcre_copy_substring to avoid leak
This commit eliminates a memory leak while parsing TLS version
information. The leak was identified through fuzzing.
5 years ago
Victor Julien 3d969a1c7d build: wrap fuzz targets in guard to fix 'make tags' 5 years ago
Victor Julien 8cbae1371f fuzz/sigpcap: fix FPs due to missing pkt cleanup 5 years ago
Victor Julien 1aaf9a80c5 decode/vxlan: minor yaml example clarrification 5 years ago
Victor Julien e97cdb48f3 decode/teredo: implement port support
Implement support for limiting Teredo detection and decoding to specific
UDP ports, with 3544 as the default.

If no ports are specified, the old behaviour of detecting/decoding on any
port is still in place. This can also be forced by specifying 'any' as the
port setting.
5 years ago
Shivani Bhardwaj 0e4f261224 Use StringParse* for all parsers and configurations 5 years ago
Shivani Bhardwaj c4c734541a Use appropriate ByteExtractString* functions 5 years ago
Shivani Bhardwaj 6b2c7d5be8 util: Add StringParse* functions
StringParse* functions would perform a stricter check compared to
ByteExtractString* functions. These new functions shall also check if
any extra characters follow the extracted numeric value in addition to
the checks performed by ByteExtractString* and return -1 in that case.
This is particularly important in parser, configuration and setup functions.
5 years ago
Philippe Antoine 293eebd999 fuzz: remove obsolete AFL code 5 years ago
Victor Julien 19fe8d9894 ci: add fuzztargets and afl build test 5 years ago
Philippe Antoine bf60959d84 fuzz: simpler way to force usage of CXX linker 5 years ago
Philippe Antoine 440bb4d600 fuzz: remove decodeder fuzz target
As we removed decodeder function
5 years ago
Philippe Antoine e15f3db474 configure: right test for AFLFUZZ_PERSISTANT_MODE 5 years ago
Philippe Antoine 66181ed2e4 ci: enables fuzz targets in one build
github workflow wih debian
5 years ago
Victor Julien e500c59b99 stream/tcp: fix STREAM_HAS_SEEN_DATA macro
The macro would not return true for smaller TCP streams, leading to
cases where the app-layer was not notified of EOF.
5 years ago
Victor Julien 1618fb1b97 stream/tcp: clean up stream flags 5 years ago
Pierre Chifflier 01aef49cbd rust/x509: map decoding errors to decoder events 5 years ago
Pierre Chifflier 333fcc43e7 ssl/tls: call rs_cstring_free for strings allocated in Rust 5 years ago
Pierre Chifflier 36d2e257c6 rust/x509: use the raw serial number so leading zeros are not removed 5 years ago
Pierre Chifflier 1d9f37a60e DER: remove the C parser for DER 5 years ago