Writing and Converting a Sigma Rule
Author vendor-agnostic Sigma detection rules mapped to MITRE ATT&CK techniques, validate selection logic, explore argument obfuscation evasion techniques, and compile rules into native query dialects using pySigma.
Contentsand lesson path
On this page
- Anatomy of a Production-Ready Sigma Rule
- Authoring a Sigma Rule and Compiling with pySigma
- Practice check
- Review prompt
Lessons of Detection Engineering
- The Detection Lifecycle and Detections as Code Concept · 15 min
- Writing and Converting a Sigma Rule Lab · 30 min
- Proving Detections with Adversary Emulation Lab · 30 min
- Tuning for Precision Without Blind Spots Worked example · 20 min
- Coverage Gaps, Deception and Hypothesis-Driven Hunting Worked example · 25 min
- Detection Engineering Check Knowledge check · 8 questions
What you will learn
- Write a Sigma rule for a specific ATT&CK technique, convert it to a SIEM query, and document its data source, logic and known false positives.
Prerequisites: Security Logging & SIEM
01. Anatomy of a Production-Ready Sigma Rule
Sigma is the universal standard for signature description in computer security — equivalent to Snort for network traffic or YARA for file payloads. Prior to Sigma, threat intelligence teams shared detections as unformatted blog paragraphs or proprietary query snippets tied to a specific commercial vendor. If an advisory shared a Splunk query, organizations running Elastic Security, Microsoft Sentinel, or Wazuh had to manually translate the logic into their respective query languages.
A production-grade Sigma rule is defined in human-readable YAML structured into five mandatory functional sections:
1. Metadata & Identification
Defines title, a unique UUID4 id (guaranteeing deterministic tracking across rule version updates), operational status (experimental, test, stable, deprecated), detailed description, and external references to threat reports.
2. Categorization & MITRE ATT&CK Tagging
Annotated with standardized tags that map the detection to exact MITRE ATT&CK matrix identifiers: tactics (e.g., attack.execution) and specific technique IDs (e.g., attack.t1059.001 for PowerShell).
3. Log Source Specification (logsource)
Explicitly declares the telemetry requirements necessary for rule execution: category (such as process_creation), product (such as windows), and service (such as sysmon). This ensures the rule is only evaluated against relevant telemetry indices.
4. Detection Logic & Modifiers (detection)
Specifies field selections, search modifiers, and boolean evaluation logic. Sigma provides powerful string and list modifiers:
|contains: Substring matching (case-insensitive by default in most backends).|endswith&|startswith: Prefix and suffix matching, commonly used for image paths and file extensions.|all: Requires all values in a defined list to match simultaneously, rather than default OR semantics.|re: Regular expression matching adhering to PCRE standards.|base64offset: Automatically expands a target search string into all three possible base64-encoded representations, defeating simple base64 command obfuscation.
The condition statement defines the relationship between selections, exclusions, and thresholds (such as selection_process and selection_cli and not filter_admin_tools or 1 of selection_*).
5. False Positives & Severity Rating
Every rule must document known benign conditions in falsepositives (such as legitimate administrative management scripts) and assign an operational level (informational, low, medium, high, critical) that informs SOC paging priorities.
03. Practice check
04. Review prompt
Deconstruct the core architectural sections of a production Sigma rule (metadata, MITRE ATT&CK tags, logsource, detection logic, false positives, and severity level), explaining why each section is critical for operational clarity.
Explain the technical mechanics of the pySigma conversion engine, detailing how pipelines map abstract field names (like CommandLine and Image) into concrete target schemas (such as ECS process.command_line and process.executable). Outline the steps for compiling a single Sigma rule into OpenSearch Lucene, Splunk SPL, and Microsoft Sentinel KQL without altering the source YAML.
Describe how to manage detection rule versioning and deprecation in enterprise Git repositories, explaining why UUID4 rule IDs must remain constant across logic revisions while rule status transitions from experimental to stable.
Discuss the role of custom pySigma processing pipelines in handling proprietary internal logging schemas, explaining how organizations author custom YAML pipeline extensions to remap organizational log fields without modifying open-source upstream community rules.
Explain how detection engineering teams measure the operational trade-offs between detection precision and recall when designing Sigma rules, describing how overly broad substring matches trigger devastating SOC alert fatigue while excessively narrow command-line constraints allow trivial adversary string evasion through backtick insertion and variable splitting.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.