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