Detection rules › Elastic

Library Load from a Truncated Stack

Source
github.com/elastic/protections-artifacts

Detects attempts to load libraries from a potentially truncated call stack in order to conceal the true source of the call.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = """
Detects attempts to load libraries from a potentially truncated call stack in order to conceal the true source of the
call.
"""
id = "250df259-4363-4aba-b13f-83829c978501"
license = "Elastic License v2"
name = "Library Load from a Truncated Stack"
os_list = ["windows"]
reference = ["https://www.elastic.co/security-labs/doubling-down-etw-callstacks"]
version = "1.0.3"

query = '''
library where
(
  (dll.name : ("wininet.dll", "ws2_32.dll", "winhttp.dll", "amsi.dll", "netapi32.dll", "wldap32.dll", "wtsapi32.dll", "mswsock.dll", "urlmon.dll") and
   process.thread.Ext.call_stack_summary == "ntdll.dll|kernelbase.dll" and
   _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: "C:\\Windows\\Sys?????\\KernelBase.dll!LoadLibrary*")) or

  (dll.name : ("kernel32.dll", "kernelbase.dll", "dbghelp.dll", "ntdll.dll", "amsi.dll") and process.thread.Ext.call_stack_summary == "ntdll.dll" and
   _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: "C:\\Windows\\System32\\ntdll.dll!??MapViewOfSectionEx*") and
   not _arraysearch(process.thread.Ext.call_stack, $entry,
                    $entry.symbol_info: ("C:\\Windows\\System32\\ntdll.dll!??MapViewOfSectionEx*",
                                         "c:\\windows\\System32\\kernelbase.dll!LoadLibrary*",
                                         "c:\\windows\\System32\\ntdll.dll!Ldr*",
                                         "C:\\Windows\\System32\\ntdll.dll!RtlUserThreadStart*")))
)
'''

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.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", "winhttp.dll", "amsi.dll", "netapi32.dll", "wldap32.dll", "wtsapi32.dll", "mswsock.dll", "urlmon.dll") and
   process.thread.Ext.call_stack_summary == "ntdll.dll|kernelbase.dll" and
   _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: "C:\\Windows\\Sys?????\\KernelBase.dll!LoadLibrary*")) or

  (dll.name : ("kernel32.dll", "kernelbase.dll", "dbghelp.dll", "ntdll.dll", "amsi.dll") and process.thread.Ext.call_stack_summary == "ntdll.dll" and
   _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: "C:\\Windows\\System32\\ntdll.dll!??MapViewOfSectionEx*") and
   not _arraysearch(process.thread.Ext.call_stack, $entry,
                    $entry.symbol_info: ("C:\\Windows\\System32\\ntdll.dll!??MapViewOfSectionEx*",
                                         "c:\\windows\\System32\\kernelbase.dll!LoadLibrary*",
                                         "c:\\windows\\System32\\ntdll.dll!Ldr*",
                                         "C:\\Windows\\System32\\ntdll.dll!RtlUserThreadStart*")))
)

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.namewildcard
  • amsi.dll corpus 5 (elastic 5)
  • dbghelp.dll corpus 2 (elastic 2)
  • kernel32.dll corpus 2 (elastic 2)
  • kernelbase.dll corpus 2 (elastic 2)
  • mswsock.dll corpus 2 (elastic 2)
  • netapi32.dll corpus 3 (elastic 3)
  • ntdll.dll corpus 6 (elastic 6)
  • urlmon.dll corpus 2 (elastic 2)
  • winhttp.dll corpus 16 (elastic 16)
  • wininet.dll corpus 18 (elastic 18)
  • wldap32.dll corpus 5 (elastic 5)
  • ws2_32.dll corpus 20 (elastic 20)
  • wtsapi32.dll corpus 5 (elastic 5)
field:"dll.name" kind:wildcard
process.thread.Ext.call_stack_summaryeq
  • ntdll.dll corpus 3 (elastic 3)
  • ntdll.dll|kernelbase.dll
field:"process.thread.Ext.call_stack_summary" kind:eq