Detect Portable Executable Injection in Google Chronicle
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.
MITRE ATT&CK
- Technique
- T1055 Process Injection
- Sub-technique
- T1055.002 Portable Executable Injection
- Canonical reference
- https://attack.mitre.org/techniques/T1055/002/
YARA-L Detection Query
rule pe_injection_create_remote_thread_no_module {
meta:
author = "Detection Engineering"
description = "Detects PE injection via Sysmon CreateRemoteThread (Event 8) with no StartModule, indicating direct code injection into a remote process"
mitre_attack_tactic = "Defense Evasion, Privilege Escalation"
mitre_attack_technique = "T1055.002"
severity = "CRITICAL"
confidence = "HIGH"
reference = "https://attack.mitre.org/techniques/T1055/002/"
events:
$e.metadata.product_event_type = "8"
re.regex($e.metadata.product_name, `(?i)sysmon`)
not re.regex($e.principal.process.file.full_path,
`(?i)(MsMpEng|csrss|services|svchost|lsass|wmiprvse)\.exe$`)
$e.about.labels["StartModule"] = ""
condition:
$e
} Chronicle YARA-L 2.0 rule detecting PE injection via Sysmon CreateRemoteThread events (product_event_type=8) where the StartModule UDM label is empty. principal.process.file.full_path maps to Sysmon SourceImage. The about.labels["StartModule"] field relies on Chronicle's Sysmon parser populating non-standard Sysmon fields into the UDM labels collection; verify field mapping with your Chronicle ingestion configuration and adjust if StartModule is mapped to a different UDM path.
Data Sources
Required Tables
False Positives & Tuning
- Security vendor EDR components that perform injection-based API hooking may generate CreateRemoteThread events with an empty StartModule when Chronicle's parser does not capture the module reference
- Virtualization platform guest tools (VMware Tools, Hyper-V Integration Services) creating threads in host process space may lack a StartModule label after UDM normalization
- Some software updater and hot-patching frameworks that create threads in running processes without a DLL path may trigger this rule legitimately
Other platforms for T1055.002
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 1PE Injection via PowerShell with VirtualAllocEx and WriteProcessMemory
Expected signal: Sysmon Event ID 1: notepad.exe spawned by PowerShell. If full API chain used: Sysmon Event ID 10 (ProcessAccess) from PowerShell to notepad.exe with PROCESS_VM_WRITE rights. Sysmon Event ID 8 if CreateRemoteThread is called.
- Test 2Shellcode Injection via Donut Framework
Expected signal: When using the full Donut injection: Sysmon Event ID 8 (CreateRemoteThread) with empty StartModule. Sysmon Event ID 10 (ProcessAccess) with PROCESS_ALL_ACCESS. No corresponding Sysmon Event ID 7 (ImageLoad) in the target process.
- Test 3Process Injection using C# System.Diagnostics APIs
Expected signal: Sysmon Event ID 1: csc.exe spawned by PowerShell (compilation). Sysmon Event ID 11: pe_inject_test.exe created in TEMP. Sysmon Event ID 1: pe_inject_test.exe execution. Sysmon Event ID 1: notepad.exe spawned by pe_inject_test.exe.
References (5)
- https://attack.mitre.org/techniques/T1055/002/
- https://www.endgame.com/blog/technical-blog/ten-process-injection-techniques-technical-survey-common-and-trending-process
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1055.002/T1055.002.md
- https://github.com/TheWover/donut
- https://www.elastic.co/blog/ten-process-injection-techniques-technical-survey-common-and-trending-process
Unlock Pro Content
Get the full detection package for T1055.002 including response playbook, investigation guide, and atomic red team tests.