In Part 1 of this series, we covered how to configure the Linux audit framework — auditd rules, syscall monitoring, and kernel-level telemetry that captures what’s actually happening on your systems. In Part 2, we built the collection pipeline — centralizing those logs, normalizing them, and getting them into a place where they can be analyzed at scale.
Now comes the part that actually matters: turning all of that telemetry into detections that catch attackers.
Most organizations collect logs and never look at them. They have terabytes of audit trails sitting in Elasticsearch, rotated weekly, queried only during post-incident forensics when it’s already too late. The gap between “we have logs” and “we detect threats” is where detection engineering lives — and it’s the most underinvested discipline in most security teams.
Understanding What Your Logs Are Telling You
Before writing a single detection rule, you need to understand the patterns in your data. Raw auditd logs are dense, but they follow predictable structures when attacks occur.
A legitimate administrator session looks like this:
# Normal: user authenticates via SSH, runs expected commands
type=USER_LOGIN msg=audit(1713600000.000:1234): pid=5678 uid=0 auid=1000 ses=42
subj=unconfined acct="admin" addr=10.0.1.50 terminal=ssh res=success
type=SYSCALL msg=audit(1713600001.000:1235): arch=c000003e syscall=59
success=yes exit=0 a0=... comm="systemctl" exe="/usr/bin/systemctl"
key="service_management"
A privilege escalation attack looks fundamentally different:
# Suspicious: unexpected SUID binary execution, followed by uid change
type=SYSCALL msg=audit(1713600500.000:4567): arch=c000003e syscall=59
success=yes exit=0 a0=... comm="find" exe="/usr/bin/find"
key="suid_execution" euid=0 uid=1001
type=SYSCALL msg=audit(1713600501.000:4568): arch=c000003e syscall=59
success=yes exit=0 a0=... comm="bash" exe="/bin/bash" euid=0 uid=1001
The key difference: context and sequence. A single event is rarely conclusive. It’s the correlation of multiple events — a user authenticating from an unusual IP, executing a known-vulnerable SUID binary, then spawning a root shell — that constitutes a detection.
| Log Pattern | What It Suggests | Confidence |
|---|---|---|
execve of SUID binary + uid != euid | Potential privilege escalation | Medium |
openat on /etc/shadow by non-root process | Credential harvesting | High |
connect syscall to external IP from cron | C2 callback or data exfil | High |
unlinkat on files in /var/log/ | Log tampering | Critical |
init_module or finit_module syscall | Kernel module loading (rootkit) | Critical |
Detection Engineering as a Discipline
Detection engineering is not “writing SIEM rules.” It’s a systematic, engineering-driven practice that treats detections as code — versioned, tested, measured, and continuously improved.
According to the 2025 State of Detection Engineering Report, 80% of organizations now invest seriously in detection engineering, with that number climbing to 85% in large enterprises. The shift is clear: reactive alert-writing is being replaced by proactive, CI/CD-driven detection pipelines.
The core principles:
- Detection-as-Code — Rules live in Git, go through pull requests, and are deployed via CI/CD pipelines. No more clicking around in a SIEM GUI.
- Coverage-Driven — Measure what percentage of MITRE ATT&CK techniques you can detect. Identify gaps systematically, not by waiting for an incident to expose them.
- Test with Real Attack Data — Every rule must be validated against known-good attack samples. If you haven’t tested it, it doesn’t work.
- Tune Continuously — A rule that fires 500 times a day is worse than no rule at all. False positive rates are a first-class metric.
Sigma Rules: Portable Detection Logic
Sigma is to detection what YARA is to malware — a vendor-agnostic format for expressing detection logic. Write a rule once, compile it to any SIEM backend.
Sigma Rule Structure
| |
Compiling Sigma to Wazuh
The Sigma CLI can convert rules to multiple backends:
| |
Sigma to Other Backends
| Backend | Command | Use Case |
|---|---|---|
| Wazuh | sigma convert -t wazuh | Open-source SIEM/XDR |
| Splunk | sigma convert -t splunk | Enterprise SIEM |
| Elastic | sigma convert -t elasticsearch | ELK-based detection |
| QRadar | sigma convert -t qradar | IBM security stack |
| osquery | sigma convert -t osquery | Endpoint visibility |
The power of Sigma is that your detection investment is portable. When you switch SIEMs (and you will, eventually), your detection logic moves with you.
Wazuh: Open-Source Detection and Response
Wazuh has become the de-facto open-source SIEM/XDR platform for Linux environments. It combines rule-based and anomaly-based detection, file integrity monitoring, vulnerability scanning, and active response — all without vendor lock-in.
Wazuh Architecture for Linux Detection
┌─────────────────┐ ┌─────────────────┐ ┌──────────────────┐
│ Linux Endpoint │ │ Wazuh Manager │ │ Wazuh Indexer │
│ ┌─────────────┐│ │ ┌─────────────┐ │ │ (OpenSearch) │
│ │ Wazuh Agent ││────▶│ │ Analysis │ │────▶│ ┌────────────┐ │
│ │ - auditd ││ │ │ Engine │ │ │ │ Dashboards │ │
│ │ - syslog ││ │ │ - Decoders │ │ │ │ Alerts │ │
│ │ - FIM ││ │ │ - Rules │ │ │ │ Compliance │ │
│ │ - osquery ││ │ │ - Active Resp│ │ │ └────────────┘ │
│ └─────────────┘│ │ └─────────────┘ │ └──────────────────┘
└─────────────────┘ └─────────────────┘
Built-In Linux Rules
Wazuh ships with over 4,000 rules out of the box. The ones relevant to Linux kernel security:
| |
Writing Custom Wazuh Rules
The built-in rules are a baseline. Real detection requires custom rules tailored to your environment. Here’s how to build them for common Linux attack patterns.
Custom decoder for auditd SYSCALL events:
| |
Custom rule for kernel module loading (rootkit detection):
| |
MITRE ATT&CK Mapping: Making Detections Meaningful
Every detection rule should map to at least one MITRE ATT&CK technique. Without this mapping, you have alerts with no context — and analysts waste time figuring out what the alert means instead of responding to it.
Here’s the mapping for common Linux attack vectors:
| Attack Category | Technique | ID | Detection Source |
|---|---|---|---|
| Privilege Escalation | Abuse SUID/SGID | T1548.001 | auditd execve with euid=0, uid!=0 |
| Privilege Escalation | Sudo exploitation | T1548.003 | auditd sudo commands, /var/log/auth.log |
| Persistence | Cron job creation | T1053.003 | FIM on /etc/crontab, /var/spool/cron/ |
| Persistence | SSH authorized_keys | T1098.004 | FIM on ~/.ssh/authorized_keys |
| Persistence | Systemd service | T1543.002 | FIM on /etc/systemd/system/ |
| Lateral Movement | SSH brute force | T1110.001 | PAM auth failures, frequency rules |
| Lateral Movement | SSH hijacking | T1563.001 | auditd ptrace syscall monitoring |
| Defense Evasion | Log deletion | T1070.002 | FIM on /var/log/, auditd unlinkat |
| Defense Evasion | Timestomping | T1070.006 | auditd utimensat, futimesat syscalls |
| Defense Evasion | Fileless execution | T1620 | auditd /proc/self/mem writes |
| Execution | Kernel module loading | T1547.006 | auditd init_module, finit_module |
Building Detection Rules for Common Linux Attacks
Privilege Escalation: Sudo Abuse and SUID Exploitation
Sudo abuse is the most common privilege escalation path on Linux. Attackers look for misconfigured sudoers entries that allow command execution as root.
| |
For SUID exploitation, monitor the execution of binaries listed on GTFOBins:
| |
Persistence: Cron Jobs, SSH Keys, and Systemd Services
Attackers need persistence to survive reboots and session terminations. The three most common mechanisms on Linux:
Wazuh File Integrity Monitoring configuration:
| |
Custom rule to alert on new authorized_keys entries:
| |
Lateral Movement: SSH Brute Force and Unusual Connections
| |
Defense Evasion: Log Tampering, Timestomping, Fileless Execution
These are the techniques that make incident response difficult. If an attacker can erase their tracks, your audit trail becomes unreliable.
| |
The corresponding auditd rules that generate these events:
| |
The Detection Toolchain
Detection engineering on Linux isn’t a single-tool problem. Each tool in the chain serves a specific purpose:
| Tool | Role | Strength | Limitation |
|---|---|---|---|
| Wazuh | SIEM/XDR, correlation, active response | Full detection pipeline, built-in rules | Complex initial setup |
| Sigma | Portable detection rule format | Vendor-agnostic, large community rule set | Requires backend-specific compilation |
| YARA | File and memory pattern matching | Malware identification, IOC scanning | Static analysis only, no behavioral detection |
| osquery | Endpoint state querying (SQL interface) | Inventory, compliance, snapshot analysis | Not real-time, polling-based |
| Falco | Runtime syscall monitoring | Real-time kernel-level visibility (eBPF) | Container-focused, limited correlation |
| Tetragon | eBPF-based observability + enforcement | Can block attacks, not just detect | Newer, smaller rule ecosystem |
The recommended stack for most Linux environments:
auditd (telemetry) → Wazuh Agent (collection) → Wazuh Manager (detection) → OpenSearch (storage/search)
↑
Sigma rules (portable logic)
YARA rules (malware scanning)
osquery (endpoint queries)
Active Response: Automated Containment
Detection without response is just expensive logging. Wazuh’s active response capability lets you automate containment actions when high-confidence detections fire.
Block an IP after brute force detection:
| |
Disable a compromised user account:
| |
The disable-account script:
| |
The Detection Engineering Lifecycle
Detection engineering is iterative. No rule is ever “done.” Follow this cycle:
┌──────────────┐
│ Hypothesis │ "Attackers escalating via SUID find on our servers"
└──────┬───────┘
▼
┌──────────────┐
│ Write Rule │ Sigma/Wazuh rule targeting SUID find execution
└──────┬───────┘
▼
┌──────────────┐
│ Test Rule │ Run against attack simulation (Atomic Red Team)
└──────┬───────┘
▼
┌──────────────┐
│ Tune Rule │ Exclude legitimate admin usage, reduce false positives
└──────┬───────┘
▼
┌──────────────┐
│ Deploy Rule │ Push via CI/CD to Wazuh Manager
└──────┬───────┘
▼
┌──────────────┐
│ Measure │ Track: true positive rate, MTTD, ATT&CK coverage
└──────┬───────┘
│
└──────────▶ Back to Hypothesis (new intelligence, new gaps)
Testing with Atomic Red Team:
| |
Key metrics for your detection program:
| Metric | What It Measures | Target |
|---|---|---|
| MITRE ATT&CK coverage | % of relevant techniques with detections | > 70% for Linux tactics |
| Mean Time to Detect (MTTD) | Time from attack to alert | < 5 minutes |
| False Positive Rate | % of alerts that are benign | < 10% per rule |
| Rule test coverage | % of rules with validated test cases | 100% |
| Detection latency | Time from log generation to alert | < 60 seconds |
Incident Response Workflow
When a detection fires, the collected telemetry from Parts 1 and 2 becomes your investigation foundation. Here’s a practical workflow:
1. Triage (0-5 minutes)
- Assess alert severity and MITRE ATT&CK context
- Check if the alert correlates with other recent events on the same host
- Determine if active response already contained the threat
2. Scope (5-15 minutes)
| |
3. Contain (15-30 minutes)
- Isolate the host from the network (Wazuh active response or manual)
- Preserve volatile evidence (memory dump, process list, network connections)
- Rotate compromised credentials
4. Investigate (30 minutes - hours)
- Reconstruct the full attack chain using auditd logs
- Identify initial access vector, persistence mechanisms, lateral movement
- Determine data exposure
5. Remediate and Improve
- Remove persistence mechanisms
- Patch the exploited vulnerability
- Update detection rules based on lessons learned
- Add new coverage for any gaps the attack exposed
Conclusion
The trilogy is complete. Auditing gives you visibility. Collection gives you centralized data. Detection and response give you the ability to act on that data before an attacker achieves their objective.
The key takeaways:
- Detection engineering is a discipline, not a task. Treat your rules like production code — version them, test them, measure them, and iterate.
- Sigma gives you portability. Invest in Sigma rules and you’re never locked into a single SIEM vendor.
- Wazuh is a capable, open-source detection platform for Linux environments. Its combination of built-in rules, custom decoders, FIM, and active response covers the full detection-to-response pipeline.
- Map everything to MITRE ATT&CK. It forces you to think about what you’re detecting and — more importantly — what you’re not.
- Automate response carefully. Active response is powerful but dangerous. Start with alerting, validate your rules, then graduate to automated containment for high-confidence detections.
The gap between “we have security tools” and “we detect and respond to threats” is filled by engineering rigor, not more products. Build the pipeline, test it relentlessly, and iterate.
References:
- Sigma Rules — SigmaHQ GitHub
- Wazuh Documentation — Custom Rules and Decoders
- MITRE ATT&CK Linux Matrix
- Atomic Red Team — Red Canary
- Neo23x0 Auditd Best Practice Configuration
- 2025 State of Detection Engineering Report — Anvilogic
- Wazuh: Open Source SIEM/XDR
- Tetragon — eBPF-based Security Observability
- GTFOBins — SUID Binary Abuse Reference
