Repository navigation
Add Linux Auditd Enumeration Script Activity detection - #4380
vahidmalekk wants to merge 4 commits into
Conversation
Behavioral/threshold analytic that detects the rapid fan-out of many distinct discovery utilities characteristic of automated enumeration scripts (LinEnum/LinPEAS/LSE) using Linux Auditd Execve, rather than single discovery commands. Maps to T1082/T1083/T1057/T1518.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42e196e3c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| | eval base_cmd=mvindex(split(base_cmd,"/"),-1) | ||
| | eval is_recon=if(base_cmd IN ("whoami","id","uname","hostname","hostnamectl","lsb_release","sudo","find","getcap","crontab","ps","netstat","ss","lsof","last","lastlog","w","who","arp","ip","ifconfig","route","mount","lsblk","df","dpkg","dpkg-query","rpm","getent","lsmod","modinfo","dmesg","env","uptime","aa-status","sestatus","capsh"),1,0) | ||
| | bin _time span=2m | ||
| | stats count as exec_count dc(base_cmd) as distinct_commands sum(is_recon) as recon_executions dc(eval(if(is_recon=1,base_cmd,null()))) as distinct_recon_commands values(base_cmd) as commands min(_time) as firstTime max(_time) as lastTime BY _time dest |
There was a problem hiding this comment.
Preserve allowlist fields before applying the filter
When this fires on a CI or configuration-management host and an operator follows the documented service-account/parent-process allowlisting guidance, the filter cannot implement that tuning: this stats emits only _time, dest, aggregate counts, and commands, so user/uid, parent identity, and even the renamed process fields have been discarded before linux_auditd_enumeration_script_activity_filter runs. Preserve and collect those dimensions or apply the allowlist before aggregation; otherwise the only reliable mitigation offered here is suppressing the entire host.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed. The window now carries the allowlist dimensions: values(auid) as auid, values(uid) as uid, values(process) as process, and values(ppid) as parent_pids (plus dc(ppid) as distinct_parents). So the filter macro can allowlist a specific service account or parent process - e.g. a CI/config-management account - instead of being forced to suppress the whole host. Updated how_to_implement, known_false_positives, and the entity message to reference these. Pushed in 2b2abc4.
| `linux_auditd` execve_command=* | ||
| | rename host as dest | ||
| | rename comm as process_name | ||
| | rename exe as process | ||
| | eval base_cmd=lower(mvindex(split(trim(execve_command)," "),0)) | ||
| | eval base_cmd=mvindex(split(base_cmd,"/"),-1) | ||
| | eval is_recon=if(base_cmd IN ("whoami","id","uname","hostname","hostnamectl","lsb_release","sudo","find","getcap","crontab","ps","netstat","ss","lsof","last","lastlog","w","who","arp","ip","ifconfig","route","mount","lsblk","df","dpkg","dpkg-query","rpm","getent","lsmod","modinfo","dmesg","env","uptime","aa-status","sestatus","capsh"),1,0) | ||
| | bin _time span=2m | ||
| | stats count as exec_count dc(base_cmd) as distinct_commands sum(is_recon) as recon_executions dc(eval(if(is_recon=1,base_cmd,null()))) as distinct_recon_commands values(base_cmd) as commands values(auid) as auid values(uid) as uid values(process) as process dc(ppid) as distinct_parents values(ppid) as parent_pids min(_time) as firstTime max(_time) as lastTime BY _time dest | ||
| | where exec_count>=50 AND distinct_commands>=15 AND distinct_recon_commands>=8 |
There was a problem hiding this comment.
Limiting initial search to enumeration commands help increasing search performance. execve events are parsing binary name in a0 argument, therefore removing additional evals that are parsing it.
Captured event time separately before time bins are generated, this provides precise timestamps for min, max commands later in the SPL.
Since we are not capturing any out-of-scope binaries, simplified distinct calculation filter and rounded it up to 10 binaries.
| `linux_auditd` execve_command=* | |
| | rename host as dest | |
| | rename comm as process_name | |
| | rename exe as process | |
| | eval base_cmd=lower(mvindex(split(trim(execve_command)," "),0)) | |
| | eval base_cmd=mvindex(split(base_cmd,"/"),-1) | |
| | eval is_recon=if(base_cmd IN ("whoami","id","uname","hostname","hostnamectl","lsb_release","sudo","find","getcap","crontab","ps","netstat","ss","lsof","last","lastlog","w","who","arp","ip","ifconfig","route","mount","lsblk","df","dpkg","dpkg-query","rpm","getent","lsmod","modinfo","dmesg","env","uptime","aa-status","sestatus","capsh"),1,0) | |
| | bin _time span=2m | |
| | stats count as exec_count dc(base_cmd) as distinct_commands sum(is_recon) as recon_executions dc(eval(if(is_recon=1,base_cmd,null()))) as distinct_recon_commands values(base_cmd) as commands values(auid) as auid values(uid) as uid values(process) as process dc(ppid) as distinct_parents values(ppid) as parent_pids min(_time) as firstTime max(_time) as lastTime BY _time dest | |
| | where exec_count>=50 AND distinct_commands>=15 AND distinct_recon_commands>=8 | |
| `linux_auditd` type=EXECVE | |
| a0 IN ( | |
| "whoami", | |
| "id", | |
| "groups", | |
| "uname", | |
| "hostname", | |
| "hostnamectl", | |
| "lsb_release", | |
| "uptime", | |
| "w", | |
| "who", | |
| "last", | |
| "lastlog", | |
| "env", | |
| "printenv", | |
| "sudo", | |
| "crontab", | |
| "find", | |
| "getcap", | |
| "getfacl", | |
| "lsattr", | |
| "ps", | |
| "netstat", | |
| "ss", | |
| "lsof", | |
| "ifconfig", | |
| "ip", | |
| "arp", | |
| "route", | |
| "iptables", | |
| "mount", | |
| "lsblk", | |
| "df", | |
| "lsmod", | |
| "modinfo", | |
| "dmesg", | |
| "dpkg", | |
| "dpkg-query", | |
| "rpm", | |
| "getent", | |
| "aa-status", | |
| "sestatus", | |
| "capsh", | |
| "showmount", | |
| "systemctl", | |
| "atq" | |
| ) | |
| | eval evt_time=_time | |
| | bin _time span=2m | |
| | rename host as dest | |
| | stats count as exec_count dc(a0) as distinct_recon_commands values(a0) as recon_commands min(evt_time) as firstTime max(evt_time) as lastTime BY _time dest | |
| | where distinct_recon_commands>=10 |
Summary
Adds a new anomaly analytic, Linux Auditd Enumeration Script Activity, that detects the behavior of automated Linux enumeration / privilege-escalation scripts (LinEnum, LinPEAS, linux-smart-enumeration, linuxprivchecker) rather than individual discovery commands.
Existing
Linux Auditd ...discovery analytics each key on a single technique/command. Those are valuable, but one command at a timewhoami,id,uname,find,crontab -l,ss -tlpnis everyday admin activity and generates noise. This analytic instead keys on the rapid fan-out of many distinct discovery utilities together in a short window on one host, which is the signature of an enumeration script and simultaneously covers T1082/T1083/T1057/T1518. It fires only when a 2-minute window per host crosses all three thresholds: high execution volume, high distinct-binary count, and a high number of distinct recon/discovery tools.Data source
Linux Auditd Execveusesexecve_commandandargc, consistent with the current auditd detections (e.g.linux_auditd_file_and_directory_discovery).Testing
type: Anomaly, tuned vialinux_auditd_enumeration_script_activity_filterfor config-management/monitoring/CI false positives (documented in known_false_positives).MITRE ATT&CK
T1082, T1083, T1057, T1518
Notes: thresholds are documented as starting points in how_to_implement; happy to adjust threshold values, the recon-utility list, or the grouping to match STRT conventions.