Detecting Linux Privilege Escalation With Wazuh and auditd

· Original article ↗

Summary

A Wazuh tutorial demonstrates auditd, file integrity monitoring and custom rules to detect Linux privilege escalation techniques, including sudo abuse, ptrace injection, dynamic linker hijacking and cron abuse.

Key points

  • The walkthrough uses a Wazuh server and an Ubuntu endpoint to configure detections and simulate privilege escalation activity.
  • Auditd tracks sudo execution and permission changes associated with SUID and SGID binaries; custom rules flag sensitive binaries and permission changes.
  • File integrity monitoring watches group membership and sudo configuration files, while auditd records user-management commands.
  • A ptrace audit rule captures PTRACE_ATTACH requests; the simulation notes that an attempted attachment may fail on a hardened system.
  • Auditd and file integrity monitoring track changes to dynamic linker configuration, including /etc/ld.so.preload.
  • Cron and logrotate monitoring covers configuration changes and root-privileged execution from writable directories that may indicate PATH hijacking.
  • The tutorial maps custom alerts to MITRE ATT&CK and shows how to review them in the Wazuh dashboard.

Article Details

Defense Focus
Detect common Linux privilege escalation attempts using audit events, file integrity monitoring, and custom rules.
Detection Methods
  • Alert on sudo execution of binaries that can enable a privileged shell.
  • Detect chmod syscalls setting SUID or SGID bits and file permission changes in user-writable directories.
  • Monitor usermod and groupmod execution and changes to privileged group and sudo configuration files.
  • Detect ptrace attach requests, including non-root requests outside known debugging tools.
  • Detect writes and file changes affecting dynamic linker preload configuration.
  • Detect cron and logrotate configuration changes and root execution from writable directories.
Data Sources
  • Linux auditd syscall and file-write events from /var/log/audit/audit.log
  • File integrity events for permissions and sensitive configuration files
Rule Types
  • Linux auditd rules
  • Custom Wazuh XML detection rules with PCRE2 matching
  • File integrity monitoring rules
Platforms
  • Linux
  • Ubuntu 26.04
Defensive Actions
  • Configure auditd to collect relevant execution, permission-change, ptrace, and file-write events, and forward its log through the endpoint agent.
  • Enable real-time integrity monitoring for writable directories and sensitive group, sudo, dynamic linker, and scheduled-task configurations.
  • Deploy and reload the custom detection rules, then review privilege escalation and MITRE-mapped events in the dashboard.
  • Clean up test accounts, configuration changes, and simulated payloads after validation.

MITRE ATT&CK

Vendors

Products

Tools

Related Articles