Sigma Rules in Brief
YARA describes files. Most of what an incident leaves behind, though, is in logs: process creations, registry changes, DNS queries, logons. Every SIEM has its own query language (Splunk SPL, Elastic's KQL and EQL, Microsoft Sentinel's KQL, …), so a detection written for one can't be shared with a team using another. Sigma is to logs what YARA is to files: a vendor-neutral, YAML-based rule format that converters translate into each SIEM's language. This lesson writes one Sigma rule for the lab sample's behaviour and evaluates it by hand on synthetic events. Detection engineering with Sigma at scale (pipelines, testing, tuning, ATT&CK coverage) is the subject of sec-blue-team.
Anatomy of a Sigma rule
title: Program in Downloads sets an autostart Run value
id: 5c0e4a8e-0b7d-4c55-9f0d-2b6d6f1a6c01
status: experimental
description: A process whose image is in a user's Downloads folder writes a value under a Run key.
references:
- https://attack.mitre.org/techniques/T1547/001/
author: ExcelTAD lab
date: 2026-01-15
tags:
- attack.persistence
- attack.t1547.001
logsource:
product: windows
category: registry_set
detection:
selection:
TargetObject|contains: '\CurrentVersion\Run\'
Image|contains: '\Downloads\'
filter_known:
Image|endswith:
- '\LabVendorUpdater.exe'
condition: selection and not filter_known
falsepositives:
- Portable software that registers itself to start at logon from the Downloads folder
level: highlogsourcesays which logs the rule applies to (product,category,service); the converter maps it to an index or table, for example Sysmon event 13 forregistry_set.detectionholds named selections: a map is an AND of its fields; a list of values for one field is an OR. Modifiers after|change the comparison:contains,startswith,endswith,re,all(all list values must match),cidr,base64offset,windashand others. Values are case-insensitive by default.conditioncombines selections:and,or,not, parentheses, and1 of selection_*/all of them.falsepositivesandleveltell the analyst what to expect;tagscarry the ATT&CK mapping.
Rules are converted with pySigma and its sigma-cli (the older sigmac tool is retired), for example sigma convert -t splunk -p sysmon rule.yml. The public rule repository (SigmaHQ) holds thousands of rules.
Evaluating the rule by hand
A converter turns the rule into a query; the semantics are simple enough to apply directly. The example encodes the detection section as Python data and evaluates it on synthetic Sysmon registry events (event 13), the same events as in Process Monitor and Sysmon plus an allow-listed updater.
def match_field(value, spec):
field_mod, wanted = spec
_, _, mod = field_mod.partition("|")
value = (value or "").lower()
values = [w.lower() for w in (wanted if isinstance(wanted, list) else [wanted])]
test = {"contains": lambda v, w: w in v, "startswith": str.startswith, "endswith": str.endswith,
"": lambda v, w: v == w}[mod]
return any(test(value, w) for w in values) # list of values = OR
def match_selection(event, selection): # map of fields = AND
return all(match_field(event.get(k.partition("|")[0]), (k, v)) for k, v in selection.items())
detection = {
"selection": {"TargetObject|contains": "\\CurrentVersion\\Run\\", "Image|contains": "\\Downloads\\"},
"filter_known": {"Image|endswith": ["\\LabVendorUpdater.exe"]},
}
condition = lambda s: s["selection"] and not s["filter_known"]
events = [
{"EventID": 13, "UtcTime": "2026-01-15 10:04:12", "Image": r"C:\Users\lab\Downloads\labagent.exe",
"TargetObject": r"HKU\S-1-5-21-1000\Software\Microsoft\Windows\CurrentVersion\Run\LabAgentUpdater"},
{"EventID": 13, "UtcTime": "2026-01-15 10:05:30", "Image": r"C:\Program Files\LabVendor\updater.exe",
"TargetObject": r"HKLM\SOFTWARE\LabVendor\Updater\LastCheck"},
{"EventID": 13, "UtcTime": "2026-01-15 11:20:02", "Image": r"C:\Users\kim\Downloads\LabVendorUpdater.exe",
"TargetObject": r"HKU\S-1-5-21-1001\Software\Microsoft\Windows\CurrentVersion\Run\LabVendor"},
{"EventID": 13, "UtcTime": "2026-01-15 12:41:57", "Image": r"C:\USERS\ANA\DOWNLOADS\NOTES-SYNC.EXE",
"TargetObject": r"HKU\S-1-5-21-1002\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\NotesSync"},
]
for e in events:
s = {name: match_selection(e, sel) for name, sel in detection.items()}
verdict = "ALERT" if condition(s) else "-"
print(f"{verdict:<5} {e['UtcTime']} {e['Image'].split(chr(92))[-1]:<22} selection={s['selection']!s:<5} filter={s['filter_known']}")ALERT 2026-01-15 10:04:12 labagent.exe selection=True filter=False
- 2026-01-15 10:05:30 updater.exe selection=False filter=False
- 2026-01-15 11:20:02 LabVendorUpdater.exe selection=True filter=True
ALERT 2026-01-15 12:41:57 NOTES-SYNC.EXE selection=True filter=False
Three things to notice: the vendor's updater in Downloads would have matched the selection, and the filter removes it (that is how known false positives are handled, visibly, inside the rule); the upper-case event matches too, because Sigma values are case-insensitive; and the fourth alert, NOTES-SYNC.EXE, may well be legitimate portable software, which is why the rule lists it under falsepositives and why someone must triage every alert.
How Sigma fits with the rest
| Format | Describes | Typical source |
|---|---|---|
| YARA | files and memory | samples, disks, process memory |
| Sigma | log events | SIEM: Sysmon, Windows Security, proxy, DNS, cloud audit logs |
| Suricata / Snort | network packets and flows | IDS sensors (rules) |
| STIX | indicators and their context, carrying any of the above | sharing (STIX) |
A good malware analysis report ships all three kinds of detection where they apply: a YARA rule for the file, a Sigma rule for its behaviour, and network indicators or an IDS rule for its traffic.
How Sigma rules are tested and maintained
A Sigma rule is code and is treated like it:
- Positive tests: keep a few log events that must match (from the lab run, or from an attack simulation such as an Atomic Red Team test executed in the lab) next to the rule, and check them in CI after every change, like the evaluation above.
- Negative tests: run the converted query over a week of production logs before enabling alerts; every hit is either a true positive, a filter to add, or a sign that the rule is too broad.
- Status field:
experimental→test→stableas the rule proves itself;deprecatedwhen it is replaced. - Beyond single events: version 2 of the Sigma specification adds correlation rules (for example, the same rule firing on more than N hosts in an hour, or several different rules firing for one user in sequence) and separate filter files for environment-specific exclusions, so shared rules don't need local edits. Support depends on the converter backend; check it before relying on it.
Pitfalls
- Rules for logs you don't collect. A
registry_setrule is useless without Sysmon event 13 (or EDR registry telemetry); check the log source first. - Field names differ between Sysmon, Windows Security and EDR schemas; conversion pipelines map them, and a wrong pipeline silently produces a query that never matches.
- Over-broad
contains:Image|contains: 'temp'matchesC:\Program Files\Template Studio\; anchor with path separators. - Untested conversion: always run the converted query on sample events you know should match.
Practice
1. Write a selection that matches cmd.exe or powershell.exe started by any process whose image is in Downloads.
For category: process_creation: selection: {Image|endswith: ['\cmd.exe', '\powershell.exe'], ParentImage|contains: '\Downloads\'} with condition: selection.
2. What would change if the filter were Image|endswith: 'updater.exe', without the backslash and the vendor prefix?
It would still filter the vendor's LabVendorUpdater.exe, but also any program whose name ends in updater.exe, such as an attacker's labupdater.exe in Downloads, because endswith compares the end of the string case-insensitively. Filters should be as narrow as the false positive they remove: the full file name with its leading \, ideally with the signer or a hash checked elsewhere.
3. Why is the Sigma rule's id a UUID?
So the rule keeps a stable, unique identity across repositories, renames and conversions; derived rules reference it in a related field.
Test yourself
What is Sigma?
- A malware family
- A vendor-neutral YAML format for log-based detection rules, converted to SIEM queries
- A packet capture format
- A YARA module
In a Sigma selection, how are several fields in one map combined, and several values in one list?
- Fields OR, values AND
- Fields AND, values OR
- Both AND
- Both OR
Why did the upper-case NOTES-SYNC.EXE event match the rule?
- Sigma values are case-insensitive by default
- Because of a regex
- Because the filter failed
- Upper case is always malicious
Which tool converts Sigma rules today?
- yarac
- pySigma with sigma-cli
- tshark
- ssdeep