From use case to rule
Detection engineering turns knowledge of attackers into reliable, documented and measurable detections. Everything starts with a use case: a precise malicious behaviour you want to spot in a given context.
- 01 · Need — Priority threat, ATT&CK technique, incident or Red Team finding
- 02 · Research — Understand the technique and the logs it produces
- 03 · Development — Write the rule, document it, define triage
- 04 · Testing — Replay the technique, measure false positives
- 05 · Deployment — Versioned release, performance monitoring
- 06 · Tuning — Justified exclusions, improvement, retirement if obsolete
Prioritising: what to detect first?
You cannot detect everything. Prioritisation crosses three dimensions:
- The threat: techniques used by adversaries targeting your sector (see Threat intelligence);
- Visibility: do you have the necessary logs? If not, collection comes first;
- Impact: techniques that lead to critical assets (privileged identities, backups, sensitive data).
Sigma, the universal format
Sigma is an open YAML format for describing detection rules independently of the SIEM. The same rule can be converted into a query for Microsoft Sentinel (KQL), Splunk (SPL), Elastic, QRadar and many others. Thousands of community rules are available and make an excellent starting point.
title: Suspicious access to LSASS memory
id: 4a1c2e3f-8d5b-4e7a-9c2d-1f0e6b7a8c90
status: experimental
description: >
Detects an unusual process opening LSASS with rights that allow
reading memory (credential extraction).
references:
- https://attack.mitre.org/techniques/T1003/001/
tags:
- attack.credential-access
- attack.t1003.001
logsource:
product: windows
category: process_access
detection:
selection:
TargetImage|endswith: '\lsass.exe'
GrantedAccess|contains:
- '0x1010'
- '0x1410'
- '0x1fffff'
filter_legit:
SourceImage|endswith:
- '\MsMpEng.exe'
- '\csrss.exe'
- '\wininit.exe'
condition: selection and not filter_legit
falsepositives:
- Legitimate security or backup solutions (exclude them by name)
level: high
The same logic in KQL (Microsoft Sentinel / Defender)
DeviceEvents
| where ActionType == "OpenProcessApiCall"
| where FileName =~ "lsass.exe"
| where InitiatingProcessFileName !in~ ("MsMpEng.exe", "csrss.exe", "wininit.exe")
| summarize Attempts = count(), First = min(Timestamp)
by DeviceName, InitiatingProcessFileName, InitiatingProcessAccountName
| order by Attempts desc
Another example: Kerberoasting
SecurityEvent
| where EventID == 4769
| where TicketEncryptionType == "0x17" // RC4-HMAC
| where ServiceName !endswith "$"
| summarize Services = dcount(ServiceName), List = make_set(ServiceName, 20)
by Account = TargetUserName, IpAddress, bin(TimeGenerated, 10m)
| where Services >= 5
Documenting a detection
A rule without documentation is an alert nobody knows how to handle. Each detection must come with a card:
| Field | Content |
|---|---|
| Objective | The targeted behaviour and why it matters |
| ATT&CK | Tactic and technique(s) |
| Data sources | Required logs and their configuration |
| Logic | Readable description of the rule |
| Known false positives | Legitimate situations that trigger the rule |
| Triage | Questions to ask, data to collect |
| Response | Recommended actions depending on the verdict |
| Test | How to reproduce the technique to validate the rule |
| Owner and version | Who maintains it, change history |
Detection-as-code
Detection-as-code applies software development practices to detection rules: Git repository, code review, automated tests and continuous deployment.
Versioned repository
All rules (Sigma, KQL, SPL) and their cards live in a Git repository. Each change is traced and peer-reviewed.
Automatic validation
On every change, a CI pipeline checks syntax, converts Sigma rules and verifies mandatory metadata (ATT&CK, owner, false positives).
Regression tests
Reference log datasets, or running Atomic Red Team in a lab, prove that the rule fires on the attack and not on usual noise.
Continuous deployment
Validated rules are pushed automatically to the SIEM via its API. Rollback is instant.
Measurement
Alert volume, true positive rate and handling time per rule drive tuning or retirement decisions.
name: detections-ci
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check Sigma rules
run: sigma check rules/
- name: Convert for Microsoft Sentinel
run: sigma convert -t kusto -p microsoft_xdr rules/ -o build/
- name: Check mandatory metadata
run: python tools/lint_metadata.py rules/
Measuring coverage
The MITRE ATT&CK matrix serves as the map. For each priority technique, the coverage level is assessed: no visibility, logged, detected, detected and tested. Tools such as ATT&CK Navigator or DeTT&CT visualise this coverage and track its progress.
The most cost-effective log sources
- Entra ID and Active Directory authentications
- EDR telemetry (process, network, registry)
- Microsoft 365 and email logs
- Sysmon on critical servers
- PowerShell Script Block Logging
- DNS and web proxy
- Firewall and VPN
- Admin and cloud consoles (AWS, Azure, GCP)
Frequently asked questions
Should you use the rules provided by the SIEM or EDR vendor?
Yes, as a foundation: they cover many common threats. But they do not know your environment. The most effective detections are often the ones you write for your critical assets, privileged accounts and business processes.
How do you reduce false positives without losing detection?
With precise, justified exclusions (never generic ones), contextual enrichment (asset criticality, user role), correlation of several weak signals and, for very noisy rules, turning them into threat hunting queries rather than alerts.
What is a honeytoken?
A decoy: an account, a file, an API key or a DNS record with no legitimate use. Any use is therefore suspicious by nature. They are very reliable and inexpensive detections.
