Suspicious Antimalware Scan Interface DLL
Identifies the creation of the Antimalware Scan Interface (AMSI) DLL in an unusual location. This may indicate an attempt to bypass AMSI by loading a rogue AMSI module instead of the legit one.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/01/17"
3integration = ["windows", "endpoint", "sentinel_one_cloud_funnel", "m365_defender"]
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 the creation of the Antimalware Scan Interface (AMSI) DLL in an unusual location. This may indicate an
37attempt to bypass AMSI by loading a rogue AMSI module instead of the legit one.
38"""
39from = "now-9m"
40index = [
41 "winlogbeat-*",
42 "logs-endpoint.events.file-*",
43 "logs-windows.sysmon_operational-*",
44 "endgame-*",
45 "logs-sentinel_one_cloud_funnel.*",
46 "logs-m365_defender.event-*",
47]
48language = "eql"
49license = "Elastic License v2"
50name = "Suspicious Antimalware Scan Interface DLL"
51note = """## Triage and analysis
52
53### Investigating Suspicious Antimalware Scan Interface DLL
54
55The Windows Antimalware Scan Interface (AMSI) is a versatile interface standard that allows your applications and services to integrate with any antimalware product on a machine. AMSI integrates with multiple Windows components, ranging from User Account Control (UAC) to VBA macros and PowerShell.
56
57Attackers might copy a rogue AMSI DLL to an unusual location to prevent the process from loading the legitimate module, achieving a bypass to execute malicious code.
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- Identify the process that created the DLL and which account was used.
65- 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.
66- Investigate other alerts associated with the user/host during the past 48 hours.
67- Investigate the execution of scripts and macros after the registry modification.
68- Investigate other processes launched from the directory that the DLL was created.
69- Inspect the host for suspicious or abnormal behavior in the alert timeframe:
70 - Observe and collect information about the following activities in 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
81### False positive analysis
82
83- This modification should not happen legitimately. Any potential benign true positive (B-TP) should be mapped and monitored by the security team as these modifications expose the host to malware infections.
84
85### Response and remediation
86
87- Initiate the incident response process based on the outcome of the triage.
88- Isolate the involved hosts to prevent further post-compromise behavior.
89- If the triage identified malware, search the environment for additional compromised hosts.
90 - Implement temporary network rules, procedures, and segmentation to contain the malware.
91 - Stop suspicious processes.
92 - Immediately block the identified indicators of compromise (IoCs).
93 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
94- Remove and block malicious artifacts identified during triage.
95- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
96- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
97- 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).
98"""
99references = ["https://github.com/S3cur3Th1sSh1t/Amsi-Bypass-Powershell"]
100risk_score = 73
101rule_id = "fa488440-04cc-41d7-9279-539387bf2a17"
102severity = "high"
103tags = [
104 "Domain: Endpoint",
105 "OS: Windows",
106 "Use Case: Threat Detection",
107 "Tactic: Defense Evasion",
108 "Data Source: Elastic Endgame",
109 "Resources: Investigation Guide",
110 "Data Source: Elastic Defend",
111 "Data Source: Sysmon",
112 "Data Source: SentinelOne",
113 "Data Source: Microsoft Defender for Endpoint",
114]
115timestamp_override = "event.ingested"
116type = "eql"
117
118query = '''
119file where host.os.type == "windows" and event.type != "deletion" and file.path != null and
120 file.name : ("amsi.dll", "amsi") and
121 not file.path : (
122 "?:\\$SysReset\\CloudImage\\Package_for_RollupFix*",
123 "?:\\Windows\\system32\\amsi.dll",
124 "?:\\Windows\\Syswow64\\amsi.dll",
125 "?:\\$WINDOWS.~BT\\DUImageSandbox\\*",
126 "?:\\$WINDOWS.~BT\\NewOS\\Windows\\WinSXS\\*",
127 "?:\\$WINDOWS.~BT\\NewOS\\Windows\\servicing\\LCU\\*",
128 "?:\\$WINDOWS.~BT\\Work\\*\\*",
129 "?:\\$WINDOWS.~BT\\Store\\Offline\\File\\C$\\Windows\\SoftwareDistribution\\Download.bak\\*",
130 "?:\\Windows\\CbsTemp\\*\\f\\amsi.dll",
131 "?:\\Windows\\SoftwareDistribution\\Download\\*",
132 "?:\\Windows\\WinSxS\\amd64_microsoft-antimalware-scan-interface_*\\amsi.dll"
133 ) and
134 not
135 (
136 process.executable : "C:\\Windows\\System32\\wbengine.exe" and
137 file.path : (
138 "\\Device\\HarddiskVolume??\\Windows\\system32\\amsi.dll",
139 "\\Device\\HarddiskVolume??\\Windows\\syswow64\\amsi.dll",
140 "\\Device\\HarddiskVolume??\\Windows\\WinSxS\\*\\amsi.dll",
141 "\\\\?\\Volume{*}\\Windows\\WinSxS\\*\\amsi.dll",
142 "\\\\?\\Volume{*}\\Windows\\system32\\amsi.dll",
143 "\\\\?\\Volume{*}\\Windows\\syswow64\\amsi.dll"
144 )
145 )
146'''
147
148
149[[rule.threat]]
150framework = "MITRE ATT&CK"
151[[rule.threat.technique]]
152id = "T1562"
153name = "Impair Defenses"
154reference = "https://attack.mitre.org/techniques/T1562/"
155[[rule.threat.technique.subtechnique]]
156id = "T1562.001"
157name = "Disable or Modify Tools"
158reference = "https://attack.mitre.org/techniques/T1562/001/"
159
160
161[[rule.threat.technique]]
162id = "T1574"
163name = "Hijack Execution Flow"
164reference = "https://attack.mitre.org/techniques/T1574/"
165[[rule.threat.technique.subtechnique]]
166id = "T1574.001"
167name = "DLL Search Order Hijacking"
168reference = "https://attack.mitre.org/techniques/T1574/001/"
169
170
171
172[rule.threat.tactic]
173id = "TA0005"
174name = "Defense Evasion"
175reference = "https://attack.mitre.org/tactics/TA0005/"
Triage and analysis
Investigating Suspicious Antimalware Scan Interface DLL
The Windows Antimalware Scan Interface (AMSI) is a versatile interface standard that allows your applications and services to integrate with any antimalware product on a machine. AMSI integrates with multiple Windows components, ranging from User Account Control (UAC) to VBA macros and PowerShell.
Attackers might copy a rogue AMSI DLL to an unusual location to prevent the process from loading the legitimate module, achieving a bypass to execute malicious code.
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
- Identify the process that created the DLL and which account was used.
- 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.
- Investigate the execution of scripts and macros after the registry modification.
- Investigate other processes launched from the directory that the DLL was created.
- Inspect the host for suspicious or abnormal behavior in the alert timeframe:
- Observe and collect information about the following activities in 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.
- Observe and collect information about the following activities in the alert subject host:
False positive analysis
- This modification should not happen legitimately. Any potential benign true positive (B-TP) should be mapped and monitored by the security team as these modifications expose the host to malware infections.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved hosts 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.
- 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
- Adding Hidden File Attribute via Attrib
- Alternate Data Stream Creation/Execution at Volume Root Directory
- Attempt to Install Kali Linux via WSL
- Bypass UAC via Event Viewer
- Clearing Windows Console History