Detection rules › Elastic

Windows API via Work Callback

Source
github.com/elastic/protections-artifacts

Identifies the call of Memory Windows APIs indirectly via a callback function. This may be the result of an evasion attempt to hide the origin of the API call from the call stack such as unbacked memory region.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = """
Identifies the call of Memory Windows APIs indirectly via a callback function. This may be the result of an evasion
attempt to hide the origin of the API call from the call stack such as unbacked memory region.
"""
id = "d0759e87-16c1-45ed-ac8f-b2ad6e4fdddc"
license = "Elastic License v2"
name = "Windows API via Work Callback"
os_list = ["windows"]
reference = [
    "https://www.elastic.co/security-labs/doubling-down-etw-callstacks",
    "https://0xdarkvortex.dev/hiding-in-plainsight/",
]
version = "1.0.3"

query = '''
api where
 process.Ext.api.name in ("VirtualAlloc", "VirtualProtect", "WriteProcessMemory", "VirtualProtectEx", "VirtualAllocEx", "MapViewOfFile", "MapViewOfFile2", "SetThreadContext", "SuspendThread", "ReadProcessMemory", "connect") and
 process.thread.Ext.call_stack_summary == "ntdll.dll|kernel32.dll|ntdll.dll" and
 _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info : ("*ntdll.dll!TppWorkpExecuteCallback*", "*ntdll.dll!TppWorkerThread*"))
'''

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 = "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: api

api where
 process.Ext.api.name in ("VirtualAlloc", "VirtualProtect", "WriteProcessMemory", "VirtualProtectEx", "VirtualAllocEx", "MapViewOfFile", "MapViewOfFile2", "SetThreadContext", "SuspendThread", "ReadProcessMemory", "connect") and
 process.thread.Ext.call_stack_summary == "ntdll.dll|kernel32.dll|ntdll.dll" and
 _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info : ("*ntdll.dll!TppWorkpExecuteCallback*", "*ntdll.dll!TppWorkerThread*"))

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
process.Ext.api.namein
  • MapViewOfFile
  • MapViewOfFile2
  • ReadProcessMemory
  • SetThreadContext corpus 4 (elastic 4)
  • SuspendThread
  • VirtualAlloc corpus 4 (elastic 4)
  • VirtualAllocEx
  • VirtualProtect corpus 19 (elastic 19)
  • VirtualProtectEx
  • WriteProcessMemory corpus 14 (elastic 14)
  • connect corpus 5 (elastic 5)
field:"process.Ext.api.name" kind:in
process.thread.Ext.call_stack_summaryeq
  • ntdll.dll|kernel32.dll|ntdll.dll corpus 4 (elastic 4)
field:"process.thread.Ext.call_stack_summary" kind:eq value:"ntdll.dll|kernel32.dll|ntdll.dll"