Detection & logging
Detection doesn’t stop an attack: it makes it visible. Its job is to shorten the time an adversary spends inside without anyone noticing, turning scattered traces (processes, connections, authentications) into alerts an analyst can investigate. That conversion has two halves that fail independently: logging the right event, and writing and testing the logic that recognizes it. This page covers both from a detection engineering angle: detections are designed, tested and maintained as code.
What it solves
Section titled “What it solves”- Shorter dwell time: in Mandiant’s 2025 investigations the global median was 14 days (11 in 2024), and 122 days for espionage and North Korean IT worker operations (M-Trends 2026).
- Internal detection: 52% of those intrusions were discovered by the organization itself; the rest came from an external notification or from the attacker announcing it (common in ransomware).
- Knowing what you can’t see: an explicit detection strategy states which techniques are covered, by which source and which rule, instead of assuming “the SIEM will catch it”.
Lifecycle of a detection
Section titled “Lifecycle of a detection”flowchart LR
R["Requirement<br/>TTP from intel,<br/>incident or gap"] --> V{"Is the telemetry<br/>logged?"}
V -->|No| L["Enable logging<br/>or Sysmon"]
L --> V
V -->|Yes| E["Write the logic<br/>Sigma"]
E --> T["Test<br/>positives and negatives"]
T --> D["Deploy<br/>to the SIEM"]
D --> A["Tune<br/>false positives"]
A --> M["Measure and review<br/>or retire"]
M --> R
The step most often skipped is the second one: writing a rule for an event nobody collects produces a rule that never fires and a false sense of coverage.
No telemetry, no rule
Section titled “No telemetry, no rule”On Windows, much of what’s useful is disabled or incomplete by default. The minimum for behavioral detection:
| Source | Events | Answers | How to enable |
|---|---|---|---|
| Process creation | Security 4688 | What ran and with which command line | Process Creation auditing + command line policy |
| PowerShell | PowerShell/Operational 4104 | The script actually executed, already deobfuscated | Script Block Logging via GPO |
| Logons | 4624, 4625, 4672 | Who logged on, how (logon type) and with which privileges | Logon auditing (success and failure) |
| Kerberos | 4768, 4769, 4771 | Spraying, Kerberoasting, failed pre-authentication | Kerberos auditing on domain controllers |
| Services | System 7045 | Persistence and lateral movement (PsExec and similar) | On by default |
| Log clearing | Security 1102, System 104 | Anti-forensics | On by default |
| Enriched endpoint | Sysmon 1, 3, 7, 10, 11, 13, 22 | Hash, parent process, per-process network, LSASS access | Sysmon with a good configuration |
Enabling it on a lab machine (in production, use GPO):
# Audit process creation (by GUID: the subcategory name depends on the Windows language)auditpol /set /subcategory:"{0CCE922B-69AE-11D9-BED3-505054503030}" /success:enable
# Include the command line in 4688reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Audit" /v ProcessCreationIncludeCmdLine_Enabled /t REG_DWORD /d 1 /f
# PowerShell Script Block Logging (4104)reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1 /fOn Linux the equivalent is auditd (execve calls, changes to sensitive files) plus authentication logs; the artifacts are covered in Linux artifacts.
From TTP to logic
Section titled “From TTP to logic”A useful detection describes behavior, not an artifact the attacker changes in seconds (see the pyramid of pain in IOCs and TTPs). Example: dumping LSASS memory (T1003.001). The hash of mimikatz.exe expires with every recompile; what doesn’t change is that some process has to open lsass.exe with memory read access. Sysmon logs it as event 10:
EventID 10 2019-03-17 19:37:11 PC04.example.corp SourceImage: C:\Users\IEUser\Desktop\mimikatz_trunk\Win32\mimikatz.exe TargetImage: C:\Windows\system32\lsass.exe GrantedAccess: 0x00001010 CallTrace: C:\Windows\SYSTEM32\ntdll.dll+4595c|...|mimikatz.exe+5c5a9|...0x1010 is PROCESS_VM_READ | PROCESS_QUERY_LIMITED_INFORMATION: exactly what’s needed to read the process memory. The rule is built on that.
Detection as code
Section titled “Detection as code”The rule in Sigma format, with metadata, ATT&CK tag and known false positives:
title: LSASS access from an executable in a user-writable pathid: 6f0d3c1e-6a43-4c2e-9a51-1b7e2f4d8a10status: experimentaltags: - attack.credential-access - attack.t1003.001logsource: product: windows category: process_accessdetection: selection: TargetImage|endswith: '\lsass.exe' GrantedAccess|endswith: # 0x1010 and 0x00001010 depending on Sysmon version - '1010' - '1410' - '1438' - '143a' - '1fffff' user_path: SourceImage|contains: - '\Users\' - '\ProgramData\' - '\Temp\' condition: selection and user_pathfalsepositives: - Support or security tools installed per userlevel: highTest. It was evaluated against the public EVTX-ATTACK-SAMPLES set (278 .evtx files, 37,364 events, real attacks recorded in a lab) by converting the rule to SQL with pySigma and running it over the events:
| Result | Detail |
|---|---|
| Positives | 10 events in 5 files: mimikatz, procdump, Outflank-Dumpert, AndrewSpecial and PPLdump |
| Did not fire | services.exe opening LSASS with 0x1410 (system path, legitimate) |
| Did not fire | rundll32.exe + comsvcs.dll (system path): needs another rule based on the command line |
The first version of the rule used GrantedAccess|contains: '0x1010' and never fired: in those samples Sysmon writes the value zero-padded (0x00001010). That’s the most instructive mistake of the lab: a rule not tested against real data can be broken from day one.
The same rule is translated to each SIEM’s language with sigma convert (see SIEM):
sigma convert -t splunk -p splunk_windows -p sysmon lsass_userpath.ymlsource="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=10 TargetImage="*\\lsass.exe" GrantedAccess IN ("*1010", "*1410", "*1438", "*143a", "*1fffff") SourceImage IN ("*\\Users\\*", "*\\ProgramData\\*", "*\\Temp\\*")Measuring coverage with ATT&CK
Section titled “Measuring coverage with ATT&CK”Since v18 (October 2025), ATT&CK replaced “data sources” with detection strategies and analytics. v20.1 has 706 strategies, 1,773 analytics and 106 data components. Each analytic states the specific events it needs. For T1003.001:
| Object | Content |
|---|---|
| Strategy DET0363 | Detection of Credential Dumping from LSASS Memory via Access and Dump Sequence |
| Analytic AN1030 (Windows) | Abnormal process opens LSASS with broad access and then dumps memory, creates a file or touches the registry |
| Sources required | Sysmon 10 (Process Access), Sysmon 1, Sysmon 11, Security 4673, Sysmon 13/14 |
Crossing those sources with what actually reaches the SIEM gives the visibility map; crossing techniques with deployed rules gives the detection map. They’re different maps, and the second can never be better than the first. Prioritization comes from the techniques used by the adversaries relevant to the organization (ATT&CK).
The lab illustrates the difference. SigmaHQ’s 2,308 Windows rules (November 2026 snapshot) evaluated over the same 278 recordings:
- 314 rules fired; 192 of the 278 files produced at least one alert.
- 102 rules use fields that appear in no event of the set: without that telemetry, they can’t fire.
- The Security log cleared rule (1102) didn’t fire until the parser extracted the
Provider_Namefield and theUserDatacontents: the event was there, but badly normalized.
Metrics
Section titled “Metrics”| Metric | Measures | Beware |
|---|---|---|
| MTTD | Mean time from activity to alert | Only counts what was detected |
| MTTR | Time from alert to containment | Depends on the SOC process, not just the rule |
| ATT&CK coverage | Prioritized techniques with a tested rule | An untested rule doesn’t count |
| Precision | True alerts / total alerts per rule | A rule that never fires has undefined precision, not perfect precision |
| Source health | Sources that stop sending data | Silence looks like “all quiet” |
Common mistakes
Section titled “Common mistakes”- Rules without telemetry: deploying 4688 rules without auditing the command line.
- Untested rules: different field formats (
0x1010vs0x00001010), uppercase paths or incomplete normalization break them silently. - Chasing IOCs: hashes and IPs expire; they serve a specific campaign, not a strategy.
- Alert fatigue: hundreds of low-quality alerts bury the good one; every rule needs an owner and a tuning threshold.
- Logs only on the host: a privileged attacker clears the local 1102; immediate forwarding off the machine preserves it.
Real cases
Section titled “Real cases”- Storm-0558 (2023): a US federal agency detected access to its Exchange Online mail thanks to
MailItemsAccessedevents with an unexpectedAppID. That record was only in premium auditing (G5/E5 license); CISA and the FBI stated they knew of no other log that would have detected it (AA23-193A). - Living off the land: the joint guidance from ASD, CISA, FBI, NSA and other partners (August 2024) starts from the premise that legitimate binaries and fileless malware are only detected with a centralized, tamper-resistant logging program and an explicit detection strategy.
Checklist
Section titled “Checklist”- Source inventory by domain (endpoint, identity, network, cloud, application)
- 4688 with command line, 4104 and Sysmon enabled and reaching the SIEM
- Rules in Sigma, versioned, with ATT&CK tag and documented false positives
- Every rule with a positive and a negative test event
- Visibility map (sources) kept separate from detection map (rules)
- Metrics: MTTD, MTTR, per-rule precision and source health
- Immediate forwarding of logs off the host
References
Section titled “References”- MITRE ATT&CK — Detection Strategies
- MITRE ATT&CK — Updates October 2025 (v18)
- SigmaHQ — rules and specification
- EVTX-ATTACK-SAMPLES — sbousseaden
- Microsoft Learn — Audit Process Creation
- ASD/CISA — Best Practices for Event Logging and Threat Detection
- CISA AA23-193A — Enhanced Monitoring to Detect APT Activity Targeting Outlook Online
- Mandiant — M-Trends 2026
- NIST SP 800-92 — Guide to Computer Security Log Management