| ID | Technique | Tactic |
|---|---|---|
| T1059.004 | Unix Shell | Execution |
| T1078.003 | Local Accounts | Initial Access |
Detection: Linux Auditd Shell Execution by Non-User Account
Description
The following analytic detects successful auditd execve events that launch an interactive Linux shell, identified by a TTY, under accounts that commonly do not log in. These are identified by a list of well-known service account names or by a system UID (between 1 and 999). An interactive shell for these accounts may indicate password-bypass abuse or unauthorized access.
Search
1`linux_auditd` type=SYSCALL
2comm IN (
3 "ash",
4 "bash",
5 "csh",
6 "dash",
7 "fish",
8 "ksh",
9 "mksh",
10 "rbash",
11 "sh",
12 "tcsh",
13 "yash",
14 "zsh"
15)
16success=yes
17
18
19| where isnotnull(tty) AND tty!="(none)"
20
21
22| rex field=_raw "\\bUID=[[:punct:]]?(?<audit_user>[[:alnum:]_.-]+)"
23
24
25| eval audit_user=lower(coalesce(audit_user, user))
26
27| eval uid_num=tonumber(uid)
28
29
30| where (uid_num>0 AND uid_num<1000) OR in(audit_user, "daemon", "bin", "sys", "sync", "shutdown", "halt", "games", "man", "lp", "mail", "news", "uucp", "operator", "www-data", "backup", "list", "irc", "gnats", "nobody", "_apt", "systemd-network", "systemd-resolve", "messagebus", "uuidd", "sshd", "ntp", "ftp", "chrony", "postfix", "redis", "mysql", "mariadb", "postgres", "alpine", "guest")
31
32
33| rename host as dest
34
35
36| stats count min(_time) as firstTime
37 max(_time) as lastTime
38 values(audit_user) as user
39 values(uid) as uid
40 values(euid) as euid
41 values(comm) as shell
42 values(exe) as executable
43 values(tty) as tty
44 by dest
45
46
47| `security_content_ctime(firstTime)`
48
49| `security_content_ctime(lastTime)`
50
51| `linux_auditd_shell_execution_by_non_user_account_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Linux Auditd Syscall | 'auditd' |
'auditd' |
Macros Used
| Name | Value |
|---|---|
| security_content_ctime | convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$) |
| linux_auditd_shell_execution_by_non_user_account_filter | search * |
linux_auditd_shell_execution_by_non_user_account_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
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 |
Implementation
To implement this detection, you should ingest auditd data, that consists of 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
System administrators and automation may run shells under service accounts or accounts that are not locked on a particular image. The search also matches any account with a UID between 1 and 999 (the system account range on most modern distributions), so administrators who use su or sudo to open an interactive shell as a service account such as jenkins or gitlab-runner will trigger it. On legacy systems (for example RHEL/CentOS 6) regular users may start at UID 500, so adjust the threshold if needed. Review the account's shadow state and the process context before escalating.
Associated Analytic Story
Intermediate Findings
| Message | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| Shell [$shell$] executed as non-user account [$user$] on [$dest$]. | dest | system | 20 |
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