✳ The reference desk / In practice

Detection rule

A saved query that names the events it reads, the values it matches, and when it raises an alert. It works only if those events are collected and reach the system that runs it.

What it means

A detection rule is a saved query that raises an alert when events match it. A log source says which events it reads. A selection says which values must match, and a condition says when to fire. Notes on expected false positives and a severity level tell the analyst what to expect.

A rule is only half of a detection. The other half is the data. If the events a rule reads are never logged, or never reach the system that runs it, the rule is blind, however good its logic. Sigma is an open format for writing rules once and converting them to each SIEM's query language. Tagging a rule with an ATT&CK technique records what it is meant to catch, not whether it can.

See the idea / Detection

A detection rule can only fire on events that reach it.

Build one rule part by part. Then see it stay silent because its events never arrived, and see what changes when they do.

Nyx, Meridian's threat hunter, writes a rule for one behavior: a scheduled task created from the command line on a Windows host. Meridian has 38 ground-station hosts. Each runs Sysmon, which writes a process-creation event, event ID 1, to the host's own log. A forwarder on each host sends chosen log channels to the SIEM.

Detection rule: Build one rule part by part. Then see it stay silent because its events never arrived, and see what changes when they do. The chapter text below describes every state.Nyx’s rule · scheduled taskTagged attack.t1053.005Log sourceNot namedWhich events the rule readsSelection and conditionNot writtenWhat must match, and whenEvents in the SIEMNot checkedFrom 38 ground-station hostsWhat the rule can showNothing yetAn alert, or a silenceWHICH EVENTS DOES IT READ?

01 / 04

Source

The rule names its log source: process-creation events from Windows hosts. Each one records a program that started and its command line.

More about this step

Every field the rule matches must exist in the events it reads. In Sigma the log source is written as a category and a product, here process_creation and windows. A converter later maps it to the right index and field names in the SIEM.

Keep in mindOne rule and one way of creating a task. A task created through PowerShell or the Task Scheduler interface starts no schtasks.exe process, so this rule would miss it. Being able to fire is not the same as having fired: the rule still needs a harmless test.

Read the visual, step by step
  1. Source. The rule names its log source: process-creation events from Windows hosts. Each one records a program that started and its command line. Every field the rule matches must exist in the events it reads. In Sigma the log source is written as a category and a product, here process_creation and windows. A converter later maps it to the right index and field names in the SIEM.
  2. Match. The selection matches schtasks.exe with /create in the command line. The condition fires on a single match, at medium severity. Installers and admin scripts also create tasks, so the rule lists them as expected false positives. Nyx tags it attack.t1053.005, the ATT&CK technique Scheduled Task. The tag records what the rule is meant to catch.
  3. Data. A week of searching finds nothing. Nyx counts the hosts that sent any process event to the SIEM: 0 of 38. The Sysmon channel was not on the forwarder list. The hosts were recording. The events stayed in each host's own log. So the empty result meant no data, not no tasks. The rule had never had a chance to fire.
  4. Forward. The Sysmon channel is added to the forwarder list on all 38 hosts. The events now arrive, so the rule can fire. Whether it does is still untested. A detection is the rule plus its data. With both in place, the next step is a harmless emulation: create a test task on a test host at a recorded time and check that the alert fires.

One rule and one way of creating a task. A task created through PowerShell or the Task Scheduler interface starts no schtasks.exe process, so this rule would miss it. Being able to fire is not the same as having fired: the rule still needs a harmless test.

Flow references: SigmaHQ: Sigma Rules Specification · MITRE ATT&CK: T1053.005 Scheduled Task · Microsoft Sysinternals: Sysmon

AN ILLUSTRATIVE SCENARIO

A card payment team's silent rule

An online retailer writes a rule that alerts when one account adds more than five new payment cards in an hour, a sign of card testing. For two months it never fires, and the team takes that as good news. A test that adds six harmless test cards finds the real cause. The rule reads a field named card_added, but the payment service logs the event as payment_method_created. After one corrected field name, the test alert arrives within a minute.

Put it to work

  1. For each rule, write down the log source it reads, and check that every host or service in scope sends those events today.
  2. Test the rule with a harmless instance of the behavior it targets, and keep the test with the rule so it runs again after every change.
  3. Give each rule an owner and a review date, and record every exclusion with its reason and what the rule no longer sees.

How to check your work

Run a harmless emulation of the behavior at a recorded time and confirm the alert arrives. Then count the hosts that sent at least one of the rule's events in the last day. Both numbers belong in the rule's record.

Connect the ideas

  • SIEM

    A capability that collects, parses, stores, and searches security telemetry and often fires alerts.

  • Alert

    A notification that a rule or model wants a human to look at one or more records.

  • False positive

    An alert that did not represent the harmful event the detector was meant to catch.

  • MITRE ATT&CK

    A public knowledge base of attacker behavior seen in real intrusions. Tactics name the attacker's goal at each stage. Techniques and sub-techniques name how that goal is reached.

Explore a field lesson

Find your next idea.

Tip: press / to open search. Escape closes this window.