PISA Pakistan β€” Community CERT

← βš™οΈ SOC Analyst Foundations

8. Writing SIEM Detection Rules with Sigma

⏱ 12 min

The Role of Detection Rules in a SOC

A SOC is only as effective as its detection capabilities. SIEM systems like ELK or Splunk collect logs from endpoints, firewalls, and applications β€” but without proper detection rules, these logs remain noise. Sigma is an open standard for writing detection rules that can be converted into SIEM-specific queries, enabling analysts to share and reuse detection logic across platforms.

Understanding Sigma Rule Structure

Sigma rules are written in YAML format with clear sections:

  • Title: A concise name describing the detection (e.g., "Suspicious PowerShell Execution").
  • Logsource: Specifies the data source (Windows Event IDs, Sysmon, firewall logs).
  • Detection: Defines the conditions β€” keywords, field values, or patterns to match.
  • Level: Assigns severity (informational, low, medium, high, critical).
  • Tags: Maps to MITRE ATT&CK tactics and techniques.

Practical Rule Writing Steps

  1. Identify the Attack Pattern: Start with threat intelligence from MISP or recent incident data from your TheHive cases. For example, Pakistani users frequently report WhatsApp phishing links β€” write a rule to detect clicks to short URLs from messaging apps.
  2. Select the Log Source: Choose the appropriate log type β€” Windows Event ID 4104 for PowerShell, Sysmon Event ID 1 for process creation, or firewall logs for network anomalies.
  3. Write Detection Logic: Use field-based conditions. Example: EventID: 1 AND ParentImage: '*whatsapp*' AND Image: '*cmd.exe*'.
  4. Test the Rule: Deploy in a test environment first; tune for false positives. If easypaisa transaction logs generate noise, refine your conditions.
  5. Convert and Deploy: Use sigmac to convert Sigma rules into ELK DSL or Splunk SPL.

MITRE ATT&CK Mapping for Pakistani Threat Scenarios

Map your rules to ATT&CK techniques relevant to local threats:

  • T1566 (Phishing): Detect suspicious email attachments or WhatsApp link clicks.
  • T1048 (Exfiltration): Alert on large outbound transfers during off-hours.
  • T1070 (Indicator Removal): Detect clearing of Windows Event Logs.

Case Study: OLX Scam Detection Rule

An OLX seller receives a "buyer" message asking to pay via a phishing link. Write a rule:

title: OLX Phishing Link Detection
logsource:
  product: windows
  service: Sysmon
detection:
  selection:
    EventID: 1
    ProcessName: '*chrome.exe*'
    CommandLine: '*olx*payment*'
  condition: selection
level: high
tags:
  - attack.t1566

This alerts analysts when a browser navigates to a URL containing "olx" and "payment" β€” a common scam indicator.

Do / Don't

  • Do: Collaborate with threat intelligence teams to align rules with current actor TTPs.
  • Do: Regularly review and tune rules β€” what catches attacks today may cause false positives tomorrow.
  • Don't: Write overly broad rules β€” they generate alert fatigue and overwhelm analysts.
  • Don't: Skip MITRE ATT&CK mapping β€” it helps stakeholders understand detection rationale.

Key Takeaway

This week, write one Sigma rule based on a recent alert from your SOC environment. Convert it using sigmac and test it in your ELK sandbox. Share the rule with your team β€” collaborative detection development strengthens your SOC's defenses against evolving threats.

← PrevNext β†’