At multiple sites I am running Suricata 1.4.1 on 64 bit Ubuntu 12.04 and CentOS 6 with PF_RING, and I am frequently running into this problem. It appears that when an HTTP request spanning multiple packets (like an HTTP POST with the POST data spilling over into a second packet), triggers an IDS alert, that frequently the wrong packet gets stuffed into the payload field of the unified2 file for that event, such that looking at the stored event I cannot find the substring that the firing rule was looking for.
For example, I just has this rule fire at two different sites running Suricata (versions 1.4 and 1.4.1).
In both cases an HTTP POST spread across two packets is involved. The substring matched by the rule is in the 1st packet, but only the second packet is recorded as the payload. When a multi-packet HTTP request is made, I'd personally like to see the whole thing merged together into a single data payload to be inserted into the NIDS event. Or if that isn't reasonable, at least stash the same packet that actually matched the rule.
If you enable alert-debug.log (and try to mirror the situation) - what packet data would be written in it for that alert? Would it be the same situation?
Following the general pattern I repeatedly have seen, the strings referenced by the rule would be found in a neighboring packet in the same tcp connection which for some reason Suricata did not incorporate into the flow.
Kevin, I think you're not supposed to make ETPRO rules public.
Wrt the issue. Generally HTTP rules match on the reconstructed state, not the individual packets. In IDS mode the state is reconstructed based on ACK'd TCP data, which means that by definition the packet containing the data is already gone. We try to log out anything still in the stream engine's memory, but it's not always there anymore.
Sorry about posting an intact ETPRO rule like that. Will try to avoid that in the future. I'm pretty sure I am only seeing this issue on http requests spanning multiple packets, often just 2 packets. If the stream engine is losing the 1st packet in two-packet http request streams, could the engine be tuned or fixed to retain more? Could there be an issue in htp? Or do I just need to do some kind of tuning in the suricata.conf file related to memory handling?
I should be able to come up with a pcap within the next day or two. If it looks like it should go to you privately, should I use your inliniac.net address?
I should be able to come up with a pcap within the next day or two. If it looks like it should go to you privately, should I use your inliniac.net address?
I emailed you the pcap of this classic example of bug 810 that just popped up today. Packets number 4 and 5 comprise a two-packet http GET request. Content in packet 4 triggers rule 2016919, but only the payload of packet 5 gets inserted into the event. Also, here is the matching debug output for the event. In the debug, I see that the content titled "PAYLOAD:" consists of the combined payloads of packets 4 and 5, but that "STREAM DATA:" contains only the payload from packet 5. That little scrap from packet 5 is all I get in the event as it is written to the unified2 file that gets read by barnyard for loading into a database.
After upgrading from 1.4.1 to 1.4.3 I am still seeing this problem recur. In a case today, the rule that fired was 2008438 - "ET MALWARE Possible Windows executable sent when remote host claims to send a Text File" The payload put into the alert event record was from the packet directly following the packet that contained the triggering content. Attached is a text dump of the http conversation, a pcap of the conversation, and the Suricata alert debug data about the event. Can anyone reproduce this? I'm not doing anything particularly exotic in my Suricata setup other than using PF_RING.
commit 88a21456e324f589575c4bccfaa63dee0e3b301a
Author: Victor Julien <victor@inliniac.net>
Date: Sun May 20 17:17:57 2012 +0200
stream: keep segments in memory until we are sure the stream/state is inspected.
I haven't been able to reproduce the issue since, so closing this ticket. If encounter the issue in our 2.x branch, please reopen.