Suspicious DLL Loaded for Persistence or Privilege Escalation

Identifies the loading of a non Microsoft signed DLL that is missing on a default Windows install (phantom DLL) or one that can be loaded from a different location by a native Windows process. This may be abused to persist or elevate privileges via privileged file write vulnerabilities.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/01/07"
  3integration = ["endpoint", "windows"]
  4maturity = "production"
  5updated_date = "2024/07/11"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies the loading of a non Microsoft signed DLL that is missing on a default Windows install (phantom DLL) or one
 11that can be loaded from a different location by a native Windows process. This may be abused to persist or elevate
 12privileges via privileged file write vulnerabilities.
 13"""
 14from = "now-9m"
 15index = ["winlogbeat-*", "logs-endpoint.events.library*", "logs-windows.sysmon_operational-*", "endgame-*"]
 16language = "eql"
 17license = "Elastic License v2"
 18name = "Suspicious DLL Loaded for Persistence or Privilege Escalation"
 19note = """## Triage and analysis
 20
 21### Investigating Suspicious DLL Loaded for Persistence or Privilege Escalation
 22
 23Attackers can execute malicious code by abusing missing modules that processes try to load, enabling them to escalate privileges or gain persistence. This rule identifies the loading of a non-Microsoft-signed DLL that is missing on a default Windows installation or one that can be loaded from a different location by a native Windows process.
 24
 25#### Possible investigation steps
 26
 27- Examine the DLL signature and identify the process that created it.
 28  - Investigate any abnormal behaviors by the process such as network connections, registry or file modifications, and any spawned child processes.
 29- Investigate other alerts associated with the user/host during the past 48 hours.
 30- Retrieve the DLL and determine if it is malicious:
 31  - Use a private sandboxed malware analysis system to perform analysis.
 32    - Observe and collect information about the following activities:
 33      - Attempts to contact external domains and addresses.
 34      - File and registry access, modification, and creation activities.
 35      - Service creation and launch activities.
 36      - Scheduled task creation.
 37  - Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
 38    - Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 39
 40### False positive analysis
 41
 42- This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.
 43
 44### Response and remediation
 45
 46- Initiate the incident response process based on the outcome of the triage.
 47- Isolate the involved host to prevent further post-compromise behavior.
 48- If the triage identified malware, search the environment for additional compromised hosts.
 49  - Implement temporary network rules, procedures, and segmentation to contain the malware.
 50  - Stop suspicious processes.
 51  - Immediately block the identified indicators of compromise (IoCs).
 52  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
 53- Remove and block malicious artifacts identified during triage.
 54- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 55- 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.
 56- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 57- 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).
 58"""
 59references = [
 60    "https://itm4n.github.io/windows-dll-hijacking-clarified/",
 61    "http://remoteawesomethoughts.blogspot.com/2019/05/windows-10-task-schedulerservice.html",
 62    "https://googleprojectzero.blogspot.com/2018/04/windows-exploitation-tricks-exploiting.html",
 63    "https://shellz.club/2020/10/16/edgegdi-dll-for-persistence-and-lateral-movement.html",
 64    "https://windows-internals.com/faxing-your-way-to-system/",
 65    "http://waleedassar.blogspot.com/2013/01/wow64logdll.html",
 66]
 67risk_score = 73
 68rule_id = "bfeaf89b-a2a7-48a3-817f-e41829dc61ee"
 69setup = """## Setup
 70
 71If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 72events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 73Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 74`event.ingested` to @timestamp.
 75For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 76"""
 77severity = "high"
 78tags = [
 79    "Domain: Endpoint",
 80    "OS: Windows",
 81    "Use Case: Threat Detection",
 82    "Tactic: Persistence",
 83    "Tactic: Privilege Escalation",
 84    "Tactic: Defense Evasion",
 85    "Resources: Investigation Guide",
 86    "Data Source: Elastic Endgame",
 87    "Data Source: Elastic Defend",
 88    "Data Source: Sysmon",
 89]
 90timestamp_override = "event.ingested"
 91type = "eql"
 92
 93query = '''
 94any where host.os.type == "windows" and
 95(event.category : ("driver", "library") or (event.category == "process" and event.action : "Image loaded*")) and
 96(
 97  /* compatible with Elastic Endpoint Library Events */
 98  (
 99    ?dll.name : (
100        "wlbsctrl.dll", "wbemcomn.dll", "WptsExtensions.dll", "Tsmsisrv.dll", "TSVIPSrv.dll", "Msfte.dll",
101        "wow64log.dll", "WindowsCoreDeviceInfo.dll", "Ualapi.dll", "wlanhlp.dll", "phoneinfo.dll", "EdgeGdi.dll",
102        "cdpsgshims.dll", "windowsperformancerecordercontrol.dll", "diagtrack_win.dll", "oci.dll", "TPPCOIPW32.dll", 
103        "tpgenlic.dll", "thinmon.dll", "fxsst.dll", "msTracer.dll"
104    )
105    and (
106      ?dll.code_signature.trusted != true or
107      ?dll.code_signature.exists != true or
108      (
109        dll.code_signature.trusted == true and
110          not dll.code_signature.subject_name : ("Microsoft Windows", "Microsoft Corporation", "Microsoft Windows Publisher")
111      )
112  ) or
113
114  /* compatible with Sysmon EventID 7 - Image Load */
115  (file.name : ("wlbsctrl.dll", "wbemcomn.dll", "WptsExtensions.dll", "Tsmsisrv.dll", "TSVIPSrv.dll", "Msfte.dll",
116               "wow64log.dll", "WindowsCoreDeviceInfo.dll", "Ualapi.dll", "wlanhlp.dll", "phoneinfo.dll", "EdgeGdi.dll",
117               "cdpsgshims.dll", "windowsperformancerecordercontrol.dll", "diagtrack_win.dll", "oci.dll", "TPPCOIPW32.dll", 
118               "tpgenlic.dll", "thinmon.dll", "fxsst.dll", "msTracer.dll") and 
119   not file.hash.sha256 : 
120            ("6e837794fc282446906c36d681958f2f6212043fc117c716936920be166a700f", 
121             "b14e4954e8cca060ffeb57f2458b6a3a39c7d2f27e94391cbcea5387652f21a4", 
122             "c258d90acd006fa109dc6b748008edbb196d6168bc75ace0de0de54a4db46662") and 
123   not file.code_signature.status == "Valid")
124  ) and
125  not
126  (
127    ?dll.path : (
128      "?:\\Windows\\System32\\wbemcomn.dll",
129      "?:\\Windows\\SysWOW64\\wbemcomn.dll",
130      "?:\\Windows\\System32\\windowsperformancerecordercontrol.dll",
131      "?:\\Windows\\System32\\wlanhlp.dll"
132    ) or
133    file.path : (
134      "?:\\Windows\\System32\\wbemcomn.dll",
135      "?:\\Windows\\SysWOW64\\wbemcomn.dll",
136      "?:\\Windows\\System32\\windowsperformancerecordercontrol.dll",
137      "?:\\Windows\\System32\\wlanhlp.dll"
138    )
139  )
140)
141'''
142
143
144[[rule.threat]]
145framework = "MITRE ATT&CK"
146[[rule.threat.technique]]
147id = "T1574"
148name = "Hijack Execution Flow"
149reference = "https://attack.mitre.org/techniques/T1574/"
150[[rule.threat.technique.subtechnique]]
151id = "T1574.002"
152name = "DLL Side-Loading"
153reference = "https://attack.mitre.org/techniques/T1574/002/"
154
155
156
157[rule.threat.tactic]
158id = "TA0004"
159name = "Privilege Escalation"
160reference = "https://attack.mitre.org/tactics/TA0004/"
161[[rule.threat]]
162framework = "MITRE ATT&CK"
163[[rule.threat.technique]]
164id = "T1574"
165name = "Hijack Execution Flow"
166reference = "https://attack.mitre.org/techniques/T1574/"
167[[rule.threat.technique.subtechnique]]
168id = "T1574.001"
169name = "DLL Search Order Hijacking"
170reference = "https://attack.mitre.org/techniques/T1574/001/"
171
172
173
174[rule.threat.tactic]
175id = "TA0003"
176name = "Persistence"
177reference = "https://attack.mitre.org/tactics/TA0003/"
178[[rule.threat]]
179framework = "MITRE ATT&CK"
180[[rule.threat.technique]]
181id = "T1036"
182name = "Masquerading"
183reference = "https://attack.mitre.org/techniques/T1036/"
184[[rule.threat.technique.subtechnique]]
185id = "T1036.001"
186name = "Invalid Code Signature"
187reference = "https://attack.mitre.org/techniques/T1036/001/"
188
189
190
191[rule.threat.tactic]
192id = "TA0005"
193name = "Defense Evasion"
194reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Suspicious DLL Loaded for Persistence or Privilege Escalation

Attackers can execute malicious code by abusing missing modules that processes try to load, enabling them to escalate privileges or gain persistence. This rule identifies the loading of a non-Microsoft-signed DLL that is missing on a default Windows installation or one that can be loaded from a different location by a native Windows process.

Possible investigation steps

  • Examine the DLL signature and identify the process that created it.
    • Investigate any abnormal behaviors by the process such as network connections, registry or file modifications, and any spawned child processes.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Retrieve the DLL and determine if it is 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.
        • File and registry access, modification, and creation activities.
        • Service creation and launch activities.
        • Scheduled task creation.
    • Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
      • Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.

False positive analysis

  • This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.

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.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • 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.
  • 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