Startup Persistence by a Suspicious Process

Identifies files written to or modified in the startup folder by commonly abused processes. Adversaries may use this technique to maintain persistence.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/11/18"
  3integration = ["endpoint", "windows", "m365_defender", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5updated_date = "2025/03/20"
  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 files written to or modified in the startup folder by commonly abused processes. Adversaries may use this
 37technique to maintain persistence.
 38"""
 39from = "now-9m"
 40index = [
 41    "winlogbeat-*",
 42    "logs-endpoint.events.file-*",
 43    "logs-windows.sysmon_operational-*",
 44    "endgame-*",
 45    "logs-m365_defender.event-*",
 46    "logs-sentinel_one_cloud_funnel.*",
 47]
 48language = "eql"
 49license = "Elastic License v2"
 50name = "Startup Persistence by a Suspicious Process"
 51note = """## Triage and analysis
 52
 53### Investigating Startup Persistence by a Suspicious Process
 54
 55The Windows Startup folder is a special folder in Windows. Programs added to this folder are executed during account logon, without user interaction, providing an excellent way for attackers to maintain persistence.
 56
 57This rule monitors for commonly abused processes writing to the Startup folder locations.
 58
 59> **Note**:
 60> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/current/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
 61
 62#### Possible investigation steps
 63
 64- 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.
 65- Investigate other alerts associated with the user/host during the past 48 hours.
 66- Validate if the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
 67- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
 68- Examine the host for derived artifacts that indicate suspicious activities:
 69  - Analyze the file using a private sandboxed analysis system.
 70  - Observe and collect information about the following activities in both the sandbox and the alert subject host:
 71    - Attempts to contact external domains and addresses.
 72      - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
 73      - Examine the DNS cache for suspicious or anomalous entries.
 74        - $osquery_0
 75    - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
 76    - Examine the host services for suspicious or anomalous entries.
 77      - $osquery_1
 78      - $osquery_2
 79      - $osquery_3
 80  - 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.
 81- Investigate potentially compromised accounts. Analysts can do this by searching for login events (for example, 4624) to the target host after the registry modification.
 82
 83### False positive analysis
 84
 85- Administrators may add programs to this mechanism via command-line shells. Before the further investigation, verify that this activity is not benign.
 86
 87### Related rules
 88
 89- Suspicious Startup Shell Folder Modification - c8b150f0-0164-475b-a75e-74b47800a9ff
 90- Persistent Scripts in the Startup Directory - f7c4dc5a-a58d-491d-9f14-9b66507121c0
 91
 92### Response and remediation
 93
 94- Initiate the incident response process based on the outcome of the triage.
 95- Isolate the involved host to prevent further post-compromise behavior.
 96- If the triage identified malware, search the environment for additional compromised hosts.
 97  - Implement temporary network rules, procedures, and segmentation to contain the malware.
 98  - Stop suspicious processes.
 99  - Immediately block the identified indicators of compromise (IoCs).
100  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
101- Remove and block malicious artifacts identified during triage.
102- 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.
103- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
104- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
105- 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).
106"""
107references = [
108    "https://www.elastic.co/security-labs/hunting-for-persistence-using-elastic-security-part-1",
109    "https://www.elastic.co/security-labs/elastic-security-uncovers-blister-malware-campaign",
110]
111risk_score = 47
112rule_id = "440e2db4-bc7f-4c96-a068-65b78da59bde"
113severity = "medium"
114tags = [
115    "Domain: Endpoint",
116    "OS: Windows",
117    "Use Case: Threat Detection",
118    "Tactic: Persistence",
119    "Resources: Investigation Guide",
120    "Data Source: Elastic Endgame",
121    "Data Source: Elastic Defend",
122    "Data Source: Sysmon",
123    "Data Source: Microsoft Defender for Endpoint",
124    "Data Source: SentinelOne",
125]
126timestamp_override = "event.ingested"
127type = "eql"
128
129query = '''
130file where host.os.type == "windows" and event.type != "deletion" and
131  user.domain != "NT AUTHORITY" and
132  file.path : ("C:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*",
133               "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\*") and
134  process.name : ("cmd.exe",
135                  "powershell.exe",
136                  "wmic.exe",
137                  "mshta.exe",
138                  "pwsh.exe",
139                  "cscript.exe",
140                  "wscript.exe",
141                  "regsvr32.exe",
142                  "RegAsm.exe",
143                  "rundll32.exe",
144                  "EQNEDT32.EXE",
145                  "WINWORD.EXE",
146                  "EXCEL.EXE",
147                  "POWERPNT.EXE",
148                  "MSPUB.EXE",
149                  "MSACCESS.EXE",
150                  "iexplore.exe",
151                  "InstallUtil.exe")
152'''
153
154
155[[rule.threat]]
156framework = "MITRE ATT&CK"
157[[rule.threat.technique]]
158id = "T1547"
159name = "Boot or Logon Autostart Execution"
160reference = "https://attack.mitre.org/techniques/T1547/"
161[[rule.threat.technique.subtechnique]]
162id = "T1547.001"
163name = "Registry Run Keys / Startup Folder"
164reference = "https://attack.mitre.org/techniques/T1547/001/"
165
166
167
168[rule.threat.tactic]
169id = "TA0003"
170name = "Persistence"
171reference = "https://attack.mitre.org/tactics/TA0003/"
...
toml

The Windows Startup folder is a special folder in Windows. Programs added to this folder are executed during account logon, without user interaction, providing an excellent way for attackers to maintain persistence.

This rule monitors for commonly abused processes writing to the Startup folder locations.

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.

  • 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 file 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 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
    • 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.
  • Administrators may add programs to this mechanism via command-line shells. Before the further investigation, verify that this activity is not benign.
  • Suspicious Startup Shell Folder Modification - c8b150f0-0164-475b-a75e-74b47800a9ff
  • Persistent Scripts in the Startup Directory - f7c4dc5a-a58d-491d-9f14-9b66507121c0
  • 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

to-top