T1106 Elastic Security · Elastic

Detect Native API in Elastic Security

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/

Elastic Detection Query

Elastic Security (Elastic)
eql
/* T1106 — Native API: process injection and ntdll unhooking
   Requires Sysmon 13+ via Elastic Agent or Winlogbeat (windows.sysmon_operational) */
any where event.dataset == "windows.sysmon_operational" and
(
  /* EID 8: CreateRemoteThread — high-risk initiator or injection into protected process */
  (
    event.code == "8" and
    (
      regex(winlog.event_data.SourceImage,
        "(?i)(winword|excel|powerpnt|outlook|mshta|wscript|cscript|regsvr32|rundll32|msiexec).exe$")
      or (
        regex(winlog.event_data.TargetImage,
          "(?i)(lsass|csrss|winlogon|smss|wininit).exe$") and
        not regex(winlog.event_data.SourceImage,
          "(?i)(MsMpEng|SenseIR|SenseCnC|kavtray|bdservicehost|CylanceSvc|cb).exe$")
      )
    )
  )
  /* EID 10: ProcessAccess with injection-grade access rights */
  or (
    event.code == "10" and
    (
      regex(winlog.event_data.TargetImage,
        "(?i)(lsass|csrss|winlogon).exe$")
      or regex(winlog.event_data.SourceImage,
        "(?i)(winword|excel|powerpnt|mshta|wscript|cscript|rundll32|regsvr32).exe$")
    ) and
    winlog.event_data.GrantedAccess like~ ("0x1f*", "0x143a", "0x1438", "0x14*")
  )
  /* EID 7: ntdll.dll loaded from non-standard path — EDR hook bypass via clean-copy mapping */
  or (
    event.code == "7" and
    regex(winlog.event_data.ImageLoaded, "(?i)ntdll.dll$") and
    not (
      winlog.event_data.ImageLoaded like~ "*System32*ntdll.dll" or
      winlog.event_data.ImageLoaded like~ "*SysWOW64*ntdll.dll" or
      winlog.event_data.ImageLoaded like~ "*WinSxS*ntdll.dll"
    )
  )
)
high severity high confidence

Detects T1106 Native API abuse via three Sysmon signals: (1) CreateRemoteThread (EID 8) from high-risk Office or scripting processes, or targeting protected system processes like lsass/csrss/winlogon; (2) ProcessAccess (EID 10) with PROCESS_ALL_ACCESS or injection-enabling access masks against sensitive targets; (3) ntdll.dll image load (EID 7) from outside System32/SysWOW64/WinSxS, indicating the clean-copy remap technique used by SysWhispers and similar EDR bypass tooling. Requires Sysmon 13+ deployed via Elastic Agent Windows Integration or Winlogbeat.

Data Sources

Windows Sysmon 13+Elastic Agent Windows IntegrationWinlogbeat

Required Tables

logs-windows.sysmon_operational-*

False Positives & Tuning

  • EDR and AV agents (MsMpEng.exe, SenseIR.exe, CylanceSvc.exe) legitimately use cross-process memory APIs for scanning and real-time protection — exclude by principal process path or add to the TrustedSecurity exclusion list
  • Debuggers such as WinDbg, x64dbg, and OllyDbg use CreateRemoteThread and ProcessAccess with high-privilege masks as part of normal debugging workflows
  • Game anti-cheat systems (BattlEye, Easy Anti-Cheat) inject shim DLLs into game processes using the same injection primitives detected here
Download portable Sigma rule (.yml)

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections