T1218.013 Microsoft Sentinel · KQL

Detect Mavinject in Microsoft Sentinel

Adversaries may abuse mavinject.exe to proxy execution of malicious code. Mavinject.exe is the Microsoft Application Virtualization Injector, a Windows utility that can inject code into external processes as part of Microsoft Application Virtualization (App-V). Adversaries abuse it to inject malicious DLLs into running processes (DLL injection) using the /INJECTRUNNING flag. Since mavinject.exe is a signed Microsoft binary, it can bypass application control. TONESHELL malware has been observed using mavinject.exe for process injection.

MITRE ATT&CK

Tactic
Defense Evasion
Technique
T1218 System Binary Proxy Execution
Sub-technique
T1218.013 Mavinject
Canonical reference
https://attack.mitre.org/techniques/T1218/013/

KQL Detection Query

Microsoft Sentinel (KQL)
kusto
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "mavinject.exe"
| extend InjectRunning = ProcessCommandLine has "/INJECTRUNNING"
| extend TargetPID = ProcessCommandLine matches regex @"/INJECTRUNNING \d+"
| extend SuspiciousPath = ProcessCommandLine has_any ("Temp", "AppData", "Downloads", "Public", "Desktop")
| extend SuspiciousParent = InitiatingProcessFileName has_any ("cmd.exe", "powershell.exe", "wscript.exe", "cscript.exe", "mshta.exe", "winword.exe", "excel.exe")
| project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName,
         InitiatingProcessCommandLine, InjectRunning, SuspiciousPath, SuspiciousParent
| sort by Timestamp desc
high severity high confidence

Detects mavinject.exe abuse focused on the /INJECTRUNNING flag used to inject DLLs into running processes. Also detects DLL injection from user-writable paths and suspicious parent processes. Mavinject.exe has very limited legitimate use outside of App-V environments — any execution with /INJECTRUNNING and a non-App-V DLL path is highly suspicious.

Data Sources

Process: Process CreationCommand: Command ExecutionMicrosoft Defender for Endpoint

Required Tables

DeviceProcessEvents

False Positives & Tuning

  • Microsoft Application Virtualization (App-V) environments where mavinject.exe is used legitimately for virtualized application management
  • App-V client infrastructure invoking mavinject.exe as part of normal application publishing and streaming workflows
  • Enterprise App-V deployments where IT administrators use mavinject.exe for application compatibility management
  • Microsoft App-V testing and development environments
Download portable Sigma rule (.yml)

Other platforms for T1218.013


Testing Methodology

Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Mavinject DLL Injection into Running Process

    Expected signal: Sysmon Event ID 1: mavinject.exe with /INJECTRUNNING and a PID in command line. Sysmon Event ID 8 (CreateRemoteThread) from notepad.exe. Sysmon Event ID 7 (Image Load) on notepad.exe for the injected DLL. Security Event ID 4688.

  2. Test 2Mavinject from PowerShell Parent

    Expected signal: Sysmon Event ID 1: powershell.exe then mavinject.exe with ParentImage=powershell.exe and /INJECTRUNNING in command line. SuspiciousParent and InjectRunning both fire.

  3. Test 3Mavinject with DLL from Temp Directory

    Expected signal: Sysmon Event ID 11: DLL written to Temp. Sysmon Event ID 1: mavinject.exe with /INJECTRUNNING and Temp path. The injection will fail (PID 4 is SYSTEM) but the process creation and file creation events fire.

Unlock Pro Content

Get the full detection package for T1218.013 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections