Why didn't my Suricata or Snort rule fire?

A rule that stays silent on a capture you know is malicious usually has one of a handful of problems. Go through them in this order: the cheap checks come first, and each one rules out a whole class of causes.

1. Did the rule load?

Suricata skips a rule it can’t parse and carries on with the others, so a typo can look like a rule that doesn’t match. Look for error parsing signature in suricata.log, or check the rule counts the engine prints at startup:

suricata -T -c /etc/suricata/suricata.yaml -S my.rules

Snort 3 stops at the first bad rule instead, with the file and line in the error:

snort -c /usr/local/etc/snort/snort.lua -R my.rules -T

Rules written for another engine are the usual culprits. Snort 3 rejects nocase; as a separate option, and Suricata rejects Snort 3’s content:"GET", nocase;. The Snort 3 syntax guide lists the differences.

2. Does the header match any packet?

The rule header is checked against every packet on its own:

alert tcp $HOME_NET any -> $EXTERNAL_NET 80 (...)

This only sees packets whose source is in HOME_NET and whose destination is outside it, on port 80. Three ways it goes wrong:

3. Does the flow option fit the traffic?

flow:to_server and flow:to_client pick a direction, and it has to agree with the header and with where the content is. A response header such as Content-Type is in the server’s reply, so a rule for it needs flow:to_client (or flow:from_server).

flow:established needs the TCP handshake. Suricata and Snort only call a connection established after they’ve seen the SYN, SYN-ACK and ACK. A capture that starts in the middle of a connection (a ring buffer, a capture started late, a filter that dropped the SYNs) never has an established connection, so these rules can’t fire on it, however good the content match is. Suricata’s stream.midstream setting changes this, but it’s off by default and on most sensors.

4. Did the engine recognize the protocol?

Rules on an application protocol (alert http, alert dns, alert tls) and rules using its buffers (http.uri, dns.query, tls.sni) only see connections the engine identified as that protocol. Suricata identifies most protocols from their first bytes, not the port, so HTTP on port 8080 is fine. But it has to see the start of the connection: without a handshake, Suricata doesn’t parse the application layer at all, and every app-layer rule stays silent.

5. Is the content really there, the way the rule says?

6. Is something else holding it back?

7. Is the capture the problem?

Why the alert’s packet number isn’t the packet with the content

Both engines reassemble TCP streams and often inspect data only once the other side has acknowledged it, so an alert can carry the number of a later packet: the ACK or the reply. For a content match, the packet that holds the bytes and the packet the alert names can differ.

Checking all of this at once

IDS Rule Tester runs these checks for you: it runs your rules on Suricata or Snort 3 against your capture, and for each rule that loaded but stayed silent it says which of the problems above it found, with the packet numbers.