Measuring noise and tuning without going blind
Unit 4 of 5 in Detection engineering.
You will be able to calculate a rule's precision, tune it narrowly and re-test that it still catches what it should.
Lesson
Two ways to be wrong, and they trade against each other
NIST's guide says detection systems cannot be completely accurate. When benign activity is flagged as malicious, a false positive has occurred. When malicious activity is missed, a false negative has occurred. It is not possible to eliminate all of either, and in most cases reducing one increases the other. Many organizations choose to decrease false negatives at the cost of more false positives, which means more events are detected but more analyst time is needed to tell them apart. Changing the configuration to improve accuracy is called tuning.
That trade is a business decision, not just a technical one. A rule for a rare, severe behaviour can tolerate a lower precision than a rule that fires hundreds of times a day.
Count them: precision and recall
Google's machine learning course defines the measures you need. Precision is the share of positive classifications that were actually positive: true positives divided by true positives plus false positives. For an alert, it answers 'of the alerts I received, how many were real?' Recall, also called the true positive rate, is the share of real positives that were caught: it answers 'of the real attacks, how many did the rule see?'
The course also warns about accuracy. With a rare class that appears 1 percent of the time, a model that always says negative scores 99 percent accuracy and is useless. Real attacks are usually a tiny share of all events, so never judge a rule by how many events it correctly ignored. A small made-up example: a rule fires 40 times in a week and analysts confirm 10 as real, so its precision is 10 out of 40, or 25 percent. If the testers also planted 12 real cases and the rule caught 10 of them, its recall on that set is 10 out of 12. Measure both, and say what sample you measured on.
Tune narrowly
NIST lists the usual tuning tools: thresholds, lists of known-benign entities (it calls them whitelists) and known-malicious ones, alert settings, and editing the detection code. Whitelists are used on a granular basis to ignore false positives from known benign activity. Palantir's template adds three ways to reduce false positives: add another component to the rule to increase true positives, remove common false positives through patterns, and filter in the back end using stored examples of expected false positives. It also says known false positives should be suppressed in the SIEM, and that if a low false positive rate cannot be reached, the alert may need to be broken down, refactored or discarded.
Make each change as small as possible, and say why. Excluding one named management account from one rule is a narrow change. Excluding a whole folder or a whole class of users is a wide one and can silently remove the very activity you wanted to see. The Sigma habit helps: record the false positive in the rule's falsepositives list and keep the exception in a filter.
Raise the signal by combining weak events
A single event may be too common to alert on but a few of them together may be rare. Sigma correlation rules support this: single rule hits can stay low or informational, and the correlation can set a higher level when the combination appears within a timespan. The level definitions say low events are relevant in high numbers or in combination with others. This is often a better answer than loosening or tightening a single threshold.
Anomaly-based rules need a separate warning. NIST notes they can be very effective at detecting previously unknown threats, but produce many false positives because benign activity deviates from profiles, and that analysts may find it hard to work out why an alert fired. If you use a baseline, plan to rebuild it.
Re-test, review and retire
After every tuning change, run the true-positive test again. Tuning away a false positive can also tune away a real detection, and only the re-test tells you. NIST adds that administrators should review tuning and customizations periodically to be sure they are still accurate: check whitelist entries, adjust thresholds as the environment and threats change, and rebuild baselines for anomaly-based detection.
Treat the portfolio as a whole. Measure each rule's precision and the analyst hours it burns, and retire or rewrite the noisiest ones. A rule that nobody trusts is worse than no rule, because its alerts train people to ignore the queue.
Key points
- False positives and false negatives trade against each other; tuning changes the balance.
- Precision is the share of alerts that were real; recall is the share of real attacks the rule caught; accuracy misleads on rare events.
- Tune narrowly with thresholds, named exceptions and extra conditions, and record each change and why.
- Combine weak events with correlation instead of loosening a single threshold.
- Re-run the true-positive test after every change; review tuning and baselines on a schedule; retire noisy rules.
Sources
- NIST SP 800-94: Guide to Intrusion Detection and Prevention Systems (IDPS)
- Google for Developers: Classification: Accuracy, recall, precision, and related metrics
- Palantir: ADS Framework template (ADS-Framework.md on GitHub)
- Sigma Rules Specification, version 2.1.0
- Sigma documentation: Filters
- Sigma Correlation Rules Specification
Lecture
Alert triage like a SOC analyst: A talk on how an analyst works one alert, which shows what a noisy rule costs the person who receives it.
Practice in the labs
Measure noise, tune thresholds, and separate attack-like from normal admin work, using Linux audit events and synthetic alert data.
- Catch ATT&CK T1082 System Information Discovery and measure the noise (Purple Discovery 3 of 6): You compare event counts for a broad rule and a narrow rule and write one sentence deciding which to keep (Purple Discovery series). Runs on a Linux machine you own.
- Tell attack-like execution from normal admin work, and tune the rules (Purple Execution 3 of 3): You record, for three versions of a rule, how many admin events and test events each caught, tune out the admin false positive without losing the test and write a six-line runbook (Purple Execution series). Runs on a Linux machine you own.
- Correlate discovery commands into one alert and write the purple report (Purple Discovery 6 of 6): You combine four weak detections into one correlated alert and write the purple report (Purple Discovery series). Runs on a Linux machine you own.
- Detect a port scan from firewall logs and tune the threshold: You see a raw connection count flag a busy backup server, then switch to distinct hosts and ports in a sliding window. Runs offline.
- Measure per-rule alert precision and retire your noisiest detections: You compute per-rule precision with confidence intervals over 10,109 synthetic alerts and decide which rules to retire. Runs offline.
- Pick an alert classifier's threshold from a cost matrix, instead of the default 0.5: You pick a threshold from the cost of each kind of mistake instead of a default, the business side of the trade-off. Runs offline.
Also try, in the simulators
- Test it, tune it, keep it honest (Detection Lab lesson): The Detection Lab lesson on testing and tuning, with the bench that counts catches, misses and false alarms.
- Find a login on a remote-access profile nobody owns (Detection Lab task): You write a rule that finds sign-ins to a remote-access profile with no owner without alerting on staff back from leave, a tuning question you must answer in the rule.
- Find one account pulling many large result sets (Detection Lab task): You write a rule for one account pulling many large result sets without alerting on the one-off big daytime reports.
Knowledge check
- A rule fired 50 times this month. Analysts confirmed 5 were real. What is its precision? Answer: 10 percent. Precision is true positives divided by everything the rule flagged: 5 out of 50 is 10 percent. Recall would need a separate count of real attacks the rule missed.
- A rule is correct on 99 percent of all events, but real attacks are 0.1 percent of events. What does this tell you? Answer: Nothing useful: with rare events, accuracy can be high even if the rule catches no attacks. The machine learning course's example shows that with a rare class a model that always says negative scores very high accuracy while being useless, so measure precision and recall instead.
- You tune a rule to remove a false positive. What must you do next? Answer: Re-run the true-positive test to prove the rule still catches the attack. Tuning can remove real detections along with the false alarm. The validation step in the ADS template exists for exactly this, and NIST also recommends reviewing tuning periodically.
- A single event is too common to alert on, but three different events in ten minutes are rare. What is a good approach? Answer: A correlation rule that raises the level when the events combine within a timespan. Sigma correlation rules let single hits stay low and raise the level when a combination appears in a timespan, and the level definitions say low events matter in combination with others.
Back to the syllabus or see all classes.
Related
- Detection engineering
- Catch ATT&CK T1082 System Information Discovery and measure the noise (Purple Discovery 3 of 6)
- Tell attack-like execution from normal admin work, and tune the rules (Purple Execution 3 of 3)
- Correlate discovery commands into one alert and write the purple report (Purple Discovery 6 of 6)
- Detect a port scan from firewall logs and tune the threshold
- Measure per-rule alert precision and retire your noisiest detections
- Pick an alert classifier's threshold from a cost matrix, instead of the default 0.5
- All classes
- Free cyber labs