T1055.004

Asynchronous Procedure Call

Adversaries may inject malicious code into processes via the asynchronous procedure call (APC) queue in order to evade process-based defenses as well as possibly elevate privileges. APC injection is commonly performed by attaching malicious code to the APC Queue of a process's thread. Queued APC functions are executed when the thread enters an alterable state. A handle to an existing victim process is first created with native Windows API calls such as OpenThread. At this point QueueUserAPC can be used to invoke a function (such as LoadLibraryA pointing to a malicious DLL). A variation called Early Bird injection involves creating a suspended process in which malicious code is written and executed before the process' entry point via an APC. AtomBombing is another variation that utilizes APCs to invoke malicious code previously written to the global atom table.

Microsoft Sentinel / Defender
kusto
// Detect APC injection: suspended process creation followed by remote thread/APC execution
// Early Bird pattern: CreateProcess(SUSPENDED) -> WriteProcessMemory -> QueueUserAPC -> ResumeThread
let SuspiciousParents = dynamic(["powershell.exe", "cmd.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe"]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine == "" or ProcessCommandLine == FileName
| where InitiatingProcessFileName in~ (SuspiciousParents)
| where FileName in~ ("svchost.exe", "rundll32.exe", "EhStorAuthn.exe", "ctfmon.exe", "conhost.exe", "dllhost.exe")
| join kind=leftouter (
    DeviceEvents
    | where Timestamp > ago(24h)
    | where ActionType == "CreateRemoteThreadApiCall"
    | project ThreadTime=Timestamp, DeviceName, TargetProcessId=ProcessId, InjectorProcess=InitiatingProcessFileName
) on DeviceName, $left.ProcessId == $right.TargetProcessId
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, InitiatingProcessCommandLine, FileName, ProcessId, InjectorProcess
| sort by Timestamp desc
critical severity high confidence

Data Sources

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

Required Tables

DeviceProcessEvents DeviceEvents

False Positives

  • Legitimate COM object activation spawning dllhost.exe with minimal command lines
  • Service Control Manager spawning svchost.exe instances
  • Windows Update creating suspended processes for staged updates
  • Application installers spawning helper processes in suspended state for configuration

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections