Suspicious Microsoft Antimalware Service Execution

Identifies suspicious execution of the Microsoft Antimalware Service Executable (MsMpEng.exe) from non-standard paths or renamed instances. This may indicate an attempt to evade defenses through DLL side-loading or by masquerading as the antimalware process.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2021/07/07"
  3integration = ["endpoint", "windows", "m365_defender", "crowdstrike"]
  4maturity = "production"
  5updated_date = "2026/04/29"
  6
  7[rule]
  8author = ["Elastic", "Dennis Perto"]
  9description = """
 10Identifies suspicious execution of the Microsoft Antimalware Service Executable (MsMpEng.exe) from non-standard paths or
 11renamed instances. This may indicate an attempt to evade defenses through DLL side-loading or by masquerading as the
 12antimalware process.
 13"""
 14false_positives = ["Microsoft Antimalware Service Executable installed on non default installation path."]
 15from = "now-9m"
 16index = [
 17    "winlogbeat-*",
 18    "logs-endpoint.events.process-*",
 19    "logs-windows.sysmon_operational-*",
 20    "endgame-*",
 21    "logs-m365_defender.event-*",
 22    "logs-crowdstrike.fdr*",
 23]
 24language = "eql"
 25license = "Elastic License v2"
 26name = "Suspicious Microsoft Antimalware Service Execution"
 27references = [
 28    "https://news.sophos.com/en-us/2021/07/04/independence-day-revil-uses-supply-chain-exploit-to-attack-hundreds-of-businesses/",
 29]
 30risk_score = 73
 31rule_id = "053a0387-f3b5-4ba5-8245-8002cca2bd08"
 32severity = "high"
 33tags = [
 34    "Domain: Endpoint",
 35    "OS: Windows",
 36    "Use Case: Threat Detection",
 37    "Tactic: Defense Evasion",
 38    "Data Source: Elastic Endgame",
 39    "Data Source: Elastic Defend",
 40    "Data Source: Sysmon",
 41    "Data Source: Microsoft Defender XDR",
 42    "Data Source: Crowdstrike",
 43    "Resources: Investigation Guide",
 44]
 45timestamp_override = "event.ingested"
 46type = "eql"
 47
 48query = '''
 49process where host.os.type == "windows" and event.type == "start" and
 50(
 51  (process.pe.original_file_name == "MsMpEng.exe" and not process.name : "MsMpEng.exe") or
 52  (
 53    process.name : "MsMpEng.exe" and
 54    not process.executable : (
 55            "?:\\ProgramData\\Microsoft\\Windows Defender\\*.exe",
 56            "?:\\Program Files\\Windows Defender\\*.exe",
 57            "?:\\Program Files (x86)\\Windows Defender\\*.exe",
 58            "?:\\Program Files\\Microsoft Security Client\\*.exe",
 59            "?:\\Program Files (x86)\\Microsoft Security Client\\*.exe",
 60
 61            /* Crowdstrike specific exclusion as it uses NT Object paths */
 62            "\\Device\\HarddiskVolume*\\ProgramData\\Microsoft\\Windows Defender\\*.exe",
 63            "\\Device\\HarddiskVolume*\\Program Files\\Windows Defender\\*.exe",
 64            "\\Device\\HarddiskVolume*\\Program Files (x86)\\Windows Defender\\*.exe",
 65            "\\Device\\HarddiskVolume*\\Program Files\\Microsoft Security Client\\*.exe",
 66            "\\Device\\HarddiskVolume*\\Program Files (x86)\\Microsoft Security Client\\*.exe"
 67    )
 68  )
 69)
 70'''
 71
 72note = """## Triage and analysis
 73
 74### Investigating Suspicious Microsoft Antimalware Service Execution
 75
 76#### Possible investigation steps
 77
 78- Which Defender identity anomaly did the alert capture?
 79  - Focus: `process.name`, `process.pe.original_file_name`, `process.executable`, `process.code_signature.subject_name`, and `process.code_signature.trusted`.
 80  - Implication: escalate when `process.pe.original_file_name` is "MsMpEng.exe" under renamed `process.name`, or `process.name` is "MsMpEng.exe" outside Defender/Microsoft Security Client paths, even with trusted Microsoft signing; lower suspicion only when exact path, signer, and name pattern fit controlled packaging, recovery, or malware-analysis copy.
 81- Does the path, file timing, and parent context look like staged Defender abuse?
 82  - Why: unusual-path Defender binaries can load same-folder DLLs through search-order behavior, so path and parent context separate masquerading or side-loading from controlled copies.
 83  - Focus: `process.executable`, `process.Ext.relative_file_creation_time`, `process.Ext.relative_file_name_modify_time`, `process.parent.executable`, and `process.parent.command_line`.
 84  - Implication: escalate when the binary is fresh, recently renamed, or launched from user-writable, temp, share, archive, agent working, or Windows staging paths by a script, archive tool, RMM agent, or dropper parent; path age and parent context support benign closure only if later side-loading and launcher checks do not contradict them.
 85- Does the user, token, and session context fit Defender service execution?
 86  - Focus: `user.id`, `user.name`, `process.Ext.session_info.logon_type`, and `process.Ext.token.integrity_level_name`.
 87  - Implication: escalate when the process runs under an interactive/domain user, a non-service logon, or a user-level token that does not fit antimalware service startup; SYSTEM or service context lowers only the session concern and does not clear the unusual path by itself.
 88- If file or library telemetry is available, is there same-directory staging or DLL side-loading evidence?
 89  - Focus: recover file and library events with `host.id` plus `process.entity_id` when present, or `host.id` plus `process.pid` and a tight alert window; inspect `file.path`, `dll.path`, `dll.name`, `dll.code_signature.trusted`, and `dll.Ext.relative_file_creation_time`. $investigate_0
 90  - Hint: missing file or library telemetry is unresolved, not benign; prioritize same-folder DLLs whose path, signer, or creation time does not fit the product layout, plus artifacts created before `process.executable` started.
 91  - Implication: escalate when the unusual Defender copy loads a recent, unsigned/untrusted same-folder DLL or the directory contains newly staged executables, DLLs, scripts, archives, or renamed files; complete recovery with only expected Microsoft components lowers side-loading concern.
 92- Does the process act as a launcher rather than a passive service component?
 93  - Focus: child process events where `process.parent.entity_id` matches suspicious `process.entity_id`, repeated starts from `process.executable` on `host.id`, and child `process.name`, `process.executable`, and `process.command_line`.
 94    - $investigate_1
 95    - $investigate_2
 96  - Implication: escalate when it starts shells, PowerShell, certutil, netsh, installers, encryption tooling, or other hands-on-keyboard utilities, or when repeated launches suggest staged execution; no child or repeat behavior lowers launcher concern but does not clear the path anomaly.
 97- If local findings stay suspicious or unresolved, do related alerts show path reuse or host compromise?
 98  - Focus: related alerts for `process.executable`, especially unusual-path Defender, masquerading, or side-loading detections.
 99    - $investigate_3
100  - Hint: also review related alerts for `host.id` or `user.id`, especially staging, persistence, credential-access, ransomware, or other masquerading detections.
101    - $investigate_4
102    - $investigate_5
103  - Implication: broaden scope when the same path appears on unrelated hosts or the host has precursor or follow-on alerts; keep the case local only when related alerts show no reuse or follow-on activity and all local evidence is clean.
104
105- Escalate when Defender identity/path evidence plus one meaningful corroborator supports masquerading or DLL side-loading; close only when exact path, signer, parent, session, host/user scope, and optional outside confirmation tie to one controlled workflow with no contradictory telemetry; preserve artifacts and escalate when findings stay mixed or visibility is incomplete.
106
107### False positive analysis
108
109- A non-default Defender installation, controlled security packaging, recovery, or malware-analysis validation can stage Microsoft antimalware binaries outside default paths. Confirm the same workflow by matching exact `process.executable`, `process.hash.sha256` or `process.code_signature.thumbprint_sha256`, Microsoft `process.code_signature.subject_name`, `process.code_signature.trusted`, `process.parent.executable`, `process.parent.command_line`, `user.id`, `host.id`, and session pattern; without outside records, require recurrence across prior rule alerts without side-loading, launcher, or related-alert contradictions.
110- Treat production execution from temp, user-writable, share, archive, agent working, or Windows staging paths as an operational anti-pattern unless a controlled workflow proves why the copy exists. Do not close as benign when same-folder DLLs, child tooling, recent rename timing, or unrelated related alerts contradict it.
111- Build exceptions only from the minimum confirmed workflow pattern; avoid exceptions on `process.name`, `process.pe.original_file_name`, signer subject alone, or host alone.
112
113### Response and remediation
114
115- If confirmed benign, reverse any temporary containment and document the exact workflow: executable path, Microsoft signer or hash, parent process, session context, user/host scope, and any controlled packaging, recovery, or lab record that corroborated the telemetry. Create an exception only after the same narrow workflow pattern is stable across prior alerts.
116- If suspicious but unconfirmed, preserve the alert details, process tree, command line, binary copy and hash, parent context, directory listing, same-folder DLLs, and related-alert timeline before containment. Apply reversible containment first, such as execution prevention on the suspicious path or temporary host isolation when active launcher behavior or side-loading creates continuing risk and the host role can tolerate interruption.
117- If confirmed malicious, preserve process and artifact evidence first, including the suspicious Defender copy, same-folder DLLs, support files, launcher context, and related-alert timeline. Then isolate the host or apply an equivalent endpoint containment control, terminate only the suspicious non-default-path or renamed Defender instance, quarantine the suspicious executable and supporting files, remove launcher or persistence artifacts found during scoping, and restore the legitimate security product from known-good media if the masquerading copy replaced or shadowed a trusted component.
118- After containment, restrict execution from user-writable, temporary, share, archive, and agent working directories where feasible, retain process/file/library telemetry that affected this case, and document the confirmed benign workflow or malicious artifact set for future triage.
119"""
120
121setup = """## Setup
122
123This rule is designed for data generated by [Elastic Defend](https://www.elastic.co/security/endpoint-security), which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules.
124
125Setup instructions: https://ela.st/install-elastic-defend
126
127### Additional data sources
128
129This rule also supports the following third-party data sources. For setup instructions, refer to the links below:
130
131- [CrowdStrike](https://ela.st/crowdstrike-integration)
132- [Microsoft Defender XDR](https://ela.st/m365-defender)
133- [Sysmon Event ID 1 - Process Creation](https://ela.st/sysmon-event-1-setup)
134"""
135
136[rule.investigation_fields]
137field_names = [
138    "@timestamp",
139    "host.name",
140    "host.id",
141    "user.name",
142    "user.id",
143    "process.entity_id",
144    "process.pid",
145    "process.name",
146    "process.executable",
147    "process.command_line",
148    "process.pe.original_file_name",
149    "process.parent.executable",
150    "process.parent.command_line",
151    "process.code_signature.subject_name",
152    "process.code_signature.trusted",
153]
154
155[transform]
156
157[[transform.investigate]]
158label = "File and library events for the suspicious process"
159description = ""
160providers = [
161  [
162    { excluded = false, field = "host.id", queryType = "phrase", value = "{{host.id}}", valueType = "string" },
163    { excluded = false, field = "process.entity_id", queryType = "phrase", value = "{{process.entity_id}}", valueType = "string" },
164    { excluded = false, field = "event.category", queryType = "phrase", value = "file", valueType = "string" }
165  ],
166  [
167    { excluded = false, field = "host.id", queryType = "phrase", value = "{{host.id}}", valueType = "string" },
168    { excluded = false, field = "process.entity_id", queryType = "phrase", value = "{{process.entity_id}}", valueType = "string" },
169    { excluded = false, field = "event.category", queryType = "phrase", value = "library", valueType = "string" }
170  ]
171]
172relativeFrom = "now-1h"
173relativeTo = "now"
174
175[[transform.investigate]]
176label = "Child process events for the suspicious process"
177description = ""
178providers = [
179  [
180    { excluded = false, field = "host.id", queryType = "phrase", value = "{{host.id}}", valueType = "string" },
181    { excluded = false, field = "process.parent.entity_id", queryType = "phrase", value = "{{process.entity_id}}", valueType = "string" },
182    { excluded = false, field = "event.category", queryType = "phrase", value = "process", valueType = "string" }
183  ]
184]
185relativeFrom = "now-1h"
186relativeTo = "now"
187
188[[transform.investigate]]
189label = "Process events for the suspicious executable path"
190description = ""
191providers = [
192  [
193    { excluded = false, field = "host.id", queryType = "phrase", value = "{{host.id}}", valueType = "string" },
194    { excluded = false, field = "process.executable", queryType = "phrase", value = "{{process.executable}}", valueType = "string" },
195    { excluded = false, field = "event.category", queryType = "phrase", value = "process", valueType = "string" }
196  ]
197]
198relativeFrom = "now-48h/h"
199relativeTo = "now"
200
201[[transform.investigate]]
202label = "Alerts associated with the suspicious executable path"
203description = ""
204providers = [
205  [
206    { excluded = false, field = "event.kind", queryType = "phrase", value = "signal", valueType = "string" },
207    { excluded = false, field = "process.executable", queryType = "phrase", value = "{{process.executable}}", valueType = "string" }
208  ]
209]
210relativeFrom = "now-48h/h"
211relativeTo = "now"
212
213[[transform.investigate]]
214label = "Alerts associated with the host"
215description = ""
216providers = [
217  [
218    { excluded = false, field = "event.kind", queryType = "phrase", value = "signal", valueType = "string" },
219    { excluded = false, field = "host.id", queryType = "phrase", value = "{{host.id}}", valueType = "string" }
220  ]
221]
222relativeFrom = "now-48h/h"
223relativeTo = "now"
224
225[[transform.investigate]]
226label = "Alerts associated with the user"
227description = ""
228providers = [
229  [
230    { excluded = false, field = "event.kind", queryType = "phrase", value = "signal", valueType = "string" },
231    { excluded = false, field = "user.id", queryType = "phrase", value = "{{user.id}}", valueType = "string" }
232  ]
233]
234relativeFrom = "now-48h/h"
235relativeTo = "now"
236
237[[rule.threat]]
238framework = "MITRE ATT&CK"
239
240[[rule.threat.technique]]
241id = "T1036"
242name = "Masquerading"
243reference = "https://attack.mitre.org/techniques/T1036/"
244
245[[rule.threat.technique.subtechnique]]
246id = "T1036.003"
247name = "Rename Legitimate Utilities"
248reference = "https://attack.mitre.org/techniques/T1036/003/"
249
250[[rule.threat.technique.subtechnique]]
251id = "T1036.005"
252name = "Match Legitimate Resource Name or Location"
253reference = "https://attack.mitre.org/techniques/T1036/005/"
254
255[[rule.threat.technique]]
256id = "T1574"
257name = "Hijack Execution Flow"
258reference = "https://attack.mitre.org/techniques/T1574/"
259
260[[rule.threat.technique.subtechnique]]
261id = "T1574.001"
262name = "DLL"
263reference = "https://attack.mitre.org/techniques/T1574/001/"
264
265[rule.threat.tactic]
266id = "TA0005"
267name = "Defense Evasion"
268reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Suspicious Microsoft Antimalware Service Execution

Possible investigation steps

  • Which Defender identity anomaly did the alert capture?

    • Focus: process.name, process.pe.original_file_name, process.executable, process.code_signature.subject_name, and process.code_signature.trusted.
    • Implication: escalate when process.pe.original_file_name is "MsMpEng.exe" under renamed process.name, or process.name is "MsMpEng.exe" outside Defender/Microsoft Security Client paths, even with trusted Microsoft signing; lower suspicion only when exact path, signer, and name pattern fit controlled packaging, recovery, or malware-analysis copy.
  • Does the path, file timing, and parent context look like staged Defender abuse?

    • Why: unusual-path Defender binaries can load same-folder DLLs through search-order behavior, so path and parent context separate masquerading or side-loading from controlled copies.
    • Focus: process.executable, process.Ext.relative_file_creation_time, process.Ext.relative_file_name_modify_time, process.parent.executable, and process.parent.command_line.
    • Implication: escalate when the binary is fresh, recently renamed, or launched from user-writable, temp, share, archive, agent working, or Windows staging paths by a script, archive tool, RMM agent, or dropper parent; path age and parent context support benign closure only if later side-loading and launcher checks do not contradict them.
  • Does the user, token, and session context fit Defender service execution?

    • Focus: user.id, user.name, process.Ext.session_info.logon_type, and process.Ext.token.integrity_level_name.
    • Implication: escalate when the process runs under an interactive/domain user, a non-service logon, or a user-level token that does not fit antimalware service startup; SYSTEM or service context lowers only the session concern and does not clear the unusual path by itself.
  • If file or library telemetry is available, is there same-directory staging or DLL side-loading evidence?

    • Focus: recover file and library events with host.id plus process.entity_id when present, or host.id plus process.pid and a tight alert window; inspect file.path, dll.path, dll.name, dll.code_signature.trusted, and dll.Ext.relative_file_creation_time. $investigate_0
    • Hint: missing file or library telemetry is unresolved, not benign; prioritize same-folder DLLs whose path, signer, or creation time does not fit the product layout, plus artifacts created before process.executable started.
    • Implication: escalate when the unusual Defender copy loads a recent, unsigned/untrusted same-folder DLL or the directory contains newly staged executables, DLLs, scripts, archives, or renamed files; complete recovery with only expected Microsoft components lowers side-loading concern.
  • Does the process act as a launcher rather than a passive service component?

    • Focus: child process events where process.parent.entity_id matches suspicious process.entity_id, repeated starts from process.executable on host.id, and child process.name, process.executable, and process.command_line.
      • $investigate_1
      • $investigate_2
    • Implication: escalate when it starts shells, PowerShell, certutil, netsh, installers, encryption tooling, or other hands-on-keyboard utilities, or when repeated launches suggest staged execution; no child or repeat behavior lowers launcher concern but does not clear the path anomaly.
  • If local findings stay suspicious or unresolved, do related alerts show path reuse or host compromise?

    • Focus: related alerts for process.executable, especially unusual-path Defender, masquerading, or side-loading detections.
      • $investigate_3
    • Hint: also review related alerts for host.id or user.id, especially staging, persistence, credential-access, ransomware, or other masquerading detections.
      • $investigate_4
      • $investigate_5
    • Implication: broaden scope when the same path appears on unrelated hosts or the host has precursor or follow-on alerts; keep the case local only when related alerts show no reuse or follow-on activity and all local evidence is clean.
  • Escalate when Defender identity/path evidence plus one meaningful corroborator supports masquerading or DLL side-loading; close only when exact path, signer, parent, session, host/user scope, and optional outside confirmation tie to one controlled workflow with no contradictory telemetry; preserve artifacts and escalate when findings stay mixed or visibility is incomplete.

False positive analysis

  • A non-default Defender installation, controlled security packaging, recovery, or malware-analysis validation can stage Microsoft antimalware binaries outside default paths. Confirm the same workflow by matching exact process.executable, process.hash.sha256 or process.code_signature.thumbprint_sha256, Microsoft process.code_signature.subject_name, process.code_signature.trusted, process.parent.executable, process.parent.command_line, user.id, host.id, and session pattern; without outside records, require recurrence across prior rule alerts without side-loading, launcher, or related-alert contradictions.
  • Treat production execution from temp, user-writable, share, archive, agent working, or Windows staging paths as an operational anti-pattern unless a controlled workflow proves why the copy exists. Do not close as benign when same-folder DLLs, child tooling, recent rename timing, or unrelated related alerts contradict it.
  • Build exceptions only from the minimum confirmed workflow pattern; avoid exceptions on process.name, process.pe.original_file_name, signer subject alone, or host alone.

Response and remediation

  • If confirmed benign, reverse any temporary containment and document the exact workflow: executable path, Microsoft signer or hash, parent process, session context, user/host scope, and any controlled packaging, recovery, or lab record that corroborated the telemetry. Create an exception only after the same narrow workflow pattern is stable across prior alerts.
  • If suspicious but unconfirmed, preserve the alert details, process tree, command line, binary copy and hash, parent context, directory listing, same-folder DLLs, and related-alert timeline before containment. Apply reversible containment first, such as execution prevention on the suspicious path or temporary host isolation when active launcher behavior or side-loading creates continuing risk and the host role can tolerate interruption.
  • If confirmed malicious, preserve process and artifact evidence first, including the suspicious Defender copy, same-folder DLLs, support files, launcher context, and related-alert timeline. Then isolate the host or apply an equivalent endpoint containment control, terminate only the suspicious non-default-path or renamed Defender instance, quarantine the suspicious executable and supporting files, remove launcher or persistence artifacts found during scoping, and restore the legitimate security product from known-good media if the masquerading copy replaced or shadowed a trusted component.
  • After containment, restrict execution from user-writable, temporary, share, archive, and agent working directories where feasible, retain process/file/library telemetry that affected this case, and document the confirmed benign workflow or malicious artifact set for future triage.

References

Related rules

to-top