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"
5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
6min_stack_version = "8.3.0"
7updated_date = "2023/06/22"
8
9[rule]
10author = ["Elastic"]
11description = """
12Identifies the loading of a non Microsoft signed DLL that is missing on a default Windows install (phantom DLL) or one
13that can be loaded from a different location by a native Windows process. This may be abused to persist or elevate
14privileges via privileged file write vulnerabilities.
15"""
16from = "now-9m"
17index = ["winlogbeat-*", "logs-endpoint.events.*", "logs-windows.*", "endgame-*"]
18language = "eql"
19license = "Elastic License v2"
20name = "Suspicious DLL Loaded for Persistence or Privilege Escalation"
21note = """## Triage and analysis
22
23### Investigating Suspicious DLL Loaded for Persistence or Privilege Escalation
24
25Attackers 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.
26
27#### Possible investigation steps
28
29- Examine the DLL signature and identify the process that created it.
30 - Investigate any abnormal behaviors by the process such as network connections, registry or file modifications, and any spawned child processes.
31- Investigate other alerts associated with the user/host during the past 48 hours.
32- Retrieve the DLL and determine if it is malicious:
33 - Use a private sandboxed malware analysis system to perform analysis.
34 - Observe and collect information about the following activities:
35 - Attempts to contact external domains and addresses.
36 - File and registry access, modification, and creation activities.
37 - Service creation and launch activities.
38 - Scheduled task creation.
39 - Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
40 - Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
41
42### False positive analysis
43
44- 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.
45
46### Response and remediation
47
48- Initiate the incident response process based on the outcome of the triage.
49- Isolate the involved host to prevent further post-compromise behavior.
50- If the triage identified malware, search the environment for additional compromised hosts.
51 - Implement temporary network rules, procedures, and segmentation to contain the malware.
52 - Stop suspicious processes.
53 - Immediately block the identified indicators of compromise (IoCs).
54 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
55- Remove and block malicious artifacts identified during triage.
56- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
57- 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.
58- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
59- 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).
60
61## Setup
62
63If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2, events will not define `event.ingested` and default fallback for EQL rules was not added until 8.2, so you will need to add a custom pipeline to populate `event.ingested` to @timestamp for this rule to work.
64"""
65references = [
66 "https://itm4n.github.io/windows-dll-hijacking-clarified/",
67 "http://remoteawesomethoughts.blogspot.com/2019/05/windows-10-task-schedulerservice.html",
68 "https://googleprojectzero.blogspot.com/2018/04/windows-exploitation-tricks-exploiting.html",
69 "https://shellz.club/2020/10/16/edgegdi-dll-for-persistence-and-lateral-movement.html",
70 "https://windows-internals.com/faxing-your-way-to-system/",
71 "http://waleedassar.blogspot.com/2013/01/wow64logdll.html",
72]
73risk_score = 73
74rule_id = "bfeaf89b-a2a7-48a3-817f-e41829dc61ee"
75severity = "high"
76tags = [
77 "Domain: Endpoint",
78 "OS: Windows",
79 "Use Case: Threat Detection",
80 "Tactic: Persistence",
81 "Tactic: Privilege Escalation",
82 "Resources: Investigation Guide",
83 "Data Source: Elastic Endgame",
84 "Data Source: Elastic Defend"
85]
86timestamp_override = "event.ingested"
87type = "eql"
88
89query = '''
90any where host.os.type == "windows" and
91 (event.category : ("driver", "library") or (event.category == "process" and event.action : "Image loaded*")) and
92 (
93 /* compatible with Elastic Endpoint Library Events */
94 (dll.name : ("wlbsctrl.dll", "wbemcomn.dll", "WptsExtensions.dll", "Tsmsisrv.dll", "TSVIPSrv.dll", "Msfte.dll",
95 "wow64log.dll", "WindowsCoreDeviceInfo.dll", "Ualapi.dll", "wlanhlp.dll", "phoneinfo.dll", "EdgeGdi.dll",
96 "cdpsgshims.dll", "windowsperformancerecordercontrol.dll", "diagtrack_win.dll", "oci.dll", "TPPCOIPW32.dll",
97 "tpgenlic.dll", "thinmon.dll", "fxsst.dll", "msTracer.dll")
98 and (dll.code_signature.trusted != true or dll.code_signature.exists != true)) or
99
100 /* compatible with Sysmon EventID 7 - Image Load */
101 (file.name : ("wlbsctrl.dll", "wbemcomn.dll", "WptsExtensions.dll", "Tsmsisrv.dll", "TSVIPSrv.dll", "Msfte.dll",
102 "wow64log.dll", "WindowsCoreDeviceInfo.dll", "Ualapi.dll", "wlanhlp.dll", "phoneinfo.dll", "EdgeGdi.dll",
103 "cdpsgshims.dll", "windowsperformancerecordercontrol.dll", "diagtrack_win.dll", "oci.dll", "TPPCOIPW32.dll",
104 "tpgenlic.dll", "thinmon.dll", "fxsst.dll", "msTracer.dll") and
105 not file.path : ("?:\\Windows\\System32\\wbemcomn.dll", "?:\\Windows\\SysWOW64\\wbemcomn.dll") and
106 not file.hash.sha256 :
107 ("6e837794fc282446906c36d681958f2f6212043fc117c716936920be166a700f",
108 "b14e4954e8cca060ffeb57f2458b6a3a39c7d2f27e94391cbcea5387652f21a4",
109 "c258d90acd006fa109dc6b748008edbb196d6168bc75ace0de0de54a4db46662") and
110 not file.code_signature.status == "Valid")
111 )
112'''
113
114
115[[rule.threat]]
116framework = "MITRE ATT&CK"
117[[rule.threat.technique]]
118id = "T1574"
119name = "Hijack Execution Flow"
120reference = "https://attack.mitre.org/techniques/T1574/"
121[[rule.threat.technique.subtechnique]]
122id = "T1574.002"
123name = "DLL Side-Loading"
124reference = "https://attack.mitre.org/techniques/T1574/002/"
125
126
127
128[rule.threat.tactic]
129id = "TA0004"
130name = "Privilege Escalation"
131reference = "https://attack.mitre.org/tactics/TA0004/"
132[[rule.threat]]
133framework = "MITRE ATT&CK"
134[[rule.threat.technique]]
135id = "T1574"
136name = "Hijack Execution Flow"
137reference = "https://attack.mitre.org/techniques/T1574/"
138[[rule.threat.technique.subtechnique]]
139id = "T1574.001"
140name = "DLL Search Order Hijacking"
141reference = "https://attack.mitre.org/techniques/T1574/001/"
142
143
144
145[rule.threat.tactic]
146id = "TA0003"
147name = "Persistence"
148reference = "https://attack.mitre.org/tactics/TA0003/"
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.
- Observe and collect information about the following activities:
- 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.
- Use a private sandboxed malware analysis system to perform analysis.
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).
Setup
If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2, events will not define event.ingested
and default fallback for EQL rules was not added until 8.2, so you will need to add a custom pipeline to populate event.ingested
to @timestamp for this rule to work.
References
Related rules
- Adobe Hijack Persistence
- Bypass UAC via Event Viewer
- Component Object Model Hijacking
- Creation of a Hidden Local User Account
- Disabling User Account Control via Registry Modification