Detection rules › Elastic

Library Loaded via a CallBack Function

Sequence by
process.entity_id
Source
github.com/elastic/protections-artifacts

Identifies the load of library from via a callback function. This may be the result of an evasion attempt to hide the origin of the LoadLibrary call from the call stack.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = """
Identifies the load of library from via a callback function. This may be the result of an evasion attempt to hide the
origin of the LoadLibrary call from the call stack.
"""
id = "fae9f554-d3bc-4d48-8863-54d0dd68db54"
license = "Elastic License v2"
name = "Library Loaded via a CallBack Function"
os_list = ["windows"]
reference = [
    "https://malpedia.caad.fkie.fraunhofer.de/details/win.nighthawk",
    "https://www.elastic.co/security-labs/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks",
]
version = "1.0.23"

query = '''
sequence by process.entity_id 
 [process where event.action == "start"]
 [library where 
 (
  ((dll.Ext.relative_file_creation_time <= 300 or
    (dll.Ext.device.product_id : ("Virtual DVD-ROM", "Virtual Disk") and not dll.path : "C:\\*")) and
   (dll.code_signature.trusted == false or dll.code_signature.exists == false)) or 
  
   dll.name in~ ("vaultcli.dll", "wmiutils.dll", "taskschd.dll", "dnsapi.dll", "dsquery.dll", 
              "mstask.dll", "mstscax.dll", "sqlite3.dll", "clr.dll", "coreclr.dll", "ws2_32.dll", 
              "wininet.dll", "dnsapi.dll", "winhttp.dll", "psapi.dll", "bitsproxy.dll", "softokn3.dll", 
              "System.Management.Automation.dll", "Wldap32.dll")
 ) and 

 process.thread.Ext.call_stack_summary in 
                ("ntdll.dll|kernelbase.dll|ntdll.dll|kernel32.dll|ntdll.dll", 
                 "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|ntdll.dll|kernel32.dll|ntdll.dll") and
 not _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info like "C:\\Windows\\Sys?????\\ntdll.dll!KiUserApcDispatcher*")
 ]
 until [process where event.action == "end"]
'''

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

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[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.7.0"

Stages and Predicates

Ordered sequence: each step below must occur in order, correlated by process.entity_id.

Stage 1: process

[process where event.action == "start"]

Stage 2: library

[library where 
 (
  ((dll.Ext.relative_file_creation_time <= 300 or
    (dll.Ext.device.product_id : ("Virtual DVD-ROM", "Virtual Disk") and not dll.path : "C:\\*")) and
   (dll.code_signature.trusted == false or dll.code_signature.exists == false)) or 
  
   dll.name in~ ("vaultcli.dll", "wmiutils.dll", "taskschd.dll", "dnsapi.dll", "dsquery.dll", 
              "mstask.dll", "mstscax.dll", "sqlite3.dll", "clr.dll", "coreclr.dll", "ws2_32.dll", 
              "wininet.dll", "dnsapi.dll", "winhttp.dll", "psapi.dll", "bitsproxy.dll", "softokn3.dll", 
              "System.Management.Automation.dll", "Wldap32.dll")
 ) and 

 process.thread.Ext.call_stack_summary in 
                ("ntdll.dll|kernelbase.dll|ntdll.dll|kernel32.dll|ntdll.dll", 
                 "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|ntdll.dll|kernel32.dll|ntdll.dll") and
 not _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info like "C:\\Windows\\Sys?????\\ntdll.dll!KiUserApcDispatcher*")
 ]

Until: process

until [process where event.action == "end"]

Ends the sequence: the steps above must complete before an event matching this clause occurs.

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

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.Ext.device.product_idwildcard
  • Virtual DVD-ROM corpus 5 (elastic 5)
  • Virtual Disk corpus 5 (elastic 5)
field:"dll.Ext.device.product_id" kind:wildcard
dll.Ext.relative_file_creation_timele
  • 300 transforms: number corpus 7 (elastic 7)
field:"dll.Ext.relative_file_creation_time" kind:le value:"300"
dll.code_signature.existseq
  • false transforms: boolean corpus 22 (elastic 22)
field:"dll.code_signature.exists" kind:eq value:"false"
dll.code_signature.trustedeq
  • false transforms: boolean corpus 21 (elastic 21)
field:"dll.code_signature.trusted" kind:eq value:"false"
dll.namein
  • System.Management.Automation.dll corpus 5 (elastic 5)
  • Wldap32.dll corpus 5 (elastic 5)
  • bitsproxy.dll corpus 4 (elastic 4)
  • clr.dll corpus 6 (elastic 6)
  • coreclr.dll
  • dnsapi.dll corpus 7 (elastic 7)
  • dsquery.dll corpus 4 (elastic 4)
  • mstask.dll corpus 3 (elastic 3)
  • mstscax.dll corpus 5 (elastic 5)
  • psapi.dll corpus 7 (elastic 7)
  • softokn3.dll corpus 2 (elastic 2)
  • sqlite3.dll corpus 2 (elastic 2)
  • taskschd.dll corpus 7 (elastic 7)
  • vaultcli.dll corpus 8 (elastic 8)
  • winhttp.dll corpus 16 (elastic 16)
  • wininet.dll corpus 18 (elastic 18)
  • wmiutils.dll corpus 6 (elastic 6)
  • ws2_32.dll corpus 20 (elastic 20)
field:"dll.name" kind:in
event.actioneq
  • end corpus 18 (elastic 18)
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq
process.thread.Ext.call_stack_summaryin
  • ntdll.dll|kernelbase.dll|ntdll.dll|kernel32.dll|ntdll.dll
  • ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|ntdll.dll|kernel32.dll|ntdll.dll
field:"process.thread.Ext.call_stack_summary" kind:in