Detect Extra Window Memory Injection in Splunk
Adversaries may inject malicious code into process via Extra Window Memory (EWM) in order to evade process-based defenses as well as possibly elevate privileges. EWM injection is a method of executing arbitrary code in the address space of a separate live process. Before creating a window, graphical Windows-based processes must prescribe to or register a windows class, which stipulate appearance and behavior via windows procedures. Registration of new windows classes can include a request for up to 40 bytes of EWM. Although small, the EWM is large enough to store a 32-bit pointer and is often used to point to a windows procedure. Malware may utilize this memory location in part of an attack chain that includes writing code to shared sections of the process's memory, placing a pointer to the code in EWM, then invoking execution by returning execution control to the address in the process's EWM.
MITRE ATT&CK
- Technique
- T1055 Process Injection
- Sub-technique
- T1055.011 Extra Window Memory Injection
- Canonical reference
- https://attack.mitre.org/techniques/T1055/011/
SPL Detection Query
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=10
TargetImage="*\\explorer.exe"
| where GrantedAccess IN ("0x1FFFFF", "0x001F0FFF", "0x1F3FFF", "0x0020", "0x1F1FFF")
| rename SourceImage as EWMInjector, TargetImage as Target
| search NOT EWMInjector IN ("*\\explorer.exe", "*\\csrss.exe", "*\\dwm.exe", "*\\winlogon.exe", "*\\ShellExperienceHost.exe", "*\\SearchUI.exe", "*\\taskhostw.exe", "*\\sihost.exe")
| eval InjectorName=mvindex(split(EWMInjector, "\\"), -1)
| eval EWMIndicator=case(
GrantedAccess="0x1FFFFF", "Critical - PROCESS_ALL_ACCESS to explorer.exe",
GrantedAccess="0x001F0FFF", "High - Full process rights to explorer.exe",
match(GrantedAccess, "0x0020"), "Medium - PROCESS_VM_WRITE to explorer.exe",
1=1, "Medium - Suspicious access rights"
)
| table _time, host, User, EWMInjector, Target, GrantedAccess, EWMIndicator
| sort - _time Detects potential EWM injection by monitoring Sysmon Event ID 10 (ProcessAccess) for cross-process access to explorer.exe with write capabilities from non-system processes. EWM injection requires writing to explorer.exe's shared memory sections and modifying the Shell_TrayWnd window's extra window memory. The GrantedAccess masks indicating write capability to explorer.exe are strong EWM injection indicators.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Shell extensions accessing explorer.exe for integration
- Taskbar customization tools
- Accessibility tools modifying window properties
- Windows Feature Experience Pack updates accessing explorer.exe
Other platforms for T1055.011
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.
- Test 1Enumerate Shell_TrayWnd Window Handle
Expected signal: Sysmon Event ID 1: PowerShell execution with FindWindowW in command line. API call to FindWindowW with class name Shell_TrayWnd logged by ETW if user32.dll API tracing is enabled.
- Test 2GetWindowLong Extra Memory Read
Expected signal: Sysmon Event ID 1: PowerShell execution with GetWindowLongPtrW. ETW: user32.dll API calls for FindWindowW and GetWindowLongPtrW.
- Test 3Cross-Process Memory Write to Explorer
Expected signal: Sysmon Event ID 1: PowerShell execution. If actual OpenProcess with write rights is called: Sysmon Event ID 10 (ProcessAccess) from PowerShell to explorer.exe with PROCESS_VM_WRITE.
References (5)
- https://attack.mitre.org/techniques/T1055/011/
- https://www.malwaretech.com/2013/08/powerloader-injection-something-truly.html
- https://www.welivesecurity.com/2013/03/19/gapz-and-redyms-droppers-based-on-power-loader-code/
- https://www.endgame.com/blog/technical-blog/ten-process-injection-techniques-technical-survey-common-and-trending-process
- https://msdn.microsoft.com/library/windows/desktop/ms633591.aspx
Unlock Pro Content
Get the full detection package for T1055.011 including response playbook, investigation guide, and atomic red team tests.