Suspicious Startup Shell Folder Modification

Identifies suspicious startup shell folder modifications to change the default Startup directory in order to bypass detections monitoring file creation in the Windows Startup folder.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2021/03/15"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/05/21"
  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 suspicious startup shell folder modifications to change the default Startup directory in order to bypass
 37detections monitoring file creation in the Windows Startup folder.
 38"""
 39from = "now-9m"
 40index = ["logs-endpoint.events.registry-*", "endgame-*", "logs-windows.sysmon_operational-*"]
 41language = "eql"
 42license = "Elastic License v2"
 43name = "Suspicious Startup Shell Folder Modification"
 44note = """## Triage and analysis
 45
 46### Investigating Suspicious Startup Shell Folder Modification
 47
 48Techniques used within malware and by adversaries often leverage the Windows registry to store malicious programs for persistence. Startup shell folders are often targeted as they are not as prevalent as normal Startup folder paths so this behavior may evade existing AV/EDR solutions. These programs may also run with higher privileges which can be ideal for an attacker.
 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- Review the source process and related file tied to the Windows Registry entry.
 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 file 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### False positive analysis
 75
 76- There is a high possibility of benign legitimate programs being added to shell folders. This activity could be based on new software installations, patches, or other network administrator activity. Before undertaking further investigation, it should be verified that this activity is not benign.
 77
 78### Related rules
 79
 80- Startup or Run Key Registry Modification - 97fc44d3-8dae-4019-ae83-298c3015600f
 81- Persistent Scripts in the Startup Directory - f7c4dc5a-a58d-491d-9f14-9b66507121c0
 82
 83### Response and remediation
 84
 85- Initiate the incident response process based on the outcome of the triage.
 86- Isolate the involved host to prevent further post-compromise behavior.
 87- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 88- If the malicious file was delivered via phishing:
 89  - Block the email sender from sending future emails.
 90  - Block the malicious web pages.
 91  - Remove emails from the sender from mailboxes.
 92  - Consider improvements to the security awareness program.
 93- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 94- 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).
 95"""
 96risk_score = 73
 97rule_id = "c8b150f0-0164-475b-a75e-74b47800a9ff"
 98severity = "high"
 99tags = [
100    "Domain: Endpoint",
101    "OS: Windows",
102    "Use Case: Threat Detection",
103    "Tactic: Persistence",
104    "Tactic: Defense Evasion",
105    "Resources: Investigation Guide",
106    "Data Source: Elastic Endgame",
107    "Data Source: Elastic Defend",
108    "Data Source: Sysmon",
109]
110timestamp_override = "event.ingested"
111type = "eql"
112
113query = '''
114registry where host.os.type == "windows" and
115 registry.path : (
116     "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\Common Startup",
117     "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Common Startup",
118     "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\Startup",
119     "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Startup",
120     "HKU\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\Startup",
121     "HKU\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Startup",
122     "\\REGISTRY\\MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\Common Startup",
123     "\\REGISTRY\\MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Common Startup",
124     "\\REGISTRY\\USER\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\Startup",
125     "\\REGISTRY\\USER\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Startup"
126     ) and
127  registry.data.strings != null and
128  /* Normal Startup Folder Paths */
129  not registry.data.strings : (
130           "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup",
131           "%ProgramData%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup",
132           "%USERPROFILE%\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup",
133           "C:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup"
134           )
135'''
136
137
138[[rule.threat]]
139framework = "MITRE ATT&CK"
140[[rule.threat.technique]]
141id = "T1547"
142name = "Boot or Logon Autostart Execution"
143reference = "https://attack.mitre.org/techniques/T1547/"
144[[rule.threat.technique.subtechnique]]
145id = "T1547.001"
146name = "Registry Run Keys / Startup Folder"
147reference = "https://attack.mitre.org/techniques/T1547/001/"
148
149
150
151[rule.threat.tactic]
152id = "TA0003"
153name = "Persistence"
154reference = "https://attack.mitre.org/tactics/TA0003/"
155[[rule.threat]]
156framework = "MITRE ATT&CK"
157[[rule.threat.technique]]
158id = "T1112"
159name = "Modify Registry"
160reference = "https://attack.mitre.org/techniques/T1112/"
161
162
163[rule.threat.tactic]
164id = "TA0005"
165name = "Defense Evasion"
166reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Suspicious Startup Shell Folder Modification

Techniques used within malware and by adversaries often leverage the Windows registry to store malicious programs for persistence. Startup shell folders are often targeted as they are not as prevalent as normal Startup folder paths so this behavior may evade existing AV/EDR solutions. These programs may also run with higher privileges which can be ideal for an attacker.

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.
  • Review the source process and related file tied to the Windows Registry entry.
  • 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.

False positive analysis

  • There is a high possibility of benign legitimate programs being added to shell folders. This activity could be based on new software installations, patches, or other network administrator activity. Before undertaking further investigation, it should be verified that this activity is not benign.
  • Startup or Run Key Registry Modification - 97fc44d3-8dae-4019-ae83-298c3015600f
  • Persistent Scripts in the Startup Directory - f7c4dc5a-a58d-491d-9f14-9b66507121c0

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.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
  • If the malicious file was delivered via phishing:
    • Block the email sender from sending future emails.
    • Block the malicious web pages.
    • Remove emails from the sender from mailboxes.
    • Consider improvements to the security awareness program.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • 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

to-top