Skip to content

Lesson 7 of 13 · 16m

Sigma Is a Data Structure, Not a Query

Sigma rule anatomy — logsource, selections, modifiers like windash and all — and where pySigma conversion to SPL, KQL, and EQL stops being portable.

Sigma is a data structure that compiles to a query, not a query you write. A rule is YAML: metadata on top, a logsource declaring what telemetry it expects, a detection block containing named selections and a condition combining them, and a level. The compiler — pySigma with a backend, driven by the sigma CLI — turns that data structure into Splunk SPL, Sentinel KQL, Elastic KQL/EQL/Lucene, or Chronicle YARA-L.

The anatomy that matters

title: LSASS Memory Access
id: 8d4f8e1e-...-uuid
status: test
author: you
date: 2026/11/18
references:
  - https://attack.mitre.org/techniques/T1003/001/
logsource:
  category: process_access
  product: windows
detection:
  selection_target:
    TargetImage|endswith: '\lsass.exe'
  selection_access:
    GrantedAccess:
      - '0x1010'
      - '0x1410'
  filter_known:
    SourceImage|startswith: 'C:\Program Files\'
  condition: selection_target and selection_access and not filter_known
falsepositives:
  - Antivirus and backup agents reading LSASS
level: high

The condition is a boolean expression over named selections; each selection is a map of field|modifier: values. Lists are OR by default; |all turns a list into AND — CommandLine|contains|all requires every listed substring. The modifiers are where Sigma's power lives: |contains, |startswith, |endswith, |re (regex), |cased, |fieldref (compare two fields), |exists, |base64offset, |expand (fill %var% placeholders), and |windash — which expands - to / so -enc and /enc match with one pattern, because PowerShell accepts both and attackers know it.

logsource is not decorative. category: process_creation + product: windows tells the converter which index/table and which field mappings apply. A rule with no product compiles to a generic query that may not match your field names at all.

The metadata fields earn their keep: falsepositives documents the known-benign shapes an analyst should expect (attackers read this field — SigmaHQ rules are public), references carries the technique links, level orders triage: informational < low < medium < high < critical.

Conversion is where portability ends

pySigma is the current toolchain; the legacy sigmac is deprecated. sigma convert -t splunk -t kusto rules/ does the mechanical work. What it cannot do:

  • Correlation rules don't fully port. Sigma correlations (event_count, temporal) are a newer spec layer; not every backend compiles them, and the ones that do produce queries with different windowing semantics.
  • Regex flavors differ. Sigma |re semantics, Splunk regex, KQL matches regex — escaping and syntax disagree on edge cases.
  • Field names are a mapping file, not magic. The converter knows Image → process.executable only if the backend's pipeline config says so.

The check is mechanical and should run in CI: sigma convert every rule for every target backend; a rule that fails conversion is broken before it reaches the SIEM. SigmaHQ's public repository — thousands of rules named proc_creation_win_*.yml, proc_access_win_*, registry_set_* — is both the corpus to port and the corpus attackers read. Public rules are evaded precisely because they are public; treat them as a baseline to tune, not a finished deployment.

Status is a contract

status: experimental → test → stable → deprecated is the lifecycle baked into the format. Deploy at test on real telemetry, tune exclusions, promote to stable once the false-positive rate is measured. A rule that sits at experimental in production for six months is a rule nobody owns.

Selection mechanics worth internalizing

A condition like 1 of selection_* or all of them lets one rule express "any of these three shapes" without duplicating the rule — SigmaHQ uses 1 of them patterns constantly for technique-level coverage. And unnamed selections exist for single-map detections, but name every selection anyway: the day the rule needs a second selection or a filter, you'll rewrite the condition regardless — cheaper to write it named from the start. condition: selection_target and selection_access and not filter_known reads as the hypothesis it is; condition: selection and not filter reads as a wall.

A rule is also a review surface

Because a Sigma rule is data, reviewers can diff it: a tuning pass is a YAML diff of selections and filters, not a query rewrite, and the falsepositives list travels with the logic it modifies. Keep one rule per file, filename matching SigmaHQ convention — proc_access_win_lsass_dump.yml — so grep and Navigator exports both find it without an index.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.