|
1 | 1 | name: Linux Auditd Possible Access Or Modification Of Sshd Config File |
2 | 2 | id: acb3ea33-70f7-47aa-b335-643b3aebcb2f |
3 | | -version: 7 |
4 | | -date: '2025-06-10' |
5 | | -author: Teoderick Contreras, Splunk |
| 3 | +version: 8 |
| 4 | +date: '2025-11-27' |
| 5 | +author: Teoderick Contreras, Nasreddine Bencherchali, Splunk |
6 | 6 | status: production |
7 | 7 | type: Anomaly |
8 | | -description: The following analytic detects suspicious access or modification of the |
9 | | - sshd_config file on Linux systems. It leverages data from Linux Auditd, focusing |
10 | | - on command-line executions involving processes like "cat," "nano," "vim," and "vi" |
11 | | - accessing the sshd_config file. This activity is significant because unauthorized |
12 | | - changes to sshd_config can allow threat actors to redirect port connections or use |
13 | | - unauthorized keys, potentially compromising the system. If confirmed malicious, |
14 | | - this could lead to unauthorized access, privilege escalation, or persistent backdoor |
15 | | - access, posing a severe security risk. |
| 8 | +description: | |
| 9 | + The following analytic detects access, deletion or modification of the ssh_config file on Linux systems. |
| 10 | + It leverages data from Linux Auditd, focusing on events of type PATH with a nametype of ("NORMAL", "CREATE", "DELETE"). |
| 11 | + This activity could be significant because unauthorized changes to ssh_config can allow threat actors to redirect port connections or use unauthorized keys, potentially compromising the system. |
| 12 | + Correlate this with related EXECVE or PROCTITLE events to identify the process or user responsible for the access or modification. |
| 13 | + If confirmed malicious, this could lead to unauthorized access, privilege escalation, or persistent backdoor access, posing a severe security risk. |
16 | 14 | data_source: |
17 | | -- Linux Auditd Path |
18 | | -search: '`linux_auditd` type=PATH name="/etc/ssh/ssh_config*" |
| 15 | + - Linux Auditd Path |
| 16 | + - Linux Auditd Cwd |
| 17 | +search: | |
| 18 | + `linux_auditd` |
| 19 | + ( |
| 20 | + (type=PATH nametype IN ("NORMAL", "CREATE", "DELETE")) |
| 21 | + OR |
| 22 | + type=CWD |
| 23 | + ) |
| 24 | + | rex "msg=audit\([^)]*:(?<audit_id>\d+)\)" |
| 25 | +
|
| 26 | + | stats |
| 27 | + values(type) as types |
| 28 | + values(name) as names |
| 29 | + values(nametype) as nametype |
| 30 | + values(cwd) as cwd_list |
| 31 | + values(_time) as event_times |
| 32 | + by audit_id, host |
| 33 | +
|
| 34 | + | eval current_working_directory = coalesce(mvindex(cwd_list, 0), "N/A") |
| 35 | + | eval candidate_paths = mvmap(names, if(match(names, "^/"), names, current_working_directory + "/" + names)) |
| 36 | + | eval matched_paths = mvfilter(match(candidate_paths, "/etc/ssh/ssh_config.*")) |
| 37 | + | eval match_count = mvcount(matched_paths) |
| 38 | + | eval reconstructed_path = mvindex(matched_paths, 0) |
| 39 | + | eval e_time = mvindex(event_times, 0) |
| 40 | + | where match_count > 0 |
19 | 41 | | rename host as dest |
20 | | - | stats count min(_time) as firstTime max(_time) as lastTime |
21 | | - by name nametype ogid type dest |
| 42 | +
|
| 43 | + | stats count min(e_time) as firstTime max(e_time) as lastTime |
| 44 | + values(nametype) as nametype |
| 45 | + by current_working_directory |
| 46 | + reconstructed_path |
| 47 | + match_count |
| 48 | + dest |
| 49 | + audit_id |
| 50 | +
|
22 | 51 | | `security_content_ctime(firstTime)` |
23 | 52 | | `security_content_ctime(lastTime)` |
24 | | - | `linux_auditd_possible_access_or_modification_of_sshd_config_file_filter`' |
25 | | -how_to_implement: To implement this detection, the process begins by ingesting auditd |
| 53 | + | `linux_auditd_possible_access_or_modification_of_sshd_config_file_filter` |
| 54 | +how_to_implement: | |
| 55 | + To implement this detection, the process begins by ingesting auditd |
26 | 56 | data, that consist SYSCALL, TYPE, EXECVE and PROCTITLE events, which captures command-line |
27 | 57 | executions and process details on Unix/Linux systems. These logs should be ingested |
28 | 58 | and processed using Splunk Add-on for Unix and Linux (https://splunkbase.splunk.com/app/833), |
29 | 59 | which is essential for correctly parsing and categorizing the data. The next step |
30 | 60 | involves normalizing the field names to match the field names set by the Splunk |
31 | 61 | Common Information Model (CIM) to ensure consistency across different data sources |
32 | | - and enhance the efficiency of data modeling. This approach enables effective monitoring |
33 | | - and detection of linux endpoints where auditd is deployed |
34 | | -known_false_positives: Administrator or network operator can use this commandline |
35 | | - for automation purposes. Please update the filter macros to remove false positives. |
| 62 | + and enhance the efficiency of data modeling and make sure the type=CWD record type is activate in your auditd configuration. |
| 63 | + This approach enables effective monitoring and detection of linux endpoints where auditd is deployed. |
| 64 | +known_false_positives: | |
| 65 | + Administrator or network operator can use this commandline for automation purposes. |
| 66 | + Please update the filter macros to remove false positives. |
36 | 67 | references: |
37 | | -- https://www.hackingarticles.in/ssh-penetration-testing-port-22/ |
38 | | -- https://attack.mitre.org/techniques/T1098/004/ |
| 68 | + - https://www.hackingarticles.in/ssh-penetration-testing-port-22/ |
| 69 | + - https://attack.mitre.org/techniques/T1098/004/ |
39 | 70 | drilldown_searches: |
40 | | -- name: View the detection results for - "$dest$" |
41 | | - search: '%original_detection_search% | search dest = "$dest$"' |
42 | | - earliest_offset: $info_min_time$ |
43 | | - latest_offset: $info_max_time$ |
44 | | -- name: View risk events for the last 7 days for - "$dest$" |
45 | | - search: '| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$dest$") |
46 | | - starthoursago=168 | stats count min(_time) as firstTime max(_time) as lastTime |
47 | | - values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) |
48 | | - as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) |
49 | | - as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` |
50 | | - | `security_content_ctime(lastTime)`' |
51 | | - earliest_offset: $info_min_time$ |
52 | | - latest_offset: $info_max_time$ |
| 71 | + - name: View the detection results for - "$dest$" |
| 72 | + search: '%original_detection_search% | search dest = "$dest$"' |
| 73 | + earliest_offset: $info_min_time$ |
| 74 | + latest_offset: $info_max_time$ |
| 75 | + - name: View risk events for the last 7 days for - "$dest$" |
| 76 | + search: '| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$dest$") |
| 77 | + starthoursago=168 | stats count min(_time) as firstTime max(_time) as lastTime |
| 78 | + values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) |
| 79 | + as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) |
| 80 | + as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` |
| 81 | + | `security_content_ctime(lastTime)`' |
| 82 | + earliest_offset: $info_min_time$ |
| 83 | + latest_offset: $info_max_time$ |
53 | 84 | rba: |
54 | | - message: A [$type$] has been accessed/modified on host - [$dest$] to modify the |
55 | | - sshd_config file. |
| 85 | + message: $reconstructed_path$ has been accessed with type $nametype$ on host - [$dest$] |
56 | 86 | risk_objects: |
57 | | - - field: dest |
58 | | - type: system |
59 | | - score: 25 |
| 87 | + - field: dest |
| 88 | + type: system |
| 89 | + score: 25 |
60 | 90 | threat_objects: [] |
61 | 91 | tags: |
62 | 92 | analytic_story: |
63 | | - - Linux Living Off The Land |
64 | | - - Linux Privilege Escalation |
65 | | - - Linux Persistence Techniques |
66 | | - - Compromised Linux Host |
| 93 | + - Linux Living Off The Land |
| 94 | + - Linux Privilege Escalation |
| 95 | + - Linux Persistence Techniques |
| 96 | + - Compromised Linux Host |
67 | 97 | asset_type: Endpoint |
68 | 98 | mitre_attack_id: |
69 | | - - T1098.004 |
| 99 | + - T1098.004 |
70 | 100 | product: |
71 | | - - Splunk Enterprise |
72 | | - - Splunk Enterprise Security |
73 | | - - Splunk Cloud |
| 101 | + - Splunk Enterprise |
| 102 | + - Splunk Enterprise Security |
| 103 | + - Splunk Cloud |
74 | 104 | security_domain: endpoint |
75 | 105 | tests: |
76 | | -- name: True Positive Test |
77 | | - attack_data: |
78 | | - - data: |
79 | | - https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1098.004/linux_auditd_nopasswd/linux_path_ssh_config.log |
80 | | - source: auditd |
81 | | - sourcetype: auditd |
| 106 | + - name: True Positive Test |
| 107 | + attack_data: |
| 108 | + - data: |
| 109 | + https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1098.004/auditd_path_ssh_config/path_ssh_config.log |
| 110 | + source: auditd |
| 111 | + sourcetype: auditd |
0 commit comments