Detection rules › Elastic

Image Load via Synthetic Stack Spoofing

Source
github.com/elastic/protections-artifacts

Detects attempts to load a networking module from a potentially altered call stack in order to conceal the true source of the call.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Detects attempts to load a networking module from a potentially altered call stack in order to conceal the true source
of the call.
"""
id = "d8c57cb7-bab6-41fa-9063-dcc8793c3955"
license = "Elastic License v2"
name = "Image Load via Synthetic Stack Spoofing"
os_list = ["windows"]
reference = ["https://www.elastic.co/security-labs/doubling-down-etw-callstacks"]
version = "1.0.27"

query = '''
library where
dll.name : ("wininet.dll", "ws2_32.dll", "dnsapi.dll", "winhttp.dll", "clr.dll", "netapi32.dll",
                "mscorwks.dll", "System.*.dll", "mscorlib*.dll", "Microsoft.PowerShell.Security*.dll",
                "Microsoft.PowerShell.ConsoleHost*.dll", "wmiutils.dll", "fastprox.dll", "wbemprox.dll",
                "vaultcli.dll", "taskschd.dll", "dsquery.dll", "mstscax.dll", "ntdll.dll", "wldap32.dll",
                "wtsapi32.dll", "psapi.dll") and
process.thread.Ext.call_stack_summary like "ntdll.dll|kernel32.dll*" and
 
  /* JMP gadget in kernel32 */
  _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info regex~ """.*system32\\kernel32.dll!(A|[C-Z]).+""") and
  _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info : "?:\\Windows\\System32\\ntdll.dll!LdrLoadDll*") and
   not process.thread.Ext.call_stack_summary like "ntdll.dll|kernel32.dll|mso40uiwin32client.dll|mso98win32client.dll|mso.dll|*" and
   not  _arraysearch(process.thread.Ext.call_stack, $entry, 
                   $entry.symbol_info : ("*kernel32.dll!CreateProcess*", "*kernel32.dll!GetDateFormatWWorker*", 
                                         "*kernel32.dll!WerpLaunchAeDebug*", "*kernel32.dll!BaseDllReadWriteIniFile*", 
                                         "*kernel32.dll!GlobalReAlloc*", "*kernel32.dll!CreateToolhelp32Snapshot*", 
                                         "*kernel32.dll!Wow64SetThreadContext*", "*kernel32.dll!ExitProcess*", "*kernel32.dll!WinExec*",
                                         "*kernel32.dll!CallbackMayRunLong*", "*kernel32.dll!BaseGenerateAppCompatData*", 
                                         "*mpclient.dll!MpUpdateServicePingRpc*", "*chrome.exe!IsSandboxedProcess*",
                                         "*kernel32.dll!CreateActCtxWWorker*", "*kernel32.dll!Sleep*",
                                         "*kernel32.dll!BasepCheckAppCompat*", "*kernel32.dll!AddAtomW*",
                                         "*\\kernel32.dll!lstrlenW*", "*\\kernel32.dll!FindActCtxSectionGuidWorker*",
                                         "*\\kernel32.dll!OpenPrivateNamespaceW*", "*\\kernel32.dll!DeactivateActCtxWorke*",
                                         "c:\\windows\\system32\\kernel32.dll!QuirkIsEnabled3Worker*",
                                         "C:\\Windows\\System32\\kernel32.dll!GetQueuedCompletionStatus*",
                                         "*\\ntdll.dll!RtlFormatMessageEx*", "*kernel32.dll!GetQueuedCompletionStatus*"))
'''

min_endpoint_version = "8.10.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1036"
name = "Masquerading"
reference = "https://attack.mitre.org/techniques/T1036/"

[[threat.technique]]
id = "T1055"
name = "Process Injection"
reference = "https://attack.mitre.org/techniques/T1055/"


[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "8.10.0"

Stages and Predicates

Stage 1: library

library where
dll.name : ("wininet.dll", "ws2_32.dll", "dnsapi.dll", "winhttp.dll", "clr.dll", "netapi32.dll",
                "mscorwks.dll", "System.*.dll", "mscorlib*.dll", "Microsoft.PowerShell.Security*.dll",
                "Microsoft.PowerShell.ConsoleHost*.dll", "wmiutils.dll", "fastprox.dll", "wbemprox.dll",
                "vaultcli.dll", "taskschd.dll", "dsquery.dll", "mstscax.dll", "ntdll.dll", "wldap32.dll",
                "wtsapi32.dll", "psapi.dll") and
process.thread.Ext.call_stack_summary like "ntdll.dll|kernel32.dll*" and
  _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info regex~ """.*system32\\kernel32.dll!(A|[C-Z]).+""") and
  _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info : "?:\\Windows\\System32\\ntdll.dll!LdrLoadDll*") and
   not process.thread.Ext.call_stack_summary like "ntdll.dll|kernel32.dll|mso40uiwin32client.dll|mso98win32client.dll|mso.dll|*" and
   not  _arraysearch(process.thread.Ext.call_stack, $entry,
                   $entry.symbol_info : ("*kernel32.dll!CreateProcess*", "*kernel32.dll!GetDateFormatWWorker*",
                                         "*kernel32.dll!WerpLaunchAeDebug*", "*kernel32.dll!BaseDllReadWriteIniFile*",
                                         "*kernel32.dll!GlobalReAlloc*", "*kernel32.dll!CreateToolhelp32Snapshot*",
                                         "*kernel32.dll!Wow64SetThreadContext*", "*kernel32.dll!ExitProcess*", "*kernel32.dll!WinExec*",
                                         "*kernel32.dll!CallbackMayRunLong*", "*kernel32.dll!BaseGenerateAppCompatData*",
                                         "*mpclient.dll!MpUpdateServicePingRpc*", "*chrome.exe!IsSandboxedProcess*",
                                         "*kernel32.dll!CreateActCtxWWorker*", "*kernel32.dll!Sleep*",
                                         "*kernel32.dll!BasepCheckAppCompat*", "*kernel32.dll!AddAtomW*",
                                         "*\\kernel32.dll!lstrlenW*", "*\\kernel32.dll!FindActCtxSectionGuidWorker*",
                                         "*\\kernel32.dll!OpenPrivateNamespaceW*", "*\\kernel32.dll!DeactivateActCtxWorke*",
                                         "c:\\windows\\system32\\kernel32.dll!QuirkIsEnabled3Worker*",
                                         "C:\\Windows\\System32\\kernel32.dll!GetQueuedCompletionStatus*",
                                         "*\\ntdll.dll!RtlFormatMessageEx*", "*kernel32.dll!GetQueuedCompletionStatus*"))

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.thread.Ext.call_stackarray_any(no value, null check)excludes:process.thread.Ext.call_stack
process.thread.Ext.call_stack_summarystarts_withntdll.dll|kernel32.dll|mso40uiwin32client.dll|mso98win32client.dll|mso.dll|excludes:process.thread.Ext.call_stack_summary field:"process.thread.Ext.call_stack_summary" value:"ntdll.dll|kernel32.dll|mso40uiwin32client.dll|mso98win32client.dll|mso.dll|"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.namewildcard
  • Microsoft.PowerShell.ConsoleHost*.dll corpus 2 (elastic 2)
  • Microsoft.PowerShell.Security*.dll corpus 2 (elastic 2)
  • System.*.dll corpus 2 (elastic 2)
  • clr.dll corpus 6 (elastic 6)
  • dnsapi.dll corpus 7 (elastic 7)
  • dsquery.dll corpus 4 (elastic 4)
  • fastprox.dll
  • mscorlib*.dll corpus 2 (elastic 2)
  • mscorwks.dll corpus 2 (elastic 2)
  • mstscax.dll corpus 5 (elastic 5)
  • netapi32.dll corpus 3 (elastic 3)
  • ntdll.dll corpus 6 (elastic 6)
  • psapi.dll corpus 7 (elastic 7)
  • taskschd.dll corpus 7 (elastic 7)
  • vaultcli.dll corpus 8 (elastic 8)
  • wbemprox.dll corpus 2 (elastic 2)
  • winhttp.dll corpus 16 (elastic 16)
  • wininet.dll corpus 18 (elastic 18)
  • wldap32.dll corpus 5 (elastic 5)
  • wmiutils.dll corpus 6 (elastic 6)
  • ws2_32.dll corpus 20 (elastic 20)
  • wtsapi32.dll corpus 5 (elastic 5)
field:"dll.name" kind:wildcard
process.thread.Ext.call_stack_summarywildcard
  • ntdll.dll|kernel32.dll*
field:"process.thread.Ext.call_stack_summary" kind:wildcard value:"ntdll.dll|kernel32.dll*"