Most broken Sigma rules fail on syntax details, such as a modifier the backend does not support, a list where a map was needed, or a condition that binds differently than the author expected. This cheat sheet is a compact lookup for detection engineers writing or reviewing Sigma rules: the rule fields and which are mandatory, logsource values, value modifiers, condition operators and precedence, correlation rules, and the commands for checking and converting rules. It follows the SigmaHQ Sigma Rules Specification version 2.1.0 (release date 2 August 2025), checked in November 2026; confirm against the specification repository before relying on newer features. For what Sigma is, how the SigmaHQ rule repository is organised and how to deploy it, see the Sigma Rules Guide.
Key takeaways
- Only three things are mandatory. A rule needs
title,logsourceanddetection(with acondition); everything else is optional but expected in shared rules. - Maps are AND, lists are OR. Keys in one selection are ANDed; values in a list are ORed unless you add the
|allmodifier. - Matching is case-insensitive by default. Use
|casedfor case-sensitive strings; regular expressions with|reare case-sensitive unless you add|re|i. - Precedence is or, and, not, x of, brackets (least to most binding). Use brackets whenever a condition mixes
andandor. - Type modifiers depend on the backend.
re,cidrand similar modifiers must be supported by the target, so convert and test every rule against each backend you deploy to.
How to use this template
- Writing a rule: start from the skeleton in section 1, fill the fields in the order shown in section 2, then build selections with the modifier table in section 4.
- Reviewing a rule: check the mandatory fields, the logsource triple, each modifier against the table, and the condition against the precedence list in section 5.
- Converting a rule: use section 6 for
sigma-clicommands, backends and processing pipelines. - Version note: modifier and field availability is taken from specification v2.1.0. Version 2.1.0 added
neqand the time modifiers; older tooling may not accept them.
Detection engineering practice beyond syntax (prioritisation, testing strategy, lifecycle) is covered in the Detection Engineering Guide and the Detection as Code Guide.
1. Rule structure at a glance
A Sigma rule is a YAML document. The specification asks for UTF-8, LF line endings, 4-space indentation, lowercase keys, single-quoted strings and unquoted numbers. File names should be 10 to 70 lowercase characters using letters, digits and underscores, with a .yml extension.
1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.
title: Whoami Execution
id: 00000000-0000-4000-8000-000000000000 # random UUID v4
status: test
description: Detects execution of whoami.exe
references:
- https://example.org/source
author: Your Name
date: 2026-11-26
tags:
- attack.discovery
- attack.t1033
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith: '\whoami.exe'
condition: selection
falsepositives:
- Administrative scripts
level: mediumThe spec places top-level keys in this order: title, id, name, related, taxonomy, status, description, license, references, author, date, modified, logsource, detection, fields, falsepositives, level, tags, scope, then any custom fields.
2. Required and optional fields
| Field | Use | Format and allowed values |
|---|---|---|
title | Mandatory | What the rule detects, max 256 characters |
id | Optional | Globally unique, random UUID version 4. Issue a new id for major logic changes, derived rules kept active alongside the original, or merges |
name | Optional | Unique human-readable name, usable instead of the id in correlation rules |
related | Optional | List of id plus type: derived, obsolete, merged, renamed, similar |
taxonomy | Optional | Field and logsource naming scheme; default is sigma |
status | Optional | stable, test, experimental, deprecated, unsupported |
description | Optional | The activity detected, max 65,535 characters |
license | Optional | SPDX licence identifier |
author | Optional | Comma-separated if more than one |
references | Optional | List of sources the rule was derived from |
date, modified | Optional | ISO 8601 YYYY-MM-DD. Update modified when title, detection, level or logsource changes, or status becomes deprecated |
logsource | Mandatory | category, product, service, definition (see section 3) |
detection | Mandatory | Search identifiers plus condition (sections 4 and 5) |
fields | Optional | Log fields to show the analyst |
falsepositives | Optional | List of known benign triggers |
level | Optional | informational, low, medium, high, critical |
tags | Optional | Lowercase, namespaced with dots, e.g. attack.t1059.001 |
scope | Optional | Intended scope, e.g. server |
Level guidance from the spec: informational is for enrichment and should not raise cases; low and medium are informative and reviewed regularly; high should raise an internal alert for prompt review; critical indicates an incident and is used only when probability borders on certainty.
Status guidance: stable may be used in production; test is mostly stable but may need tuning; experimental may be noisy; deprecated is replaced by another rule linked in related; unsupported cannot be used as written.
3. Logsource
The logsource tells converters which data the rule applies to. Values are lowercase, spaces become underscores, and dots and hyphens are allowed. The three evaluated attributes can be used alone or together; definition is free text for readers and is not evaluated.
| Attribute | Selects | Examples |
|---|---|---|
category | A logical group of logs across products | process_creation, firewall, webserver, antivirus |
product | All logs from one product or operating system | windows, linux, apache |
service | A specific subset of a product's logs | security, system, sshd, applocker, firewall-as |
definition | Explanation of required logging configuration | "Requires Sysmon Event ID 1" or an audit policy note |
Prefer generic categories such as category: process_creation with product: windows over one rule per telemetry source; processing pipelines then map the category to Sysmon, Windows Security auditing or EDR data. Field names follow the Sigma taxonomy (for example Image, CommandLine, ParentImage). For fields without a mapping, use the name as it appears in the log with spaces removed; for Windows XML, join tag and attribute with an underscore (Provider_Name) and use the Data Name attribute for EventData fields. Telemetry choices are covered in the EDR Telemetry Guide.
4. Detection and value modifiers
Search identifiers, lists and maps
| Construct | Logic | Example |
|---|---|---|
| Map (key: value pairs) | All pairs ANDed | EventID: 4769 and TicketEncryption: '0x17' in one selection |
| List of values under one key | Values ORed | EventID: [517, 1102] |
| List of maps | Maps ORed | - Image|endswith: ... / - Description|contains: ... |
| List of strings (keywords) | Strings ORed, searched across the whole event | keywords: ['event::clear', 'event::drop'] |
Keywords with '|all': | Strings ANDed | All listed keywords must appear |
- Wildcards:
*matches any length,?one character. Prefer modifiers over leading and trailing wildcards. - Escaping: backslash escapes
*,?and itself. A plain backslash not followed by a wildcard can be single.\*is a literal asterisk;\\*is a backslash followed by a wildcard;\\\*is a literal backslash and asterisk. - Empty and null: empty is
'', null isnull.nullcannot sit in a list with other values; to express "not null", put the null test in its own selection and negate it in the condition. - Placeholders: values like
%Servers%are treated as placeholders only with the|expandmodifier (since Sigma 1.1). Standard names include%Administrators%,%JumpServers%,%Workstations%,%Servers%and%DomainControllers%. Tools that cannot resolve placeholders must reject the rule.
Value modifier reference
Modifiers follow the field name after a pipe and can be chained (field|mod1|mod2: value); they apply in the order written. The specification distinguishes transformation modifiers (generally backend-agnostic) from type modifiers, which the backend must support.
| Modifier | Group | Effect |
|---|---|---|
contains | Generic | Wildcards around the value: match anywhere |
startswith | Generic | Value at the start of the field |
endswith | Generic | Value at the end of the field, e.g. Image|endswith: '\cmd.exe' |
all | Generic | List values ANDed instead of ORed. Not allowed on a single value |
exists | Generic | true or false: field present or absent (presence only, not value) |
cased | Generic | Case-sensitive match (default is case-insensitive) |
neq | Generic and numeric | Field differs from the value (added in v2.1.0) |
windash | String | Generates permutations of hyphen, slash, en dash, em dash and horizontal bar for Windows command-line flags |
re | String (type) | PCRE subset: ., ^ $, * + ? {n,m}, character classes, |, groups. Other metacharacters are unsupported. Case-sensitive by default |
re|i, re|m, re|s | Regex sub-modifiers | Case-insensitive; multi-line anchors; dot matches newline |
base64 | Encoding | Value Base64 encoded |
base64offset | Encoding | Three variants covering 0 to 2 byte shifts, for values inside a larger encoded string |
utf16le (alias wide), utf16be, utf16 | Encoding | UTF-16 encodings; utf16 adds a byte order mark. Chain before base64 for encoded PowerShell |
lt, lte, gt, gte | Numeric | Numeric comparisons |
minute, hour, day, week, month, year | Time (v2.1.0) | Extract a number from a date value; no timezone or format conversion |
cidr | IP (type) | IPv4 or IPv6 range, e.g. DestinationIp|cidr: 10.0.0.0/8 |
expand | Specific | Resolve placeholders through the processing pipeline |
fieldref | Specific | Compare with another field of the same event; combinable with neq |
detection:
selection_img:
Image|endswith: '\powershell.exe'
selection_cli:
CommandLine|windash|contains:
- ' -enc '
- ' -encodedcommand '
filter_main_admin:
User|expand: '%Administrators%'
condition: all of selection_* and not 1 of filter_main_*5. Conditions and correlation
| Expression | Meaning |
|---|---|
sel1 and sel2, sel1 or sel2 | Logical AND, OR |
not filter | Negation |
( ... ) | Grouping |
1 of selection* | Any search identifier matching the pattern |
all of selection* | Every search identifier matching the pattern |
1 of them / all of them | Across all identifiers not starting with _. The spec discourages all of them because it blocks generic filtering downstream |
| Condition as a list | Each item generates a query; items are ORed |
Precedence, least to most binding: or, and, not, x of, brackets. So a or b and not c means a or (b and (not c)). Name selections selection_* and filters filter_* so pattern conditions stay readable and tuning can target filters.
Correlation rules
Correlations are separate YAML documents with a correlation section that refers to other rules by id or name.
| Key | Use | Values |
|---|---|---|
type | Mandatory | event_count, value_count, temporal, temporal_ordered |
rules | Mandatory | Ids or names of Sigma or correlation rules (chaining allowed) |
group-by | Optional | Fields defining the scope, ANDed when several (e.g. same host and user) |
timespan | Mandatory | Number plus lowercase unit: s, m, h, d (e.g. 90m) |
condition | Mandatory | Exactly one of gt, gte, lt, lte, eq, neq; for value_count add field |
aliases | Optional | Map different field names across rules to one name for group-by |
generate | Optional | Also convert referenced rules as stand-alone queries (default: correlation query only) |
title: Many failed logons from one source
correlation:
type: event_count
rules:
- failed_logon
group-by:
- IpAddress
timespan: 10m
condition:
gte: 20For shared exclusions across many rules, the Sigma Filters specification defines global filter documents (file prefix mf_ as best practice) that apply one tuning to several rules, so the base rules stay unmodified.
6. Testing and conversion
| Task | Command or component | Notes |
|---|---|---|
| Install the CLI | python -m pipx install sigma-cli | Or pip install sigma-cli |
| Find backends and pipelines | sigma plugin list, sigma list targets, sigma list pipelines | Install with sigma plugin install <id> |
| Validate rules | sigma check <path> | Run in CI on every change |
| Convert | sigma convert -t <backend> -p <pipeline> <path> | e.g. -t splunk -p sysmon; several -p allowed |
| Output formats | sigma list formats <backend>, then -f | e.g. Splunk saved searches |
| Schema validation | JSON schemas in the specification repository | Rules, correlations and filters each have a schema |
- Lint and check: run
sigma checkand schema validation in the pull request pipeline. - Convert per target: convert with the exact backend and pipelines used in production; a conversion error usually means an unsupported type modifier or a missing field mapping.
- Replay data: test against recorded true-positive events and a sample of normal traffic before enabling alerting.
- Stage the rollout: deploy as
experimentalortest, monitor volume, then promote tostable. - Roll back: disable the converted query and set
status: deprecatedwith arelatedlink if a replacement exists.
| Framework | Reference | How Sigma rules relate |
|---|---|---|
| NIST CSF 2.0 | DE.CM-01, DE.AE-02 | Monitoring for and analysing potentially adverse events |
| NIST SP 800-53 Rev 5 | SI-4, AU-6 | System monitoring; audit record review and analysis |
| MITRE ATT&CK | attack.* tags, e.g. T1059.001 PowerShell | Coverage mapping from rule tags |
Useful measures: share of rules converting without error per backend, share of rules with replay tests, false positive rate per rule level, and rules still at experimental after a set review period. See the Detection Engineering Metrics and KPIs Guide. How Sigma compares with file and network rule languages is in Sigma vs YARA vs Snort Rules.
Common syntax mistakes
- Duplicate keys in one map: depending on the parser this is rejected or one value silently overwrites the other; use a list or separate selections.
nullinside a value list: invalid; give it its own selection.- Unbracketed mixed conditions:
a or b and csilently meansa or (b and c). - Placeholder without
|expand:%Servers%is matched literally. - Unsupported regex features: lookarounds and other metacharacters outside the spec's PCRE subset fail or behave differently per backend.
Practitioner checklist
- Include
title,logsourceanddetectionwithcondition, plus a UUID v4id. - Set
status,level,falsepositivesand ATT&CKtagson every shared rule. - Use generic logsource categories and Sigma taxonomy field names.
- Prefer
contains,startswithandendswithto manual wildcards. - Check every type modifier (
re,cidr, time modifiers) is supported by each target backend. - Bracket any condition that mixes
andandor. - Name selections and filters consistently so
1 ofandall ofpatterns work. - Run
sigma checkand conversion for each backend in CI. - Replay true-positive and benign data before promoting a rule to
stable.
Standards and references
- SigmaHQ: Sigma Rules Specification
- SigmaHQ: Sigma Modifiers Appendix
- SigmaHQ: Sigma Correlation Rules Specification
- SigmaHQ: Sigma Filters Specification
- SigmaHQ: sigma-cli
- SigmaHQ: pySigma
- MITRE: ATT&CK
Related NHI Mgmt Group resources: Sigma Rules Guide · Detection Engineering Guide · Detection as Code Guide · Sigma vs YARA vs Snort Rules