Wazuh Guide Demonstrates Detecting Kubernetes Attacks with Audit Logs

Summary
A Wazuh guide configures Kubernetes audit logging and custom rules, then uses Stratus Red Team to emulate credential theft, RBAC abuse, privilege escalation and container-breakout techniques and validate alerts.
Key points
- The guide configures Kubernetes API audit logging on a local Minikube cluster, with an audit policy tailored to the emulated techniques.
- A Wazuh agent deployed as a DaemonSet monitors Kubernetes audit logs on cluster nodes and forwards them to the Wazuh server.
- Custom rules target secret enumeration and service-account token access, RBAC changes, privileged pods, hostPath mounts, node/proxy access, certificate requests and long-lived tokens.
- Stratus Red Team emulates these actions from an Ubuntu endpoint; the guide describes checking the resulting alerts in the Wazuh dashboard.
- An SSH tunnel connects the emulation endpoint to the local Kubernetes API server.
- The article advises refining the example audit policy for production threat models, logging needs and performance.
Article Details
- Defense Focus
- Detect and validate suspicious cluster API activity using audit logs and correlation rules.
- Detection Methods
- Monitor API audit events for cluster-wide secret enumeration and pod execution requests targeting mounted service-account tokens.
- Detect creation of ClusterRoles, ServiceAccounts, and ClusterRoleBindings, including their creation in close succession.
- Alert on pod creation involving host-root mounts and host-file access, privileged pod creation, and successful node/proxy access by a service account.
- Track certificate signing request creation, approval, status updates, retrieval, and deletion.
- Identify creation of long-lived service-account tokens outside expected system activity.
- Validate detections by generating controlled attack-emulation events and checking the resulting alerts.
- Data Sources
- Cluster API server audit logs in JSON format.
- Audit fields including request URI, verb, object reference, response status, request object, username, and user groups.
- Request and response bodies for certificate signing requests; request bodies for service-account token creation.
- Pod-change events and other API events recorded at metadata level.
- Rule Types
- XML detection rules with PCRE2 regular expressions and field matching.
- Time-window correlation rules using event frequency and matched rule IDs.
- JSON-formatted API audit log ingestion.
- Platforms
- Cluster control-plane audit subsystem.
- Centralized event manager, indexer, and dashboard with agents deployed on cluster nodes.
- Defensive Actions
- Enable API auditing with a policy that captures the events needed for detection; refine it for the organization’s threat model, logging needs, and performance constraints.
- Keep token-review events at metadata level to avoid recording tokens in logs.
- Deploy a log-collection agent on every node and forward audit logs to a central server.
- Add and reload the custom detection rules, then review generated alerts in the dashboard.
- Verify that the agent is running across all cluster nodes.
MITRE ATT&CK
T1068 · Exploitation for Privilege EscalationA rule flags successful nodes/proxy access by a service account as possible Kubernetes privilege escalation.T1098 · Account ManipulationRules detect creation of Kubernetes ClusterRoles, ServiceAccounts, ClusterRoleBindings, and long-lived service-account tokens as persistence-related activity.T1552 · Unsecured CredentialsRules detect cluster-wide enumeration of Kubernetes secrets and pod execution requests targeting mounted service-account tokens.T1611 · Escape to HostRules detect pods mounting the host root filesystem and accessing host files, as well as creation of privileged pods.T1649 · Steal or Forge Authentication CertificatesRules track certificate signing request creation, approval, status updates, retrieval, and deletion for client-certificate authentication.
Vendors
Products
KubernetesWazuh collects Kubernetes audit logs (configured via an audit policy) and forwards them to a central Wazuh server for detection and analysis.MinikubeThe blog demonstrates deploying a local Minikube cluster on AlmaLinux, configuring audit logging, and exporting a flattened kubeconfig for remote emulation.WazuhWazuh collects Kubernetes audit logs (configured via an audit policy) and forwards them to a central Wazuh server for detection and analysis.
