T1055.002

Portable Executable Injection

Adversaries may inject portable executables (PE) into processes in order to evade process-based defenses as well as possibly elevate privileges. PE injection is commonly performed by copying code (perhaps without a file on disk) into the virtual address space of the target process before invoking it via a new thread. The write can be performed with native Windows API calls such as VirtualAllocEx and WriteProcessMemory, then invoked with CreateRemoteThread or additional code (ex: shellcode). Unlike DLL injection, PE injection copies the entire executable image into the target process rather than loading a DLL via LoadLibrary. The displacement of the injected code introduces the additional requirement for functionality to remap memory references.

Microsoft Sentinel / Defender
kusto
// Detect PE injection via cross-process memory allocation and thread creation
// Focus on processes that allocate RWX memory in remote processes
DeviceEvents
| where Timestamp > ago(24h)
| where ActionType == "CreateRemoteThreadApiCall"
| where InitiatingProcessFileName !in~ ("MsMpEng.exe", "csrss.exe", "services.exe", "svchost.exe", "lsass.exe", "wmiprvse.exe")
| join kind=leftouter (
    DeviceImageLoadEvents
    | where Timestamp > ago(24h)
    | project LoadTime=Timestamp, DeviceName, ProcessId=InitiatingProcessId, LoadedModule=FileName
) on DeviceName, $left.ProcessId == $right.ProcessId
| where isempty(LoadedModule) or LoadedModule == ""
| extend InjectionType = "PE Injection (no DLL load - direct code injection)"
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, InitiatingProcessCommandLine, FileName, ProcessCommandLine, InjectionType
| sort by Timestamp desc
high severity medium confidence

Data Sources

Process: OS API Execution Process: Process Access Microsoft Defender for Endpoint

Required Tables

DeviceEvents DeviceImageLoadEvents

False Positives

  • EDR agents performing shellcode-based process monitoring and hooking
  • .NET CLR hosting injecting managed code into processes without DLL load events
  • Game anti-cheat software (EasyAntiCheat, BattlEye) injecting protection code into game processes
  • Software update agents injecting hotpatch code into running processes

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections