A bug was reported about the IP-only rules not correctly matching. This was traced to the rules in question not getting recorded into the IP-only radix tree correctly. Sequence: - 100.117.241.0/25 inserted into the tree - 100.117.241.0/26 inserted into the tree Both are part of the same radix node, but recorded by their different netmasks in the user data portion. Then faulty insert happens: - 100.117.241.64/26 For reference, these net blocks compute to: - 100.117.241.0/25: 100.117.241.0 - 100.117.241.127 - 100.117.241.0/26: 100.117.241.0 - 100.117.241.63 - 100.117.241.64/26: 100.117.241.64 - 100.117.241.127 The IP-only engine first does a search to get to the user data it may need to include. It does so for with `SCRadixFindKeyIPV4ExactMatch` for single IPs, or using `SCRadixFindKeyIPV4Netblock` in case of a netblock. Any "match" from either of these is considered an "exact match" by the IP-only setup code. This exact match expectation turned out to be wrong and `SCRadixFindKeyIPV4Netblock` behaved more like "best match" instead, which is a non-exact match, but its the next best match if no exact match is found. The way the look up for 100.117.241.64/26 went wrong, is that it returned the user data for 100.117.241.0/26. This happens as follows: - first it would do an exact find, which didn't give a result - then it removed bits from the keystream until it found a matching node and explore if any of the netmasks it contained matched. Here the first step of the bug started: it considered the netmask (with user data) a match that matched the number of bits of the matching key, but not of the actual range netmask cidr value. So in this case the number of shared bits between `100.117.241.0/25` and `100.117.241.64/26` was 25, so it assumed that the user data for the netmask 25 was the match. To summarize this step, there are 2 problems with this: 1. it returns a match on something that isn't an exact match 2. it considered the wrong netmask value - the radix code then took the returned node, and did the netmask check again. This time it did use its own netmask value, so this time it did find the netmask 26 (+ user data). However because of the node that was returned, this netmask (+user data) belongs to `100.117.241.0`, not to `100.117.241.64`. - the IP-only detection code was satisfied with what it assumed to be "exact match" and just updated the user data to include the user data that should have been associated with `100.117.241.64/26` to `100.117.241.0/26`. This patch addresses the issue as follows: It makes `SCRadixFindKeyIPV4Netblock` also return an exact match by propagating the netmask in the search and in the evaluation of the stored netmasks. It does away with the secondary netmask (+user data) evaluation. `SCRadixFindKeyIPV4Netblock` is expected to handle this correctly. The IP-only engine will fall back to the "not found" path, which does an explicit "best match" lookup and then insert a new entry into the radix tree based on the user data of the "best match". Issue was present for IPv6 as well. Bug: #5066. |
5 years ago | |
|---|---|---|
| .github | 5 years ago | |
| benches | ||
| contrib | 8 years ago | |
| doc | 5 years ago | |
| ebpf | 5 years ago | |
| etc | 6 years ago | |
| lua | 9 years ago | |
| python | 5 years ago | |
| qa | 5 years ago | |
| rules | 5 years ago | |
| rust | 5 years ago | |
| scripts | 5 years ago | |
| src | 5 years ago | |
| suricata-update | 7 years ago | |
| .clang-format | 6 years ago | |
| .gitignore | 5 years ago | |
| .lgtm.yml | 5 years ago | |
| .readthedocs.yaml | 5 years ago | |
| COPYING | 11 years ago | |
| ChangeLog | 6 years ago | |
| LICENSE | 11 years ago | |
| Makefile.am | 6 years ago | |
| Makefile.cvs | ||
| README.md | 5 years ago | |
| acsite.m4 | 6 years ago | |
| autogen.sh | 9 years ago | |
| config.rpath | ||
| configure.ac | 5 years ago | |
| doxygen.cfg | 5 years ago | |
| libsuricata-config.in | 6 years ago | |
| requirements.txt | 5 years ago | |
| suricata.yaml.in | 5 years ago | |
| threshold.config | 9 years ago | |
README.md
Suricata
Introduction
Suricata is a network IDS, IPS and NSM engine developed by the OISF and the Suricata community.
Installation
https://suricata.readthedocs.io/en/latest/install.html
User Guide
You can follow the Suricata user guide to get started.
Contributing
We're happily taking patches and other contributions. Please see https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Contributing for how to get started.
Suricata is a complex piece of software dealing with mostly untrusted input. Mishandling this input will have serious consequences:
- in IPS mode a crash may knock a network offline;
- in passive mode a compromise of the IDS may lead to loss of critical and confidential data;
- missed detection may lead to undetected compromise of the network.
In other words, we think the stakes are pretty high, especially since in many common cases the IDS/IPS will be directly reachable by an attacker.
For this reason, we have developed a QA process that is quite extensive. A consequence is that contributing to Suricata can be a somewhat lengthy process.
On a high level, the steps are:
-
Github-CI based checks. This runs automatically when a pull request is made.
-
Review by devs from the team and community
-
QA runs from private QA setups. These are private due to the nature of the test traffic.
Overview of Suricata's QA steps
OISF team members are able to submit builds to our private QA setup. It will run a series of build tests and a regression suite to confirm no existing features break.
The final QA runs takes a few hours minimally, and generally runs overnight. It currently runs:
- extensive build tests on different OS', compilers, optimization levels, configure features
- static code analysis using cppcheck, scan-build
- runtime code analysis using valgrind, AddressSanitizer, LeakSanitizer
- regression tests for past bugs
- output validation of logging
- unix socket testing
- pcap based fuzz testing using ASAN and LSAN
- traffic replay based IDS and IPS tests
Next to these tests, based on the type of code change further tests can be run manually:
- traffic replay testing (multi-gigabit)
- large pcap collection processing (multi-terabytes)
- fuzz testing (might take multiple days or even weeks)
- pcap based performance testing
- live performance testing
- various other manual tests based on evaluation of the proposed changes
It's important to realize that almost all of the tests above are used as acceptance tests. If something fails, it's up to you to address this in your code.
One step of the QA is currently run post-merge. We submit builds to the Coverity Scan program. Due to limitations of this (free) service, we can submit once a day max. Of course it can happen that after the merge the community will find issues. For both cases we request you to help address the issues as they may come up.
FAQ
Q: Will you accept my PR?
A: That depends on a number of things, including the code quality. With new features it also depends on whether the team and/or the community think the feature is useful, how much it affects other code and features, the risk of performance regressions, etc.
Q: When will my PR be merged?
A: It depends, if it's a major feature or considered a high risk change, it will probably go into the next major version.
Q: Why was my PR closed?
A: As documented in the Suricata Github workflow here https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Github_work_flow, we expect a new pull request for every change.
Normally, the team (or community) will give feedback on a pull request after which it is expected to be replaced by an improved PR. So look at the comments. If you disagree with the comments we can still discuss them in the closed PR.
If the PR was closed without comments it's likely due to QA failure. If the Github-CI checks failed, the PR should be fixed right away. No need for a discussion about it, unless you believe the QA failure is incorrect.
Q: the compiler/code analyser/tool is wrong, what now?
A: To assist in the automation of the QA, we're not accepting warnings or errors to stay. In some cases this could mean that we add a suppression if the tool supports that (e.g. valgrind, DrMemory). Some warnings can be disabled. In some exceptional cases the only 'solution' is to refactor the code to work around a static code checker limitation false positive. While frustrating, we prefer this over leaving warnings in the output. Warnings tend to get ignored and then increase risk of hiding other warnings.
Q: I think your QA test is wrong
A: If you really think it is, we can discuss how to improve it. But don't come to this conclusion too quickly, more often it's the code that turns out to be wrong.
Q: do you require signing of a contributor license agreement?
A: Yes, we do this to keep the ownership of Suricata in one hand: the Open Information Security Foundation. See http://suricata.io/about/open-source/ and http://suricata.io/about/contribution-agreement/