# Why didn't my Suricata or Snort rule fire?

A checklist for IDS rules that load but never alert on a pcap, from ports and HOME_NET to flow:established, protocol detection, content matching, flowbits and bad checksums.

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](/guides/snort-3-rule-syntax/) 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:

- **Ports in the wrong place.** `any 80 -> any any` matches packets *from* port 80, which is the
  server's reply. To match the request, write `any any -> any 80`.
- **HOME_NET doesn't fit the capture.** The stock `suricata.yaml` sets `HOME_NET` to the private
  ranges (`192.168.0.0/16`, `10.0.0.0/8`, `172.16.0.0/12`). A capture between two public
  addresses has no packet from `$HOME_NET`, so the rule above never matches. Set `HOME_NET` to
  the side you are defending, or to `any` while testing.
- **The content is in the other direction.** With `$HOME_NET -> $EXTERNAL_NET`, the packets your
  rule sees are the ones leaving your network. If the bytes you're matching are in the reply,
  they're in packets going the other way.

## 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?

- **Case.** `content` is case-sensitive unless the rule has `nocase`.
- **Buffer.** `http.uri` holds the normalized URI (percent-decoded, without the host);
  `http.header` doesn't include the request line; `file.data` is the body after dechunking and
  decompression. Matching a raw string against a decoded buffer, or the other way round, misses.
  In Snort 3, a `content` with no buffer in an `alert http` rule only searches message bodies,
  so it never finds the request line or a header.
- **Position.** `depth` and `offset` count from the start of the buffer; `distance` and `within`
  count from the end of the previous match. A `depth` that was right for the raw packet is often
  wrong for a sticky buffer.
- **Encoding on the wire.** Some protocols don't carry strings as you'd type them. DNS names are
  sent as labels, each after its length byte: `c2.example.net` is `c2|07|example|03|net`. A raw
  `content:"c2.example.net"` never matches a DNS packet; `dns.query; content:"c2.example.net";`
  does.

## 6. Is something else holding it back?

- **flowbits.** A rule with `flowbits:isset,name` only fires after another rule has set that bit on
  the same connection, and that rule has to be loaded too. A rule with `flowbits:noalert` never
  alerts by itself.
- **Thresholds.** `threshold` and `detection_filter` hold alerts back until there are enough
  matches. In Snort 3, a `detection_filter` with `count 1` alerts on the second match, not the
  first.

## 7. Is the capture the problem?

- **Bad checksums.** Captures taken on the host that sent the traffic often have wrong TCP
  checksums, because the network card fills them in after the capture point (checksum
  offloading). An engine that validates checksums won't fully inspect those packets: Suricata
  leaves them out of connection tracking, so rules that need the connection or its protocol
  (`flow:established`, `http.*` buffers) miss them, while Snort 3 skips them altogether. Reading
  a pcap with `-k none` turns the check off; that's why a rule can fire in your test and stay
  silent on the sensor, or the other way round.
- **Truncated packets.** A capture with a small snap length (`tcpdump -s 96`) cuts packets
  short. The payload you're matching may simply not be in the file.

## 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.