T1574.013

KernelCallbackTable

Adversaries abuse the KernelCallbackTable in the Process Environment Block (PEB) to hijack execution flow and execute shellcode within a target process. The KernelCallbackTable is initialized when user32.dll is loaded into a GUI process, containing function pointers for handling Win32 messages. An adversary uses NtQueryInformationProcess() to locate the PEB, reads the KernelCallbackTable pointer, duplicates the table in new process memory via WriteProcessMemory(), replaces a function pointer (e.g., fnCOPYDATA) with shellcode address, then updates the PEB to point to the modified table. Sending a Windows message (e.g., WM_COPYDATA) to the target triggers the shellcode. Used by Lazarus Group (DPRK) and FinFisher/FinSpy. Execution is masked under a legitimate GUI process.

Microsoft Sentinel / Defender
kusto
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("NtQueryInformationProcess", "ntdll.dll")
    or ProcessCommandLine has_any ("VirtualAllocEx", "WriteProcessMemory", "NtWriteVirtualMemory")
| join kind=inner (
    DeviceProcessEvents
    | where Timestamp > ago(24h)
    | where InitiatingProcessFileName in~ ("explorer.exe", "notepad.exe", "calc.exe", "mspaint.exe")
    | where not(FolderPath startswith "C:\\Windows\\System32")
    | project DeviceName, ParentProcessId=ProcessId, ParentFileName=FileName, ParentPath=FolderPath
) on DeviceName
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
         ParentFileName, ParentPath
| sort by Timestamp desc
| union (
    DeviceEvents
    | where Timestamp > ago(24h)
    | where ActionType == "ProcessInjection" or ActionType == "RemoteThreadInjection"
    | where TargetProcessFileName in~ ("explorer.exe", "notepad.exe", "iexplore.exe", "chrome.exe", "firefox.exe")
    | project Timestamp, DeviceName, AccountName=InitiatingProcessAccountName,
             InitiatingProcessFileName, TargetProcessFileName, ActionType
)
| sort by Timestamp desc
critical severity low confidence

Data Sources

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

Required Tables

DeviceProcessEvents DeviceEvents

False Positives

  • Legitimate accessibility software (screen readers, magnifiers) that interact with other process memory for UI automation
  • Debug builds of applications that legitimately use WriteProcessMemory for inter-process communication
  • Virtualization and container tools that may access process memory for management purposes
  • Some game anti-cheat systems that inject DLLs into game processes

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections