#Why this matters
In earlier lessons you wrote queries directly in Splunk SPL, Elastic KQL and Microsoft Sentinel KQL. Those queries work well inside a single platform, yet security teams rarely stay on one stack forever. An organisation might run Elastic for endpoint telemetry, Splunk in a regional branch, or migrate to Sentinel during a cloud transition. Rewriting hundreds of detections by hand for every platform wastes analyst hours and creates coverage gaps.
Sigma solves this portability problem the same way YARA does for files and Suricata does for network packets: it defines an open, structured YAML format for log-based detections. When you pair Sigma with detection engineering practices -- treating rules like software with version control, peer review and automated validation -- a single rule can be compiled into multiple SIEM backends without losing its underlying logic.
#From ad-hoc queries to detection engineering
An ad-hoc threat hunt query asks a one-off question about historical logs. A production detection rule runs continuously and wakes up an on-call analyst when it fires, so it requires far higher precision.
- HypothesisMap attacker behaviour (MITRE ATT&CK)
- TelemetryVerify required log fields exist
- AuthorWrite portable Sigma YAML with filters
- ConvertApply pipeline and compile to SIEM query
- ValidateTest against benign and attack logs
- TuneSuppress recurring false positives
Before writing a line of YAML, confirm three things:
- Behaviour over brittle IoCs: File hashes and IP addresses change in minutes. Target techniques such as suspicious parent-child process chains, encoded command lines or abnormal service creation.
- Telemetry availability: A rule checking
CommandLinefails silently if Windows process-creation auditing (Event ID 4688) does not include command-line arguments or if Sysmon Event ID 1 is not collected. - Triage context: Every alert needs a clear
description, MITRE ATT&CKtagsandfalsepositivesnotes so the L1 analyst knows what to verify first.
#Anatomy of a Sigma rule
Every Sigma rule is a YAML document divided into metadata, telemetry scope (logsource) and matching logic (detection).
| Section | Purpose | Common fields |
|---|---|---|
| Metadata | Identity, ownership and context | title, id, status, description, author, date, tags, level |
logsource |
Telemetry type the rule targets | category (e.g. process_creation), product (windows, linux), service (security, sshd) |
detection |
Named search blocks and boolean condition |
selection, filter_*, condition |
| Triage hints | Expected noise and severity | falsepositives, level (low, medium, high, critical) |
Here is a complete rule detecting certutil.exe abused to download a remote payload on Windows:
title: Suspicious Certutil Download Activity
id: 6d4e2a10-7b3c-4f8a-9c12-1a2b3c4d5e6f
status: test
description: Detects certutil.exe invoked with URL cache flags to fetch remote files.
references:
- https://attack.mitre.org/techniques/T1105/
author: CyberSamSU SOC Lab
date: 2026-11-10
tags:
- attack.command_and_control
- attack.t1105
logsource:
category: process_creation
product: windows
detection:
selection_img:
Image|endswith: '\certutil.exe'
selection_flags:
CommandLine|contains:
- 'urlcache'
- 'verifyctl'
selection_url:
CommandLine|contains: 'http'
filter_local_update:
CommandLine|contains: 'http://pki.lab.local/'
condition: all of selection_* and not filter_local_update
falsepositives:
- Legitimate internal PKI or certificate revocation list checks
level: highNotice the id field: a UUIDv4 string that stays fixed even if the title changes, allowing SIEM pipelines and Git repositories to track rule revisions cleanly. Inside detection, list items under a single field act as logical OR (urlcache OR verifyctl), whereas multiple fields inside the same block act as logical AND.
#Modifiers and condition logic
Plain string matching in Sigma is case-insensitive by default, which helps across Windows paths, yet attackers routinely alter flag prefixes, encodings and spacing. Field value modifiers appended with a pipe (|) handle these variations cleanly.
| Modifier | Behaviour | Example use |
|---|---|---|
contains |
Substring match anywhere in field | `CommandLine |
startswith / endswith |
Anchored prefix or suffix match | `Image |
all |
Requires every listed item to match (AND instead of OR) | `CommandLine |
windash |
Matches both - and / before Windows flags |
`CommandLine |
base64offset |
Generates all three Base64 byte-alignment variants | `CommandLine |
wide |
Encodes target string as UTF-16LE before applying next modifier | `CommandLine |
re |
Evaluates a regular expression | `CommandLine |
The condition expression combines selection and filter blocks using and, or, not, parentheses and wildcard selectors such as all of selection_* or 1 of filter_*. Keep filter blocks separate from selection blocks so analysts can add new exclusions without accidentally breaking core detection logic.
#Translating rules with pipelines and sigma-cli
Sigma rules use generic field names (Image, CommandLine, ParentImage) defined by the Sigma taxonomy. Your SIEM might store those fields as process.executable (Elastic ECS) or ProcessCommandLine (Microsoft Sentinel DeviceProcessEvents).
A processing pipeline bridges that gap by mapping generic Sigma fields and log sources to a specific telemetry schema before compilation. Today, sigma-cli (sigma) is the maintained SigmaHQ tool that replaces the older legacy sigmac script, though you will still encounter sigmac in older playbooks.
$ sigma check rules/certutil_download.yml
Checked 1 rules: 0 errors, 0 warnings
$ sigma convert -t splunk -p sysmon rules/certutil_download.yml
index=sysmon EventCode=1 Image="*\\certutil.exe" (CommandLine="*urlcache*" OR CommandLine="*verifyctl*") CommandLine="*http*" NOT CommandLine="*http://pki.lab.local/*"Always review the generated query before pushing it to production. Check whether case sensitivity, wildcard cost or missing index constraints could slow down SIEM searches over 24-hour windows.
#Defending and common mistakes
- Matching filenames only: Relying solely on
Image|endswith: '\powershell.exe'misses renamed binaries (copy powershell.exe helper.exe). CombineOriginalFileName(from PE metadata in Sysmon) withCommandLinepatterns where available. - Unbounded
|repatterns: Complex regular expressions with catastrophic backtracking slow down SIEM backends and fail Sigma linting. Prefer|contains,|startswithand|endswithwhenever possible. - Mixing legacy
sigmacandsigma-cliflags: If an older tutorial referencessigmac -c, checksigma list pipelinesandsigma convert --helpinsigma-clirather than guessing pipeline names. - No validation corpus: A rule that never ran against both benign baseline logs and an Atomic Red Team or lab test trace is an untested hypothesis. Store sample positive and negative JSON log fixtures beside every rule in Git.
#Summary
- Sigma provides a portable YAML format for log-based detections, separating detection intent from SIEM query syntax.
- Strong rules combine
logsource,selectionblocks, value modifiers (|contains,|all,|windash,|base64offset) and narrowfilterexclusions. - Processing pipelines in
sigma-cli(which replaced legacysigmac) translate generic Sigma fields into platform-specific queries such as Splunk SPL, Elastic KQL or Sentinel KQL. - Treating detections as code -- with UUID tracking, MITRE ATT&CK tags and baseline log tests -- keeps false positives low as telemetry changes.