Shared Object Created or Changed by Previously Unknown Process
This rule monitors the creation of shared object files by previously unknown processes. The creation of a shared object file involves compiling code into a dynamically linked library that can be loaded by other programs at runtime. While this process is typically used for legitimate purposes, malicious actors can leverage shared object files to execute unauthorized code, inject malicious functionality into legitimate processes, or bypass security controls. This allows malware to persist on the system, evade detection, and potentially compromise the integrity and confidentiality of the affected system and its data.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/06/09"
3integration = ["endpoint"]
4maturity = "production"
5min_stack_comments = "New fields added: required_fields, related_integrations, setup, New Term"
6min_stack_version = "8.6.0"
7updated_date = "2024/02/21"
8
9[transform]
10[[transform.osquery]]
11label = "Osquery - Retrieve File Listing Information"
12query = """
13SELECT * FROM file WHERE path = {{file.path}}
14"""
15[[transform.osquery]]
16label = "Osquery - Retrieve Additional File Listing Information"
17query = """
18SELECT
19 f.path,
20 u.username AS file_owner,
21 g.groupname AS group_owner,
22 datetime(f.atime, 'unixepoch') AS file_last_access_time,
23 datetime(f.mtime, 'unixepoch') AS file_last_modified_time,
24 datetime(f.ctime, 'unixepoch') AS file_last_status_change_time,
25 datetime(f.btime, 'unixepoch') AS file_created_time,
26 f.size AS size_bytes
27FROM
28 file f
29 LEFT JOIN users u ON f.uid = u.uid
30 LEFT JOIN groups g ON f.gid = g.gid
31WHERE path = {{file.path}}
32"""
33
34[[transform.osquery]]
35label = "Osquery - Retrieve Running Processes by User"
36query = "SELECT pid, username, name FROM processes p JOIN users u ON u.uid = p.uid ORDER BY username"
37
38[[transform.osquery]]
39label = "Osquery - Retrieve Crontab Information"
40query = "SELECT * FROM crontab"
41
42[[transform.osquery]]
43label = "Osquery - Retrieve Listening Ports"
44query = "SELECT pid, address, port, socket, protocol, path FROM listening_ports"
45
46[[transform.osquery]]
47label = "Osquery - Retrieve Open Sockets"
48query = "SELECT pid, family, remote_address, remote_port, socket, state FROM process_open_sockets"
49
50[[transform.osquery]]
51label = "Osquery - Retrieve Information for a Specific User"
52query = "SELECT * FROM users WHERE username = {{user.name}}"
53
54[[transform.osquery]]
55label = "Osquery - Investigate the Account Authentication Status"
56query = "SELECT * FROM logged_in_users WHERE user = {{user.name}}"
57
58[rule]
59author = ["Elastic"]
60description = """
61This rule monitors the creation of shared object files by previously unknown processes. The creation of a shared object
62file involves compiling code into a dynamically linked library that can be loaded by other programs at runtime. While
63this process is typically used for legitimate purposes, malicious actors can leverage shared object files to execute
64unauthorized code, inject malicious functionality into legitimate processes, or bypass security controls. This allows
65malware to persist on the system, evade detection, and potentially compromise the integrity and confidentiality of the
66affected system and its data.
67"""
68from = "now-9m"
69index = ["logs-endpoint.events.*", "endgame-*"]
70language = "kuery"
71license = "Elastic License v2"
72name = "Shared Object Created or Changed by Previously Unknown Process"
73note = """## Triage and analysis
74
75### Investigating Shared Object Created or Changed by Previously Unknown Process
76
77A shared object file is a compiled library file (typically with a .so extension) that can be dynamically linked to executable programs at runtime, allowing for code reuse and efficient memory usage. The creation of a shared object file involves compiling code into a dynamically linked library that can be loaded by other programs at runtime.
78
79Malicious actors can leverage shared object files to execute unauthorized code, inject malicious functionality into legitimate processes, or bypass security controls. This allows malware to persist on the system, evade detection, and potentially compromise the integrity and confidentiality of the affected system and its data.
80
81This rule monitors the creation of shared object files by previously unknown processes through the usage of the new terms rule type.
82
83> **Note**:
84> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/master/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
85> This investigation guide uses [placeholder fields](https://www.elastic.co/guide/en/security/current/osquery-placeholder-fields.html) to dynamically pass alert data into Osquery queries. Placeholder fields were introduced in Elastic Stack version 8.7.0. If you're using Elastic Stack version 8.6.0 or earlier, you'll need to manually adjust this investigation guide's queries to ensure they properly run.
86
87#### Possible Investigation Steps
88
89- Investigate the shared object that was created or modified through OSQuery.
90 - $osquery_0
91 - $osquery_1
92- Investigate the script execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence and whether they are located in expected locations.
93 - $osquery_2
94- Investigate other alerts associated with the user/host during the past 48 hours.
95- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
96- Investigate whether the altered scripts call other malicious scripts elsewhere on the file system.
97 - If scripts or executables were dropped, retrieve the files and determine if they are malicious:
98 - Use a private sandboxed malware analysis system to perform analysis.
99 - Observe and collect information about the following activities:
100 - Attempts to contact external domains and addresses.
101 - Check if the domain is newly registered or unexpected.
102 - Check the reputation of the domain or IP address.
103 - File access, modification, and creation activities.
104 - Cron jobs, services and other persistence mechanisms.
105 - $osquery_3
106- Investigate abnormal behaviors by the subject process/user such as network connections, file modifications, and any other spawned child processes.
107 - Investigate listening ports and open sockets to look for potential command and control traffic or data exfiltration.
108 - $osquery_4
109 - $osquery_5
110 - Identify the user account that performed the action, analyze it, and check whether it should perform this kind of action.
111 - $osquery_6
112- Investigate whether the user is currently logged in and active.
113 - $osquery_7
114
115### False Positive Analysis
116
117- If this activity is related to new benign software installation activity, consider adding exceptions — preferably with a combination of user and command line conditions.
118- If this activity is related to a system administrator that performed these actions for administrative purposes, consider adding exceptions for this specific administrator user account.
119- Try to understand the context of the execution by thinking about the user, machine, or business purpose. A small number of endpoints, such as servers with unique software, might appear unusual but satisfy a specific business need.
120
121### Response and remediation
122
123- Initiate the incident response process based on the outcome of the triage.
124- Isolate the involved host to prevent further post-compromise behavior.
125- If the triage identified malware, search the environment for additional compromised hosts.
126 - Implement temporary network rules, procedures, and segmentation to contain the malware.
127 - Stop suspicious processes.
128 - Immediately block the identified indicators of compromise (IoCs).
129 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
130- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
131- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
132- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
133- Leverage the incident response data and logging to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
134"""
135references = ["https://threatpost.com/sneaky-malware-backdoors-linux/180158/"]
136risk_score = 47
137rule_id = "aebaa51f-2a91-4f6a-850b-b601db2293f4"
138setup = """## Setup
139
140This rule requires data coming in from Elastic Defend.
141
142### Elastic Defend Integration Setup
143Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
144
145#### Prerequisite Requirements:
146- Fleet is required for Elastic Defend.
147- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
148
149#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
150- Go to the Kibana home page and click "Add integrations".
151- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
152- Click "Add Elastic Defend".
153- Configure the integration name and optionally add a description.
154- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
155- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
156- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
157- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
158For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
159- Click "Save and Continue".
160- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
161For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
162"""
163severity = "medium"
164tags = [
165 "Domain: Endpoint",
166 "OS: Linux",
167 "Use Case: Threat Detection",
168 "Tactic: Persistence",
169 "Data Source: Elastic Endgame",
170 "Data Source: Elastic Defend"
171 ]
172timestamp_override = "event.ingested"
173type = "new_terms"
174query = '''
175host.os.type:linux and event.action:(creation or file_create_event or file_rename_event or rename) and
176file.path:(/dev/shm/* or /usr/lib/*) and file.extension:so and process.name:* and not (
177 process.name:("dockerd" or "dpkg" or "rpm" or "snapd" or "yum" or "vmis-launcher" or "pacman" or
178 "apt-get" or "dnf" or "podman" or "platform-python") or
179 (process.name:vmware-install.pl and file.path:/usr/lib/vmware-tools/*)
180)
181'''
182
183[[rule.threat]]
184framework = "MITRE ATT&CK"
185
186[[rule.threat.technique]]
187id = "T1574"
188name = "Hijack Execution Flow"
189reference = "https://attack.mitre.org/techniques/T1574/"
190
191[[rule.threat.technique.subtechnique]]
192id = "T1574.006"
193name = "Dynamic Linker Hijacking"
194reference = "https://attack.mitre.org/techniques/T1574/006/"
195
196[rule.threat.tactic]
197id = "TA0003"
198name = "Persistence"
199reference = "https://attack.mitre.org/tactics/TA0003/"
200
201[rule.new_terms]
202field = "new_terms_fields"
203value = ["host.id", "file.path", "process.executable"]
204
205[[rule.new_terms.history_window_start]]
206field = "history_window_start"
207value = "now-10d"
Triage and analysis
Investigating Shared Object Created or Changed by Previously Unknown Process
A shared object file is a compiled library file (typically with a .so extension) that can be dynamically linked to executable programs at runtime, allowing for code reuse and efficient memory usage. The creation of a shared object file involves compiling code into a dynamically linked library that can be loaded by other programs at runtime.
Malicious actors can leverage shared object files to execute unauthorized code, inject malicious functionality into legitimate processes, or bypass security controls. This allows malware to persist on the system, evade detection, and potentially compromise the integrity and confidentiality of the affected system and its data.
This rule monitors the creation of shared object files by previously unknown processes through the usage of the new terms rule type.
Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide. This investigation guide uses placeholder fields to dynamically pass alert data into Osquery queries. Placeholder fields were introduced in Elastic Stack version 8.7.0. If you're using Elastic Stack version 8.6.0 or earlier, you'll need to manually adjust this investigation guide's queries to ensure they properly run.
Possible Investigation Steps
- Investigate the shared object that was created or modified through OSQuery.
- $osquery_0
- $osquery_1
- Investigate the script execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence and whether they are located in expected locations.
- $osquery_2
- Investigate other alerts associated with the user/host during the past 48 hours.
- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
- Investigate whether the altered scripts call other malicious scripts elsewhere on the file system.
- If scripts or executables were dropped, retrieve the files and determine if they are malicious:
- Use a private sandboxed malware analysis system to perform analysis.
- Observe and collect information about the following activities:
- Attempts to contact external domains and addresses.
- Check if the domain is newly registered or unexpected.
- Check the reputation of the domain or IP address.
- File access, modification, and creation activities.
- Cron jobs, services and other persistence mechanisms.
- $osquery_3
- Attempts to contact external domains and addresses.
- Observe and collect information about the following activities:
- Use a private sandboxed malware analysis system to perform analysis.
- If scripts or executables were dropped, retrieve the files and determine if they are malicious:
- Investigate abnormal behaviors by the subject process/user such as network connections, file modifications, and any other spawned child processes.
- Investigate listening ports and open sockets to look for potential command and control traffic or data exfiltration.
- $osquery_4
- $osquery_5
- Identify the user account that performed the action, analyze it, and check whether it should perform this kind of action.
- $osquery_6
- Investigate listening ports and open sockets to look for potential command and control traffic or data exfiltration.
- Investigate whether the user is currently logged in and active.
- $osquery_7
False Positive Analysis
- If this activity is related to new benign software installation activity, consider adding exceptions — preferably with a combination of user and command line conditions.
- If this activity is related to a system administrator that performed these actions for administrative purposes, consider adding exceptions for this specific administrator user account.
- Try to understand the context of the execution by thinking about the user, machine, or business purpose. A small number of endpoints, such as servers with unique software, might appear unusual but satisfy a specific business need.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Leverage the incident response data and logging to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Chkconfig Service Add
- Cron Job Created or Changed by Previously Unknown Process
- Kernel Module Load via insmod
- Modification of OpenSSH Binaries
- New Systemd Service Created by Previously Unknown Process