Startup or Run Key Registry Modification
Identifies run key or startup key registry modifications. In order to survive reboots and other system interrupts, attackers will modify run keys within the registry or leverage startup folder items as a form of persistence.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2020/11/18"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2024/09/23"
6
7[transform]
8[[transform.osquery]]
9label = "Osquery - Retrieve DNS Cache"
10query = "SELECT * FROM dns_cache"
11
12[[transform.osquery]]
13label = "Osquery - Retrieve All Services"
14query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
15
16[[transform.osquery]]
17label = "Osquery - Retrieve Services Running on User Accounts"
18query = """
19SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
20NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
21user_account == null)
22"""
23
24[[transform.osquery]]
25label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
26query = """
27SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
28services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
29authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
30"""
31
32
33[rule]
34author = ["Elastic"]
35description = """
36Identifies run key or startup key registry modifications. In order to survive reboots and other system interrupts,
37attackers will modify run keys within the registry or leverage startup folder items as a form of persistence.
38"""
39from = "now-9m"
40index = ["logs-endpoint.events.registry-*"]
41language = "eql"
42license = "Elastic License v2"
43name = "Startup or Run Key Registry Modification"
44note = """## Triage and analysis
45
46### Investigating Startup or Run Key Registry Modification
47
48Adversaries may achieve persistence by referencing a program with a registry run key. Adding an entry to the run keys in the registry will cause the program referenced to be executed when a user logs in. These programs will executed under the context of the user and will have the account's permissions. This rule looks for this behavior by monitoring a range of registry run keys.
49
50> **Note**:
51> 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.
52
53#### Possible investigation steps
54
55- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
56- Investigate other alerts associated with the user/host during the past 48 hours.
57- Validate if the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
58- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
59- Examine the host for derived artifacts that indicate suspicious activities:
60 - Analyze the process executable using a private sandboxed analysis system.
61 - Observe and collect information about the following activities in both the sandbox and the alert subject host:
62 - Attempts to contact external domains and addresses.
63 - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
64 - Examine the DNS cache for suspicious or anomalous entries.
65 - $osquery_0
66 - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
67 - Examine the host services for suspicious or anomalous entries.
68 - $osquery_1
69 - $osquery_2
70 - $osquery_3
71 - Retrieve the files' SHA-256 hash values using the PowerShell `Get-FileHash` cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
72- Investigate potentially compromised accounts. Analysts can do this by searching for login events (for example, 4624) to the target host after the registry modification.
73
74
75### False positive analysis
76
77- There is a high possibility of benign legitimate programs being added to registry run keys. This activity could be based on new software installations, patches, or any kind of network administrator related activity. Before undertaking further investigation, verify that this activity is not benign.
78
79### Related rules
80
81- Suspicious Startup Shell Folder Modification - c8b150f0-0164-475b-a75e-74b47800a9ff
82- Persistent Scripts in the Startup Directory - f7c4dc5a-a58d-491d-9f14-9b66507121c0
83- Startup Folder Persistence via Unsigned Process - 2fba96c0-ade5-4bce-b92f-a5df2509da3f
84- Startup Persistence by a Suspicious Process - 440e2db4-bc7f-4c96-a068-65b78da59bde
85
86### Response and remediation
87
88- Initiate the incident response process based on the outcome of the triage.
89- Isolate the involved host to prevent further post-compromise behavior.
90- If the triage identified malware, search the environment for additional compromised hosts.
91 - Implement temporary network rules, procedures, and segmentation to contain the malware.
92 - Stop suspicious processes.
93 - Immediately block the identified indicators of compromise (IoCs).
94 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
95- Remove and block malicious artifacts identified during triage.
96- 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.
97- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
98- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
99- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
100"""
101references = ["https://www.elastic.co/security-labs/elastic-security-uncovers-blister-malware-campaign"]
102risk_score = 21
103rule_id = "97fc44d3-8dae-4019-ae83-298c3015600f"
104severity = "low"
105tags = [
106 "Domain: Endpoint",
107 "OS: Windows",
108 "Use Case: Threat Detection",
109 "Tactic: Persistence",
110 "Resources: Investigation Guide",
111 "Data Source: Elastic Endgame",
112 "Data Source: Elastic Defend",
113]
114timeline_id = "3e47ef71-ebfc-4520-975c-cb27fc090799"
115timeline_title = "Comprehensive Registry Timeline"
116timestamp_override = "event.ingested"
117type = "eql"
118
119query = '''
120registry where host.os.type == "windows" and event.type == "change" and
121 registry.data.strings != null and registry.hive : ("HKEY_USERS", "HKLM") and
122 registry.path : (
123 /* Machine Hive */
124 "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
125 "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
126 "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\*",
127 "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
128 "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell\\*",
129 /* Users Hive */
130 "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
131 "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
132 "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\*",
133 "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
134 "HKEY_USERS\\*\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell\\*"
135 ) and
136 /* add common legitimate changes without being too restrictive as this is one of the most abused AESPs */
137 not registry.data.strings : "ctfmon.exe /n" and
138 not (registry.value : "Application Restart #*" and process.name : "csrss.exe") and
139 not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
140 not registry.data.strings : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and
141 not process.executable : ("?:\\Windows\\System32\\msiexec.exe", "?:\\Windows\\SysWOW64\\msiexec.exe") and
142 not (
143 /* Logitech G Hub */
144 (
145 process.code_signature.trusted == true and process.code_signature.subject_name == "Logitech Inc" and
146 (
147 process.name : "lghub_agent.exe" and registry.data.strings : (
148 "\"?:\\Program Files\\LGHUB\\lghub.exe\" --background",
149 "\"?:\\Program Files\\LGHUB\\system_tray\\lghub_system_tray.exe\" --minimized"
150 )
151 ) or
152 (
153 process.name : "LogiBolt.exe" and registry.data.strings : (
154 "?:\\Program Files\\Logi\\LogiBolt\\LogiBolt.exe --startup",
155 "?:\\Users\\*\\AppData\\Local\\Logi\\LogiBolt\\LogiBolt.exe --startup"
156 )
157 )
158 ) or
159
160 /* Google Drive File Stream, Chrome, and Google Update */
161 (
162 process.code_signature.trusted == true and process.code_signature.subject_name == "Google LLC" and
163 (
164 process.name : "GoogleDriveFS.exe" and registry.data.strings : (
165 "\"?:\\Program Files\\Google\\Drive File Stream\\*\\GoogleDriveFS.exe\" --startup_mode"
166 ) or
167
168 process.name : "chrome.exe" and registry.data.strings : (
169 "\"?:\\Program Files\\Google\\Chrome\\Application\\chrome.exe\" --no-startup-window /prefetch:5",
170 "\"?:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --no-startup-window /prefetch:5"
171 ) or
172
173 process.name : "GoogleUpdate.exe" and registry.data.strings : (
174 "\"?:\\Users\\*\\AppData\\Local\\Google\\Update\\*\\GoogleUpdateCore.exe\""
175 )
176 )
177 ) or
178
179 /* MS Programs */
180 (
181 process.code_signature.trusted == true and process.code_signature.subject_name in ("Microsoft Windows", "Microsoft Corporation") and
182 (
183 process.name : "msedge.exe" and registry.data.strings : (
184 "\"?:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" --no-startup-window --win-session-start /prefetch:5",
185 "\"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" --win-session-start",
186 "\"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" --no-startup-window --win-session-start"
187 ) or
188
189 process.name : ("Update.exe", "Teams.exe") and registry.data.strings : (
190 "?:\\Users\\*\\AppData\\Local\\Microsoft\\Teams\\Update.exe --processStart \"Teams.exe\" --process-start-args \"--system-initiated\"",
191 "?:\\ProgramData\\*\\Microsoft\\Teams\\Update.exe --processStart \"Teams.exe\" --process-start-args \"--system-initiated\""
192 ) or
193
194 process.name : "OneDriveStandaloneUpdater.exe" and registry.data.strings : (
195 "?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\*\\Microsoft.SharePoint.exe"
196 ) or
197
198 process.name : "OneDriveSetup.exe" and
199 registry.data.strings : (
200 "?:\\Windows\\system32\\cmd.exe /q /c * \"?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\*\"",
201 "?:\\Program Files (x86)\\Microsoft OneDrive\\OneDrive.exe /background*",
202 "\"?:\\Program Files (x86)\\Microsoft OneDrive\\OneDrive.exe\" /background*",
203 "?:\\Program Files\\Microsoft OneDrive\\OneDrive.exe /background *",
204 "?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\??.???.????.????\\Microsoft.SharePoint.exe"
205 ) or
206
207 process.name : "OneDrive.exe" and registry.data.strings : (
208 "\"?:\\Program Files\\Microsoft OneDrive\\OneDrive.exe\" /background",
209 "\"?:\\Program Files (x86)\\Microsoft OneDrive\\OneDrive.exe\" /background",
210 "\"?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\OneDrive.exe\" /background"
211 ) or
212
213 process.name : "Microsoft.SharePoint.exe" and registry.data.strings : (
214 "?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\??.???.????.????\\Microsoft.SharePoint.exe"
215 ) or
216
217 process.name : "MicrosoftEdgeUpdate.exe" and registry.data.strings : (
218 "\"?:\\Users\\Expedient\\AppData\\Local\\Microsoft\\EdgeUpdate\\*\\MicrosoftEdgeUpdateCore.exe\""
219 ) or
220
221 process.executable : "?:\\Program Files (x86)\\Microsoft\\EdgeWebView\\Application\\*\\Installer\\setup.exe" and
222 registry.data.strings : (
223 "\"?:\\Program Files (x86)\\Microsoft\\EdgeWebView\\Application\\*\\Installer\\setup.exe\" --msedgewebview --delete-old-versions --system-level --verbose-logging --on-logon"
224 )
225 )
226 ) or
227
228 /* Slack */
229 (
230 process.code_signature.trusted == true and process.code_signature.subject_name in (
231 "Slack Technologies, Inc.", "Slack Technologies, LLC"
232 ) and process.name : "slack.exe" and registry.data.strings : (
233 "\"?:\\Users\\*\\AppData\\Local\\slack\\slack.exe\" --process-start-args --startup",
234 "\"?:\\ProgramData\\*\\slack\\slack.exe\" --process-start-args --startup",
235 "\"?:\\Program Files\\Slack\\slack.exe\" --process-start-args --startup"
236 )
237 ) or
238
239 /* Cisco */
240 (
241 process.code_signature.trusted == true and process.code_signature.subject_name in ("Cisco WebEx LLC", "Cisco Systems, Inc.") and
242 (
243 process.name : "WebexHost.exe" and registry.data.strings : (
244 "\"?:\\Users\\*\\AppData\\Local\\WebEx\\WebexHost.exe\" /daemon /runFrom=autorun"
245 )
246 ) or
247 (
248 process.name : "CiscoJabber.exe" and registry.data.strings : (
249 "\"?:\\Program Files (x86)\\Cisco Systems\\Cisco Jabber\\CiscoJabber.exe\" /min"
250 )
251 )
252 ) or
253
254 /* Loom */
255 (
256 process.code_signature.trusted == true and process.code_signature.subject_name == "Loom, Inc." and
257 process.name : "Loom.exe" and registry.data.strings : (
258 "?:\\Users\\*\\AppData\\Local\\Programs\\Loom\\Loom.exe --process-start-args \"--loomHidden\""
259 )
260 ) or
261
262 /* Adobe */
263 (
264 process.code_signature.trusted == true and process.code_signature.subject_name == "Adobe Inc." and
265 process.name : ("Acrobat.exe", "FlashUtil32_*_Plugin.exe") and registry.data.strings : (
266 "\"?:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\AdobeCollabSync.exe\"",
267 "\"?:\\Program Files (x86)\\Adobe\\Acrobat DC\\Acrobat\\AdobeCollabSync.exe\"",
268 "?:\\WINDOWS\\SysWOW64\\Macromed\\Flash\\FlashUtil32_*_Plugin.exe -update plugin"
269 )
270 ) or
271
272 /* CCleaner */
273 (
274 process.code_signature.trusted == true and process.code_signature.subject_name == "PIRIFORM SOFTWARE LIMITED" and
275 process.name : ("CCleanerBrowser.exe", "CCleaner64.exe") and registry.data.strings : (
276 "\"C:\\Program Files (x86)\\CCleaner Browser\\Application\\CCleanerBrowser.exe\" --check-run=src=logon --auto-launch-at-startup --profile-directory=\"Default\"",
277 "\"C:\\Program Files\\CCleaner\\CCleaner64.exe\" /MONITOR"
278 )
279 ) or
280
281 /* Opera */
282 (
283 process.code_signature.trusted == true and process.code_signature.subject_name == "Opera Norway AS" and
284 process.name : "opera.exe" and registry.data.strings : (
285 "?:\\Users\\*\\AppData\\Local\\Programs\\Opera\\launcher.exe",
286 "?:\\Users\\*\\AppData\\Local\\Programs\\Opera GX\\launcher.exe"
287 )
288 ) or
289
290 /* Avast */
291 (
292 process.code_signature.trusted == true and process.code_signature.subject_name == "Avast Software s.r.o." and
293 process.name : "AvastBrowser.exe" and registry.data.strings : (
294 "\"?:\\Users\\*\\AppData\\Local\\AVAST Software\\Browser\\Application\\AvastBrowser.exe\" --check-run=src=logon --auto-launch-at-startup*",
295 "\"?:\\Program Files (x86)\\AVAST Software\\Browser\\Application\\AvastBrowser.exe\" --check-run=src=logon --auto-launch-at-startup*",
296 ""
297 )
298 ) or
299
300 /* Grammarly */
301 (
302 process.code_signature.trusted == true and process.code_signature.subject_name == "Grammarly, Inc." and
303 process.name : "GrammarlyInstaller.exe" and registry.data.strings : (
304 "?:\\Users\\*\\AppData\\Local\\Grammarly\\DesktopIntegrations\\Grammarly.Desktop.exe"
305 )
306 )
307 )
308'''
309
310
311[[rule.threat]]
312framework = "MITRE ATT&CK"
313[[rule.threat.technique]]
314id = "T1547"
315name = "Boot or Logon Autostart Execution"
316reference = "https://attack.mitre.org/techniques/T1547/"
317[[rule.threat.technique.subtechnique]]
318id = "T1547.001"
319name = "Registry Run Keys / Startup Folder"
320reference = "https://attack.mitre.org/techniques/T1547/001/"
321
322
323
324[rule.threat.tactic]
325id = "TA0003"
326name = "Persistence"
327reference = "https://attack.mitre.org/tactics/TA0003/"
Triage and analysis
Investigating Startup or Run Key Registry Modification
Adversaries may achieve persistence by referencing a program with a registry run key. Adding an entry to the run keys in the registry will cause the program referenced to be executed when a user logs in. These programs will executed under the context of the user and will have the account's permissions. This rule looks for this behavior by monitoring a range of registry run keys.
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.
Possible investigation steps
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Validate if the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
- Examine the host for derived artifacts that indicate suspicious activities:
- Analyze the process executable using a private sandboxed analysis system.
- Observe and collect information about the following activities in both the sandbox and the alert subject host:
- Attempts to contact external domains and addresses.
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process'
process.entity_id
. - Examine the DNS cache for suspicious or anomalous entries.
- $osquery_0
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process'
- Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
- Examine the host services for suspicious or anomalous entries.
- $osquery_1
- $osquery_2
- $osquery_3
- Attempts to contact external domains and addresses.
- Retrieve the files' SHA-256 hash values using the PowerShell
Get-FileHash
cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
- Investigate potentially compromised accounts. Analysts can do this by searching for login events (for example, 4624) to the target host after the registry modification.
False positive analysis
- There is a high possibility of benign legitimate programs being added to registry run keys. This activity could be based on new software installations, patches, or any kind of network administrator related activity. Before undertaking further investigation, verify that this activity is not benign.
Related rules
- Suspicious Startup Shell Folder Modification - c8b150f0-0164-475b-a75e-74b47800a9ff
- Persistent Scripts in the Startup Directory - f7c4dc5a-a58d-491d-9f14-9b66507121c0
- Startup Folder Persistence via Unsigned Process - 2fba96c0-ade5-4bce-b92f-a5df2509da3f
- Startup Persistence by a Suspicious Process - 440e2db4-bc7f-4c96-a068-65b78da59bde
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.
- Remove and block malicious artifacts identified during triage.
- 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.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Component Object Model Hijacking
- Potential Linux Backdoor User Account Creation
- Remote Execution via File Shares
- Execution of File Written or Modified by Microsoft Office
- Persistence via WMI Standard Registry Provider