Extra Window Memory Injection
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.
// Detect EWM injection via suspicious API calls targeting Shell_TrayWnd
// EWM injection targets Explorer's Shell_TrayWnd window class
DeviceEvents
| where Timestamp > ago(24h)
| where ActionType in ("SetWindowLongApiCall", "SendMessageApiCall", "CreateRemoteThreadApiCall")
| where FileName =~ "explorer.exe"
| where InitiatingProcessFileName !in~ ("explorer.exe", "csrss.exe", "dwm.exe", "winlogon.exe", "ShellExperienceHost.exe", "SearchUI.exe")
| project Timestamp, DeviceName, AccountName, ActionType, InitiatingProcessFileName, InitiatingProcessCommandLine, FileName
| sort by Timestamp desc
// Fallback: detect via ProcessAccess to explorer.exe with write rights
| union (
DeviceEvents
| where Timestamp > ago(24h)
| where ActionType == "ProcessAccessedApiCall"
| where FileName =~ "explorer.exe"
| where InitiatingProcessFileName !in~ ("explorer.exe", "csrss.exe", "dwm.exe", "winlogon.exe", "taskhost.exe", "taskhostw.exe", "ShellExperienceHost.exe")
)
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Shell extensions and explorer plugins that legitimately modify Shell_TrayWnd properties
- Taskbar customization tools (StartAllBack, Start11) modifying Shell_TrayWnd EWM
- Accessibility tools that modify window properties for screen reading
- System tray management applications interacting with Shell_TrayWnd
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.