TExcelTAD

Tuning Alerts and False Positives

A freshly installed IDS with a full rule set produces thousands of alerts a day, and almost all of them are harmless: the vulnerability scanner doing its job, a backup tool that looks like exfiltration, an old application that sends passwords in a way a policy rule dislikes. Analysts drown, start ignoring the console, and the one real alert is lost in the noise. Tuning is the continuous work of making alerts mean something: removing false positives without creating blind spots. It is where most of the value of an IDS is won or lost.

The vocabulary

Attack really happened No attack
Alert true positive (TP) false positive (FP): noise, costs analyst time
No alert false negative (FN): a miss, the dangerous one true negative (TN)
  • Precision = TP / (TP + FP): of the alerts, how many were real? Low precision means alert fatigue.
  • Recall (detection rate) = TP / (TP + FN): of the real attacks, how many were caught? Low recall means blind spots.
  • Tuning trades one against the other: every suppression raises precision and risks lowering recall.

Measuring a week of alerts

The program takes a week of triaged alerts from the lab sensor (synthetic: each alert has the analyst's verdict; rule names and SIDs are illustrative, in the style of the Emerging Threats and Suricata rule sets, plus the lab rules of the previous lesson) and computes per-rule precision and the sources responsible for the false positives.

python · try it yourself
import pandas as pd

rows = []
def add(n, sid, msg, src, verdict):
    rows.extend([(sid, msg, src, verdict)] * n)
add(420, 2001219, "ET SCAN Potential SSH Scan",          "10.10.5.10",   "FP")   # the vulnerability scanner
add(3,   2001219, "ET SCAN Potential SSH Scan",          "198.51.100.9", "TP")
add(610, 1000001, "LAB cleartext password in HTTP POST", "10.10.3.40",   "FP")   # legacy HR app, known, ticketed
add(2,   1000001, "LAB cleartext password in HTTP POST", "10.10.3.5",    "TP")
add(95,  2027865, "ET INFO Observed DNS over HTTPS",     "10.10.3.12",   "FP")
add(1,   2027865, "ET INFO Observed DNS over HTTPS",     "10.10.1.10",   "TP")   # web server bypassing the resolver
add(5,   1000004, "LAB Nmap HTTP probe",                 "198.51.100.9", "TP")
add(140, 2210045, "SURICATA STREAM Packet with invalid ack", "10.10.2.60", "FP") # capture loss on a busy SPAN
alerts = pd.DataFrame(rows, columns=["sid", "msg", "src", "verdict"])

per_rule = alerts.groupby(["sid", "msg"]).agg(alerts=("verdict", "size"), tp=("verdict", lambda v: (v == "TP").sum()))
per_rule["precision"] = (per_rule["tp"] / per_rule["alerts"]).round(3)
print(per_rule.sort_values("alerts", ascending=False).to_string())
total_tp = (alerts.verdict == "TP").sum()
print(f"\nweek: {len(alerts)} alerts, {total_tp} true positives, precision {total_tp / len(alerts):.3f}")

fp_sources = (alerts[alerts.verdict == "FP"].groupby(["sid", "src"]).size()
              .sort_values(ascending=False).rename("fp").reset_index())
print("\nfalse positives by rule and source:")
print(fp_sources.to_string(index=False))
                                                 alerts  tp  precision
sid     msg
1000001 LAB cleartext password in HTTP POST         612   2      0.003
2001219 ET SCAN Potential SSH Scan                  423   3      0.007
2210045 SURICATA STREAM Packet with invalid ack     140   0      0.000
2027865 ET INFO Observed DNS over HTTPS              96   1      0.010
1000004 LAB Nmap HTTP probe                           5   5      1.000

week: 1276 alerts, 11 true positives, precision 0.009

false positives by rule and source:
    sid        src  fp
1000001 10.10.3.40 610
2001219 10.10.5.10 420
2210045 10.10.2.60 140
2027865 10.10.3.12  95

Eleven real events hide among 1,276 alerts: precision under one percent. But the false positives are concentrated: four (rule, source) pairs produce all 1,265 of them. That concentration is typical and is what makes tuning possible.

Tuning actions, from narrowest to broadest

Action Suricata / Snort mechanism Use when
Fix the cause none: change the network or the application the alert is right and the behaviour is the problem (the HR app sending cleartext passwords)
Suppress for one source suppress gen_id 1, sig_id 2001219, track by_src, ip 10.10.5.10 in threshold.config a known, documented system triggers a rule legitimately (the scanner)
Rate-limit threshold: type limit, track by_src, count 1, seconds 3600; in the rule, or threshold lines in threshold.config the first alert matters, the next hundred don't
Rewrite the rule add flow, buffers, positions, exceptions (!$SCANNERS) the rule is too broad by design
Disable the rule disable.conf with suricata-update, or comment it out the rule doesn't apply to your environment at all (protocol you don't run)
Fix the sensor capture-loss investigation, SPAN/tap fixes stream and decoder alerts caused by dropped packets

Applying the narrowest fix to each FP group, and simulating the result:

python · try it yourself
import pandas as pd

rows = []
def add(n, sid, src, verdict): rows.extend([(sid, src, verdict)] * n)
add(420, 2001219, "10.10.5.10", "FP"); add(3, 2001219, "198.51.100.9", "TP")
add(610, 1000001, "10.10.3.40", "FP"); add(2, 1000001, "10.10.3.5", "TP")
add(95, 2027865, "10.10.3.12", "FP"); add(1, 2027865, "10.10.1.10", "TP")
add(5, 1000004, "198.51.100.9", "TP"); add(140, 2210045, "10.10.2.60", "FP")
alerts = pd.DataFrame(rows, columns=["sid", "src", "verdict"])

suppress = {(2001219, "10.10.5.10"): "scanner, documented in scope",
            (2027865, "10.10.3.12"): "IT test laptop, until 2026-03-01"}
fixed_causes = {(1000001, "10.10.3.40"): "HR app moved to HTTPS (ticket CHG-1042)",
                (2210045, "10.10.2.60"): "SPAN replaced by a tap, capture loss 0%"}
removed = alerts.apply(lambda r: (r.sid, r.src) in suppress or (r.sid, r.src) in fixed_causes, axis=1)
after = alerts[~removed]

for name, df in [("before", alerts), ("after", after)]:
    tp = (df.verdict == "TP").sum()
    print(f"{name:6}: {len(df):5} alerts, {tp:2} TP, precision {tp / len(df):.3f}")
lost = alerts[removed & (alerts.verdict == "TP")]
print("true positives lost by tuning:", len(lost))
for key, why in {**suppress, **fixed_causes}.items():
    print(f"  sid {key[0]} src {key[1]:12} {why}")
before:  1276 alerts, 11 TP, precision 0.009
after :    11 alerts, 11 TP, precision 1.000
true positives lost by tuning: 0
  sid 2001219 src 10.10.5.10   scanner, documented in scope
  sid 2027865 src 10.10.3.12   IT test laptop, until 2026-03-01
  sid 1000001 src 10.10.3.40   HR app moved to HTTPS (ticket CHG-1042)
  sid 2210045 src 10.10.2.60   SPAN replaced by a tap, capture loss 0%

Precision goes from under 1% to 100% on this week's data, and no true positive was lost, because every action was tied to one documented source or fixed the cause. Two of the four actions are not IDS changes at all: moving the HR application to HTTPS and replacing the SPAN port removed the reason for the alerts. A suppression has an owner, a reason and, where possible, an end date, like a firewall exception.

Next week's data will have new false positives, and a rule that was quiet may now be missing attacks: tuning is a loop, measured with the same numbers every time.

Measuring recall

False negatives don't announce themselves. Ways to estimate recall:

  • Replay known attack captures (your own lab recordings, public sample sets) through the sensor and count what fires.
  • Purple-team exercises: an authorised red team runs specific techniques (MITRE ATT&CK IDs), and the blue team checks which were detected (Red, Blue and Purple Teams).
  • Hunting in Zeek and flow logs for things the IDS should have alerted on (Zeek Logs with pandas).

Pitfalls

  • Suppressing by rule instead of by source: one noisy host silences the rule for everyone.
  • Suppressing the scanner's whole subnet, which an attacker on that subnet then enjoys.
  • Tuning without recording why: a year later nobody dares remove a suppression.
  • Measuring only alert volume: fewer alerts is not better if recall fell.
  • Letting decoder and stream alerts be "background": they are often a sensor-health signal.

Practice

1. Why is suppress … track by_src, ip 10.10.5.10 better than disabling rule 2001219?

It removes only the scanner's alerts. The three true positives from 198.51.100.9 still fire; disabling the rule would have lost them.

2. Compute the precision of rule 1000001 before tuning by hand.

2 TP out of 612 alerts: 2 / 612 ≈ 0.003.

3. The IT test laptop's suppression expires on 2026-03-01 and the laptop still uses DoH. What should happen?

The alerts return, which is the point of the expiry: someone must either fix the laptop's configuration (use the internal resolver), extend the exception with a new reason, or accept that it shows up. Silent permanent exceptions are how blind spots grow.

Test yourself

What is precision for an IDS?

  1. TP / (TP + FN)
  2. TP / (TP + FP): the share of alerts that were real
  3. FP / TN
  4. The number of rules

What was the week's precision before tuning?

  1. About 0.9%
  2. About 9%
  3. About 50%
  4. 100%

Which tuning action fixes the cause rather than hiding the alert?

  1. Suppressing the HR app's source
  2. Moving the HR application to HTTPS
  3. Disabling the rule
  4. Raising thresholds

Why are false negatives hard to measure?

  1. They are rare
  2. Missed attacks produce no alert; you need replays, purple-team tests or hunting to find them
  3. Suricata hides them
  4. They only occur with IPv6