Last updated: April 29, 2026
Detection engineering is the discipline of turning “attackers do X” into queries that reliably fire when X happens and stay quiet when it doesn’t. Sigma is the de-facto cross-SIEM rule format for expressing those detections — write once in YAML, convert to Splunk SPL, KQL for Sentinel, Lucene for Elastic, or any other backend. This module walks through the Sigma rule anatomy, the two mistakes most beginners make, and the workflow for taking a rule from idea to production without burying the SOC in false positives.
What Sigma is and is not
Sigma is a YAML specification maintained by SigmaHQ (GitHub: SigmaHQ/sigma). A Sigma rule describes a log-event match pattern in a vendor-neutral way. A converter tool (sigmac, or the newer pySigma) translates it to the query language of your SIEM. The community repo ships 3000+ rules covering common Windows, Linux, cloud, and network detections.
What Sigma is not: a SIEM, a detection platform, or an execution engine. It is a rule specification. You still need a SIEM to run the converted queries, and you still need to tune them against your environment.
Anatomy of a Sigma rule
title: Suspicious PowerShell Download Cradle
id: 8f3a7c9e-2b4d-4e6a-9f1c-8d5b3a7e2c4d
status: experimental
description: Detects PowerShell using DownloadString or IEX with a remote URL,
a common initial-access and in-memory execution technique.
author: Manish Garg, RingSafe
date: 2026-04-22
references:
- https://attack.mitre.org/techniques/T1059/001/
tags:
- attack.execution
- attack.t1059.001
logsource:
product: windows
category: process_creation
detection:
selection_img:
Image|endswith: '\powershell.exe'
selection_cmd:
CommandLine|contains:
- 'DownloadString'
- 'DownloadFile'
- 'Invoke-WebRequest'
- 'Invoke-RestMethod'
CommandLine|contains:
- 'http://'
- 'https://'
condition: selection_img and selection_cmd
falsepositives:
- Legitimate admin scripts pulling config or modules from internal servers
- Software installers using PowerShell download patterns
level: medium
Field-by-field walk-through
- title — short, action-oriented. Read aloud, should tell an analyst what triggered. “Suspicious PowerShell Download Cradle” beats “PS Detect 4”
- id — UUIDv4. Permanent identifier even if title changes. Always generate a fresh one
- status — experimental / test / stable / deprecated. Lifecycle marker
- logsource — what kind of data this rule needs. Combinations of
product,service,category. The converter uses this to pick the right index/table - detection — the actual match logic. Named selections (selection_img, selection_cmd) combined via the
conditionexpression - falsepositives — the FP causes you already know about. Tuning note for future analysts
- level — informational / low / medium / high / critical. Drives alerting thresholds downstream
Detection modifiers that save you from regex hell
Sigma provides field modifiers so you don’t write raw regex. The common ones:
|contains— substring match|startswith,|endswith— anchored substring|contains|all— ALL listed values must match (AND within a list)|re— regex, only when you actually need one|base64offset|contains— matches base64-encoded strings at any offset. Powerful for encoded payloads|cidr— IP range matches
Prefer modifiers over regex. Regex breaks in subtle ways across SIEMs during conversion, and it is slow at scale.
The condition DSL
Conditions are where selections combine:
condition: selection1 and selection2
condition: selection_process and not filter_admin
condition: 1 of selection_*
condition: all of selection_*
condition: selection and (filter_exclude1 or filter_exclude2)
The not filter_admin pattern is your main false-positive suppression lever. Define filters for known benign cases, then exclude them from the trigger condition.
The two mistakes beginners make
Mistake 1: too specific
A rule that matches the exact command line from one malware sample will miss the next variant. Write detections at the behaviour level, not the artifact level. “PowerShell downloading from an external URL” is behavioural. “PowerShell invoking IEX with exactly these 47 characters” is artifact-level and useless by next week.
Mistake 2: too broad
A rule that matches “any PowerShell execution” will fire 400 times per day in a Windows-heavy environment. Write detections with enough specificity that the expected fire rate is under 10 per day per 1000 endpoints. If it is higher, add exclusion filters until it comes down — without making the rule artifact-specific.
The sweet spot: behavioural pattern + environment-specific exclusions. Example:
detection:
selection:
Image|endswith: '\powershell.exe'
CommandLine|contains: 'DownloadString'
filter_scripts_dir:
ParentImage|startswith: 'C:\Program Files\RingSafe\Scripts\'
filter_known_admin:
User: 'CORP\svc_deploy'
condition: selection and not (filter_scripts_dir or filter_known_admin)
The rule development workflow
- Source the idea. MITRE ATT&CK technique, threat intel report, red team finding, or lessons-learned from a prior incident. Always cite the source in the rule
- Write it. Start with SigmaHQ repo for similar rules; adapt rather than greenfield
- Convert and test against historical. Use pySigma to render to your SIEM dialect, run as a search over the last 30 days. Look at what matches. Are the results all FPs? All TPs? Mix?
- Tune. Add filter selections for benign patterns you observe. Goal: <10 fires per day per 1000 endpoints at baseline
- Run in test mode for 1–2 weeks. Rule fires to a quieter “detection-testing” channel, not paging anyone. Tier 2 reviews daily, updates filters
- Promote to production only after TP rate is above 20% and volume is acceptable. Write the runbook as part of promotion
- Monitor. Track fire rate and TP rate weekly. If either drifts, investigate
Conversion: Sigma to your SIEM
# Install pySigma + backend of choice
pip install pysigma pysigma-backend-splunk pysigma-pipeline-windows
# Convert to Splunk SPL
sigma convert -t splunk -p sysmon rules/powershell_download.yml
# Sample output:
# (source="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
# Image="*\\powershell.exe"
# (CommandLine="*DownloadString*" OR CommandLine="*DownloadFile*" OR
# CommandLine="*Invoke-WebRequest*" OR CommandLine="*Invoke-RestMethod*")
# (CommandLine="*http://*" OR CommandLine="*https://*"))
Pipelines are important. A pipeline tells the converter what log source it is dealing with (-p sysmon, -p windows-audit, -p crowdstrike) so field names get mapped correctly. Without the right pipeline, Image becomes Image in Splunk but should be process_image in Sentinel.
Testing rules with Atomic Red Team
Atomic Red Team (github.com/redcanaryco/atomic-red-team) ships small, safe test scripts that execute each MITRE technique. Use them to validate rules end-to-end:
- Install Atomic Red Team framework on a test endpoint in your environment
- Run the atomic test for the technique your rule detects (
Invoke-AtomicTest T1059.001) - Confirm the rule fires in your SIEM
- Clean up the test artifacts
This is the only way to know your rule works without waiting for a real attacker. Tape out a testing schedule — quarterly at minimum, monthly is better.
Detection-as-code in a Git repo
Mature teams keep all Sigma rules in Git, with CI that:
- Lints YAML for Sigma schema compliance
- Converts each rule to target SIEM(s) and validates the query parses
- Runs converted queries against a staging dataset and reports fire counts
- Deploys merged rules to production via API
A minimal CI pipeline: GitHub Actions + pySigma + sigma-cli + SIEM API token. A weekend project. The payoff is that “detection X is failing” turns into “which commit broke it” instead of a tribal memory question.
Tuning metrics every rule needs
For every production rule, track:
- Fire rate: alerts per day
- TP rate: true positives / total fires (over 30 days)
- MTTR on TPs: how long from fire to contained
- Last TP date: if >180 days ago, re-evaluate whether rule is still relevant
Review these monthly. Rules with <5% TP rate are retired or refactored — they are costing analyst attention with no return. Rules with zero fires for 6 months are either broken or the threat evolved; investigate.
Where to source rules
- SigmaHQ/sigma — community repo, 3000+ rules. Not all are high quality; read before importing
- Elastic’s detection-rules repo — ES-native but many are portable
- Florian Roth’s blog and repos — Sigma co-creator, high-signal
- MDE / Sentinel GitHub — Microsoft publishes KQL queries; convert to Sigma when useful
- Red Canary’s threat reports — real-world technique prevalence, pairs well with detection work
What the next module covers
Sigma rules often rely on EDR telemetry — process_creation events with parent process, command line, hashes, and more. That telemetry does not come from Windows Event Logs alone; it comes from an EDR agent. The next module covers what EDR agents actually capture, how they differ from antivirus, and what the SOC uses them for beyond detection.
Module Quiz · 15 questions
Pass with 80%+ to mark this module complete. Unlimited retries. Each question shows an explanation.
Custom team training + practitioner advisory
Beyond the free academy — we run private workshops, vCISO advisory, and red-team exercises tailored to your stack. For Indian SMBs scaling past their first hire.