Testing the rule on a bench you own
Unit 3 of 5 in Detection engineering.
You will be able to test a rule with a true positive, a clean baseline and a variant, find its blind spots and clean up afterwards.
Lesson
An untested rule is a guess
Palantir's template has a validation section: the steps required to generate a representative true positive that triggers the alert. They compare it to a unit test. It can be a walkthrough, a script such as an Atomic Red Team test, or a scenario in an alert-testing platform. The framework's rule is blunt: each detection must have true positive validation, and if you cannot generate a true positive, the alert may need to be broken down, refactored or discarded.
The same section lists the steps: build a scenario that should produce a true positive, document it, generate the alert from a test device, and check that the strategy caught it. Notice what is missing from that list: nobody tests on production. That leads to the next point.
Build a bench you can reset
Palantir recommends a lab environment before deploying any of its example strategies to production. NIST's guide for intrusion detection systems says the same about components: implement them in a test environment first, and when you go live, activate only a few sensors with prevention disabled, because a new deployment generates many false positives until it is tuned and activating many at once makes tuning difficult.
For you, a bench means a virtual machine you own, a clean snapshot you can return to, and a sensor you have confirmed is recording. The purple series of labs starts exactly there: a Linux machine with audit logging turned on and a snapshot taken before any test. Only test on machines you own or are explicitly authorized to test, and never on a shared or production system.
Use portable tests, then read what they do
Atomic Red Team describes itself as a library of tests mapped to the ATT&CK framework that lets security teams test their environments quickly, portably and reproducibly. The project describes its tests as small and highly portable, and says you can execute them directly from the command line.
Read a test before you run it, run only low-risk ones, run the cleanup, and prove the cleanup worked. A single passed test proves one variation of one technique, not the technique. The labs in this unit make you write down what changed on the machine before and after, which is also how you find persistence that no rule saw.
Test three ways: true positive, clean baseline, variant
A good test set has three parts. A true positive shows the rule fires. A clean baseline shows it stays quiet on normal activity: the SigmaHQ repository's contributing guide describes an optional check that downloads clean Windows event log baselines and runs your rules against them to surface false positives, and regression tests that run rules against recorded event files. A variant is the same behaviour done a little differently, which shows whether the rule matches a behaviour or only one spelling of it.
NIST warns about a trap for profile-based detection: a monthly maintenance job that moves large files might not occur during the training period, so when it runs it looks like a deviation and raises an alert. A baseline that is too short produces false positives that no amount of rule logic can fix.
Write the blind spots down
Every test teaches you something the rule cannot see: a command that exists under a different name, a persistence mechanism that writes no file, a rule on one file that does not scale to a hundred files. The ADS template gives this a home: the blind spots and assumptions section, so another engineer can see where the alert may fail. Treat each blind spot as a to-do: either a different kind of control covers it, or you accept it with a reason.
Key points
- Every detection needs a documented way to produce a true positive; if you cannot, rework or discard it.
- Test on a machine you own with a clean snapshot, never on production.
- Atomic tests are small and portable; read first, run low-risk ones, run the cleanup and prove it.
- Test with a true positive, a clean baseline and a variant.
- Record blind spots, and give each a plan: another control, or an accepted risk.
Sources
- Palantir: ADS Framework template (ADS-Framework.md on GitHub)
- Palantir: Alerting and Detection Strategies Framework (project page on GitHub)
- Atomic Red Team (project page on GitHub)
- SigmaHQ rule repository: Contributing guide (on GitHub)
- NIST SP 800-94: Guide to Intrusion Detection and Prevention Systems (IDPS)
Lecture
Red, blue and purple: how the teams fit together: A talk on how red, blue and purple teams share findings, which is the working relationship behind testing detections.
Practice in the labs
Build a bench, run small harmless tests on your own machine, and write down what your rules cannot see.
- Build a purple-team bench: auditd on a Linux VM you own, with a clean snapshot (Purple Discovery 1 of 6): You build the bench: a clean snapshot, audit logging on and one rule with a key (Purple Discovery series). Runs on a Linux machine you own.
- Catch cron persistence (T1053.003), then remove it and prove it is gone (Purple Persistence 1 of 5): You catch two ways of scheduling a job, run the cleanup and prove both are gone (Purple Persistence series). Runs on a Linux machine you own.
- Catch SSH authorized_keys changes (T1098.004) and see the limit of per-file rules (Purple Persistence 3 of 5): You catch a change to a key file and write down why one rule per file does not scale. Runs on a Linux machine you own.
- Catch systemd timer execution (T1053.006), including the one that leaves no file (Purple Execution 2 of 3): You see which rule caught which test, including a timer that leaves no file (Purple Execution series). Runs on a Linux machine you own.
- Catch ATT&CK T1016 and T1049 network discovery, and find what your rules cannot see (Purple Discovery 5 of 6): You write at least three things your rules cannot see and an idea for a different control for each. Runs on a Linux machine you own.
- Find persistence without an audit rule: diff a before and after snapshot (Purple Persistence 5 of 5): You find all four changes by comparing snapshots, with no audit rule at all. Runs on a Linux machine you own.
- Validate your detections with Atomic Red Team: You run one low-risk atomic test on a snapshotted lab machine and check whether your logging caught it. Runs on a lab machine you own.
Knowledge check
- According to Palantir's template, what should you do if you cannot generate a true positive for an alert? Answer: Break it down, refactor it or discard it. The validation section says each strategy must have true positive validation and, if you cannot generate a true positive alert, the alert may need to be broken down, refactored or entirely discarded.
- Why test with a clean baseline as well as a true positive? Answer: To see whether the rule stays quiet on normal activity. A true positive shows the rule can fire; only normal data shows how often it fires when it should not. The SigmaHQ guide describes a baseline check that surfaces false positives for this reason.
- Why does NIST suggest activating only a few sensors at first when deploying a detection system? Answer: A new deployment makes many false positives until tuned, and many sensors at once makes tuning hard. NIST's guide says a new deployment is likely to generate many false positives until fully tuned, and activating many sensors at once might overwhelm the consoles and make tuning difficult.
- Where must you run a harmless attack-technique test? Answer: On a machine you own or are explicitly authorized to test, ideally with a snapshot you can restore. Tests change real systems. The ADS README and NIST both advise a lab or test environment first, and the labs make you snapshot and clean up so the machine returns to its starting state.
Back to the syllabus or see all classes.
Related
- Detection engineering
- Build a purple-team bench: auditd on a Linux VM you own, with a clean snapshot (Purple Discovery 1 of 6)
- Catch cron persistence (T1053.003), then remove it and prove it is gone (Purple Persistence 1 of 5)
- Catch SSH authorized_keys changes (T1098.004) and see the limit of per-file rules (Purple Persistence 3 of 5)
- Catch systemd timer execution (T1053.006), including the one that leaves no file (Purple Execution 2 of 3)
- Catch ATT&CK T1016 and T1049 network discovery, and find what your rules cannot see (Purple Discovery 5 of 6)
- Find persistence without an audit rule: diff a before and after snapshot (Purple Persistence 5 of 5)
- Validate your detections with Atomic Red Team
- All classes
- Free cyber labs