Detect Native API in Sumo Logic CSE
Adversaries may interact with the native OS application programming interface (API) to execute behaviors. Native APIs provide a controlled means of calling low-level OS services within the kernel, such as those involving hardware/devices, memory, and processes. Adversaries abuse these APIs to execute code while bypassing higher-level defensive sensors, AMSI, and user-mode API hooks. Common attack patterns include: direct syscall invocation (bypassing ntdll.dll hooks entirely), process injection via NT memory APIs (NtAllocateVirtualMemory, NtWriteVirtualMemory, NtCreateThreadEx, RtlCreateUserThread), API unhooking by re-mapping a clean copy of ntdll.dll from disk, and spawning processes via NtCreateProcess or NtCreateProcessEx rather than the standard Win32 CreateProcess. Real-world actors including Cobalt Strike, Medusa Group, and tools like SysWhispers leverage direct syscalls specifically to evade EDR user-mode hooks.
MITRE ATT&CK
- Tactic
- Execution
- Technique
- T1106 Native API
- Canonical reference
- https://attack.mitre.org/techniques/T1106/
Sumo Detection Query
/* T1106 — Native API: process injection and ntdll unhooking
Adjust _sourceCategory to match your Sysmon collection path */
_sourceCategory=windows/sysmon OR _sourceCategory=*sysmon*
| parse "<EventID>*</EventID>" as EventID
| where EventID in ("7", "8", "10")
| parse "<SourceImage>*</SourceImage>" as SourceImage nodrop
| parse "<TargetImage>*</TargetImage>" as TargetImage nodrop
| parse "<ImageLoaded>*</ImageLoaded>" as ImageLoaded nodrop
| parse "<GrantedAccess>*</GrantedAccess>" as GrantedAccess nodrop
| parse "<User>*</User>" as UserAccount nodrop
| parse "<Computer>*</Computer>" as Computer nodrop
| parse "<SourceCommandLine>*</SourceCommandLine>" as SourceCommandLine nodrop
| eval SourceLower = toLowerCase(SourceImage)
| eval TargetLower = toLowerCase(TargetImage)
| eval ImageLoadedLower = toLowerCase(ImageLoaded)
| eval HighRiskSource = if(
SourceLower matches "*(winword|excel|powerpnt|outlook|mshta|wscript|cscript|regsvr32|rundll32|msiexec).exe",
true, false)
| eval ProtectedTarget = if(
TargetLower matches "*(lsass|csrss|winlogon|smss|wininit).exe",
true, false)
| eval TrustedSecurity = if(
SourceLower matches "*(msmpeng|senseir|sensecnc|kavtray|bdservicehost|cylancesvc|cb).exe",
true, false)
| eval IsNtdllUnhook = if(
EventID = "7"
AND ImageLoadedLower matches "*ntdll.dll"
AND !(ImageLoadedLower matches "*(system32|syswow64|winsxs)*ntdll.dll"),
true, false)
| where
(EventID = "8" AND (HighRiskSource OR (ProtectedTarget AND !TrustedSecurity)))
OR (EventID = "10" AND (ProtectedTarget OR HighRiskSource))
OR IsNtdllUnhook = true
| eval Signal = if(EventID = "8", "CreateRemoteThread_Injection",
if(EventID = "10", "ProcessAccess_InjectionRights",
"NtdllUnhook_EDRBypass"))
| eval RiskScore = if(EventID = "8" AND HighRiskSource AND ProtectedTarget, 100,
if(IsNtdllUnhook = true, 90,
if(ProtectedTarget, 80, 60)))
| table _time, Computer, UserAccount, Signal, RiskScore, EventID,
SourceImage, TargetImage, GrantedAccess, ImageLoaded, SourceCommandLine
| sort by RiskScore, _time desc Detects T1106 Native API abuse in Sumo Logic by parsing Sysmon XML fields from forwarded Windows events. Classifies three signals: CreateRemoteThread (EID 8) from high-risk parent processes or into protected system processes; ProcessAccess (EID 10) with injection-relevant access rights targeting sensitive processes; and ntdll.dll loaded outside System32/SysWOW64/WinSxS directories (EID 7), indicating the clean-copy remap EDR bypass. Assigns a 0-100 risk score: 100 for Office→LSASS injection, 90 for ntdll unhooking, 80 for protected-target access, 60 for high-risk source injection. Adjust _sourceCategory to match your Sysmon data collection path.
Data Sources
Required Tables
False Positives & Tuning
- Security orchestration and SOAR platforms that open process handles to running agents for health checks or remediation workflows
- Windows Defender Credential Guard and virtualization-based security features that legitimately map system DLLs from isolated VSM memory regions outside standard paths
- Sysinternals tools (Process Explorer, ProcMon, ProcDump) that open handles to system processes — add exclusions based on Computer/path context for admin workstations
Other platforms for T1106
Testing Methodology
Validate this detection against 4 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 1NtAllocateVirtualMemory Direct Call via PowerShell P/Invoke
Expected signal: Sysmon Event ID 1: Process Create for powershell.exe with CommandLine containing 'NtAllocateVirtualMemory'. MDE DeviceEvents: NtAllocateVirtualMemoryApiCall ActionType from the powershell.exe process. PowerShell ScriptBlock Log Event ID 4104: full script content including the DllImport declaration and the API call.
- Test 2Process Injection via NtCreateRemoteThread (C# Executable)
Expected signal: Sysmon Event ID 8 (CreateRemoteThread): SourceImage=powershell.exe, TargetImage=notepad.exe, StartAddress pointing to null (suspended thread with null entry point). Sysmon Event ID 10 (ProcessAccess): SourceImage=powershell.exe, TargetImage=notepad.exe, GrantedAccess=0x1F0FFF. MDE DeviceEvents: CreateRemoteThreadApiCall with InitiatingProcessFileName=powershell.exe.
- Test 3API Unhooking — Remap ntdll.dll from Disk
Expected signal: Sysmon Event ID 7 (ImageLoad): The ntdll.dll module is already loaded, but if the unhooking completed (in a real attack), a second load from a temp path would appear. PowerShell ScriptBlock Log Event ID 4104: full script showing ntdll.dll path access and byte comparison. MDE DeviceFileEvents: ReadFile operation on C:\Windows\System32\ntdll.dll from powershell.exe.
- Test 4Direct Syscall Execution via Inline Assembly (SysWhispers2-style)
Expected signal: If compiled: Sysmon Event ID 1 (Process Create) for syscall_test.exe; Sysmon Event ID 11 (File Create) for the .exe in %TEMP%; MDE DeviceFileEvents for the VirtualAlloc RWX allocation. The byte pattern 4C 8B D1 B8 xx 00 00 00 0F 05 C3 in the allocated memory region is the direct syscall stub signature. If not compiled: PowerShell ScriptBlock Event ID 4104 captures the stub bytes for signature validation.
References (13)
- https://attack.mitre.org/techniques/T1106/
- https://outflank.nl/blog/2019/06/19/red-team-tactics-combining-direct-system-calls-and-srdi-to-bypass-av-edr/
- https://redops.at/en/blog/direct-syscalls-vs-indirect-syscalls
- https://www.cyberbit.com/blog/endpoint-security/malware-mitigation-when-direct-system-calls-are-used/
- https://www.mdsec.co.uk/2020/12/bypassing-user-mode-hooks-and-direct-invocation-of-system-calls-for-red-teams/
- https://github.com/jthuraisamy/SysWhispers2
- https://github.com/klezVirus/SysWhispers3
- https://undocumented.ntinternals.net/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1106/T1106.md
- https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createremotethread
- https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon
- https://docs.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
- https://security.stackexchange.com/questions/270586/direct-system-calls-detection-edr
Unlock Pro Content
Get the full detection package for T1106 including response playbook, investigation guide, and atomic red team tests.