Bug #7004
openapp-layer: wrong tx may be logged for stream rules
Description
[Private as it discusses an issue where DNS transactions are missed]
In IDS mode, transaction handling appears to be off, and there exists a discrepancy between IDS and IPS modes. While pointed out in PGSQL, I believe DNS presents a simpler reproduction case just being a simpler protocol with less state.
The test PCAP (dns-tcp-multi-5.pcap
) contains 1 TCP session with 3 DNS requests/responses, in order.
- 1) Request/response for suricata.io
- 2) Request/response for oisf.net
- 3) Request/response for google.com
One rule is used:
alert dns any any -> any any (msg:"DNS suricata"; content:"suricata"; sid:1; rev:1;)
Issue 1. IDS Mode
Using a default Suricata configuration:
suricata -S test.rules -r dns-tcp-multi-5.pcap
Observations:
- 2 alerts, logged matching on the "suricata" in the DNS stream
- The transaction in both alerts contain the data from the 3rd transaction, which is for "google.com", which is misleading.
Issue:
- The wrong transaction data is logged. This is very similar to what is being seen in #7000.
Issue 2. IPS Mode
Run the same test above, but in IPS simulation mode:
suricata -S test.rules -r dns-tcp-multi-5.pcap --simulate-ips
Observations:
- 6 alerts logged, one for each request and response
- Given the alert, and pcap_cnt, the tx data seems to be correct. TX data for each request and response is seen.
Issue:
- One might expect to get only 2 alerts in this scenario.
Summary
Being a stream rule there is no direct correlation between the match and the transaction logged. Generally logging the wrong data is worse than not logging it at all, so one idea would be to not log the transaction data in this case. For DNS, most TCP DNS sessions contain one transaction, so maybe in some cases we know we're going to log the correct tx, but in others we know it might not be the correct transaction.
I'm not sure about the IPS issue, I brought it up as it differs from IDS mode, but may be a separate issue.
Files