Detection: Linux Auditd Possible Setuid Execve Privesc

Description

The following detects privilege escalation via execve (syscall 59) where a process transitions from a non-root uid to euid=0 without a corresponding successful PAM authentication event (USER_AUTH, USER_ACCT, or CRED_ACQ) in the same audit session. Legitimate privilege elevation mechanisms such as sudo, su, and pkexec authenticate through PAM and generate these audit records tied to the session ID before granting elevated privileges. The absence of a matching successful PAM event alongside an effective UID change to root is anomalous and may indicate exploitation of a setuid binary, a kernel vulnerability, or another mechanism used to escalate privileges outside the normal authentication flow.

 1`linux_auditd` ( (type=SYSCALL syscall="59" uid!="0" euid="0") OR (type IN ("USER_AUTH","USER_ACCT","CRED_ACQ") res="success") ) 
 2| eval is_suspicious_exec=if(type="SYSCALL" AND syscall="59" AND uid!="0" AND euid="0", 1, 0) 
 3| eval is_successful_auth=if(type IN ("USER_AUTH","USER_ACCT","CRED_ACQ") AND res="success", 1, 0) 
 4| stats
 5    count(eval(is_suspicious_exec=1)) as exec_count
 6    max(eval(if(is_suspicious_exec=1, _time, null()))) as lastTime
 7    max(is_successful_auth) as has_successful_auth
 8    min(eval(if(is_suspicious_exec=1, _time, null()))) as firstTime
 9    values(eval(if(is_suspicious_exec=1, comm, null()))) as process_name
10    values(eval(if(is_suspicious_exec=1, euid, null()))) as euid
11    values(eval(if(is_suspicious_exec=1, exe, null()))) as process_path
12    values(eval(if(is_suspicious_exec=1, pid, null()))) as pid
13    values(eval(if(is_suspicious_exec=1, ppid, null()))) as ppid
14    values(eval(if(is_suspicious_exec=1, uid, null()))) as uid
15    by host ses
16
17| where exec_count > 0 AND has_successful_auth != 1 
18| rename host as dest, ses as session_id 
19| `security_content_ctime(firstTime)` 
20| `security_content_ctime(lastTime)` 
21| `linux_auditd_possible_setuid_execve_privesc_filter`

Data Source

Name Platform Sourcetype Source
Linux Auditd Execve Linux icon Linux 'auditd' 'auditd'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
linux_auditd_possible_setuid_execve_privesc_filter search *
linux_auditd_possible_setuid_execve_privesc_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1068 Exploitation for Privilege Escalation Privilege Escalation
Exploitation
DE.AE
CIS 10

CVE

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) No
Creates Intermediate Finding (Risk Event) Yes
Anomaly detections generate Intermediate Findings (Risk Events). They do not generate a Finding (Notable) directly.

Implementation

To implement this detection, the process begins by ingesting auditd data, that consist SYSCALL, TYPE, EXECVE and PROCTITLE events, which captures command-line executions and process details on Unix/Linux systems. These logs should be ingested and processed using Splunk Add-on for Unix and Linux (https://splunkbase.splunk.com/app/833), which is essential for correctly parsing and categorizing the data. The next step involves normalizing the field names to match the field names set by the Splunk Common Information Model (CIM) to ensure consistency across different data sources and enhance the efficiency of data modeling. This approach enables effective monitoring and detection of linux endpoints where auditd is deployed.

Known False Positives

Processes with an unset audit session, such as cron jobs, that legitimately drop and reacquire root privileges outside of PAM, may trigger this detection and require filtering.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
$process_name$ was launched with euid 0 on [$dest$] without PAM auth. dest system 20

Threat Objects

Field Type
process_name process_name

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Passing N/A N/A N/A
Unit Passing Dataset auditd auditd
Integration ✅ Passing Dataset auditd auditd

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub |

Version: 1