| ID | Technique | Tactic |
|---|---|---|
| T1053.003 | Cron | Execution |
Detection: Linux Auditd Possible Append Cronjob Entry On Existing Cronjob File
Description
The following analytic detects potential tampering with cronjob files on a Linux system. It leverages logs from Linux Auditd, focusing on events of type PATH or CWD. This activity could be significant because adversaries often use it for persistence or privilege escalation. Correlate this with related EXECVE or PROCTITLE events to identify the process or user responsible for the access or modification. If confirmed malicious, this could allow attackers to execute unauthorized code automatically, leading to system compromises and unauthorized data access, thereby impacting business operations and data integrity.
Search
1`linux_auditd` (type=PATH OR type=CWD)
2
3| rex "msg=audit\([^)]*:(?<audit_id>\d+)\)"
4
5
6| stats
7 values(type) as types
8 values(name) as names
9 values(nametype) as nametype
10 values(cwd) as cwd_list
11 values(_time) as event_times
12 by audit_id, host
13
14
15| eval current_working_directory = coalesce(mvindex(cwd_list, 0), "N/A")
16
17| eval candidate_paths = mvmap(names, if(match(names, "^/"), names, current_working_directory + "/" + names))
18
19| eval matched_paths = mvfilter(match(candidate_paths, "/etc/cron.*
20|.*/cron/.*
21|/etc/anacrontab.*"))
22
23| eval match_count = mvcount(matched_paths)
24
25| eval reconstructed_path = mvindex(matched_paths, 0)
26
27| eval e_time = mvindex(event_times, 0)
28
29| where match_count > 0
30
31| rename host as dest
32
33
34| stats count min(e_time) as firstTime max(e_time) as lastTime
35 values(nametype) as nametype
36 by current_working_directory
37 reconstructed_path
38 match_count
39 dest
40 audit_id
41
42
43| `security_content_ctime(firstTime)`
44
45| `security_content_ctime(lastTime)`
46
47| `linux_auditd_possible_append_cronjob_entry_on_existing_cronjob_file_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Linux Auditd Cwd | 'auditd' |
'auditd' |
|
| Linux Auditd Path | 'auditd' |
'auditd' |
Macros Used
| Name | Value |
|---|---|
| linux_auditd | sourcetype="auditd" |
| linux_auditd_possible_append_cronjob_entry_on_existing_cronjob_file_filter | search * |
linux_auditd_possible_append_cronjob_entry_on_existing_cronjob_file_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
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 Risk Event | False |
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 and make sure the type=CWD record type is activate in your auditd configuration. This approach enables effective monitoring and detection of linux endpoints where auditd is deployed.
Known False Positives
False positives may arise from legitimate actions by administrators or network operators who may use these commands for automation purposes. Therefore, it's recommended to adjust filter macros to eliminate such false positives.
Associated Analytic Story
References
-
https://blog.aquasec.com/threat-alert-kinsing-malware-container-vulnerability
-
https://www.intezer.com/blog/research/kaiji-new-chinese-linux-malware-turning-to-golang/
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: 9