Free tech learning for everyone, from basics to pro

Security OperationsCyber SecurityAdvanced

Detection engineering: writing, testing and mapping detections

In short: Detection engineering treats alert rules as software: each one starts from a clear hypothesis, is tested against real or simulated activity, and is tuned over time. Mapping rules to MITRE ATT&CK shows coverage gaps, and Sigma lets you write once and convert to many SIEMs.

What detection engineering is

Detection engineering is the discipline of building and maintaining the rules that turn logs into alerts. In immature SOCs, rules are switched on from vendor packs and never reviewed. In mature ones, every rule has an owner, a purpose, a test and a record of how well it performs. This approach is often called detection as code: rules live in version control, changes are reviewed, and deployment is automated.

Detection engineering lifecycleHypothesiswhat behaviour?Datawhich logs?Write rulequery or SigmaTestsimulate in labDeploywith runbookTunemeasure and adjust
Figure 1. Detections are treated like code: designed, tested, deployed and continually tuned.

Writing a good detection

Start with a hypothesis about attacker behaviour, not a single indicator. "Attackers dump credentials from LSASS memory" is a better starting point than "block this one hash", because it still works when the tool changes. Then ask which data source shows that behaviour (for example Sysmon process access events or EDR telemetry) and whether you actually collect it.

Good detections are:

  • Specific enough to avoid drowning analysts, but not so narrow that a renamed tool slips past.
  • Explained: each has a short runbook saying why it matters and how to triage it.
  • Tested: you have proved it fires on the behaviour and noted known false positives.

Sigma: a common rule language

Parts of a Sigma ruleMetadatatitle, id, author, statusLog sourceproduct, categoryDetectionselections and filtersConditionhow selections combineContextlevel, false positives, tags
Figure 2. A Sigma rule describes what to look for in a vendor-neutral way that can be converted to SIEM queries.

Sigma is an open, YAML-based format for describing log detections independently of any SIEM. Converters such as the pySigma-based sigma-cli translate a rule into Splunk, KQL, Elastic and other query languages. A simplified example that flags an office application starting PowerShell:

title: Office application spawning PowerShell
status: experimental
logsource:
  product: windows
  category: process_creation
detection:
  selection:
    ParentImage|endswith:
      - '\winword.exe'
      - '\excel.exe'
    Image|endswith: '\powershell.exe'
  condition: selection
falsepositives:
  - Approved macros used by finance
level: high
tags:
  - attack.execution
  - attack.t1059.001

The tags link the rule to MITRE ATT&CK technique T1059.001 (PowerShell). Public repositories hold thousands of community Sigma rules, which are a useful starting point, but always test and tune them for your environment.

Testing, mapping and measuring

  1. Reproduce the behaviour safely in an isolated lab you own. Open frameworks such as Atomic Red Team provide small, documented tests mapped to ATT&CK techniques.
  2. Confirm the logs arrive and the rule fires; save the test as a regression check.
  3. Run the rule over several weeks of historical data to estimate false positives before going live.
  4. Map each rule to ATT&CK techniques and keep a coverage view; tools such as ATT&CK Navigator can colour in what you detect.
  5. Track each rule's alert count and true positive rate, and retire or fix rules that only create noise.

Tip: coverage maps can mislead. One weak rule against a technique does not mean the technique is "covered"; record confidence too.

Practice

Why is "detect credential dumping from LSASS" a better hypothesis than "detect hash X"?
It targets behaviour that stays the same when attackers change or recompile their tools, so it lasts longer.
What does a Sigma converter do?
It translates a vendor-neutral Sigma rule into the query language of a specific SIEM or EDR.
How can you estimate a rule's false positive rate before deploying it?
Run it against several weeks of historical logs and review what it would have matched.

Key takeaways

  • Treat detections as code: version control, review, testing and owners.
  • Start from attacker behaviour, then confirm you collect the right data.
  • Sigma is a vendor-neutral YAML rule format that converts to many SIEMs.
  • Test rules safely in a lab and map them to MITRE ATT&CK.
  • Measure rule performance and retire noisy detections.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.