Detection rules › Elastic
API Call from Inaccessible Memory Page
Identifies API calls from memory regions unexpectedly marked as inaccessible. This may indicate an attempt to hide injected code from memory scanners.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth |
Rule body
[rule]
description = """
Identifies API calls from memory regions unexpectedly marked as inaccessible. This may indicate an attempt to hide
injected code from memory scanners.
"""
id = "2f4afc62-e9df-4654-b0c1-67ce380a1131"
license = "Elastic License v2"
name = "API Call from Inaccessible Memory Page"
os_list = ["windows"]
version = "1.0.3"
query = '''
api where
process.Ext.api.name in ("VirtualProtect", "VirtualAlloc", "SetThreadContext", "MapViewOfFile", "MapViewOfFile2") and
(process.thread.Ext.call_stack_final_user_module.name == "Unbacked" or
process.thread.Ext.call_stack_final_user_module.allocation_private_bytes >= 100000) and
_arraysearch(process.thread.Ext.call_stack, $entry,
$entry.symbol_info == "Unbacked" and $entry.callsite_trailing_bytes like ("NOACCESS*", "GUARD*"))
'''
min_endpoint_version = "8.18.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
tree = true
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1564"
name = "Hide Artifacts"
reference = "https://attack.mitre.org/techniques/T1564/"
[[threat.technique]]
id = "T1620"
name = "Reflective Code Loading"
reference = "https://attack.mitre.org/techniques/T1620/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "8.18.0"
Stages and Predicates
Stage 1: api
api where
process.Ext.api.name in ("VirtualProtect", "VirtualAlloc", "SetThreadContext", "MapViewOfFile", "MapViewOfFile2") and
(process.thread.Ext.call_stack_final_user_module.name == "Unbacked" or
process.thread.Ext.call_stack_final_user_module.allocation_private_bytes >= 100000) and
_arraysearch(process.thread.Ext.call_stack, $entry,
$entry.symbol_info == "Unbacked" and $entry.callsite_trailing_bytes like ("NOACCESS*", "GUARD*"))
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
process.Ext.api.name | in |
| field:"process.Ext.api.name" kind:in |
process.thread.Ext.call_stack_final_user_module.allocation_private_bytes | ge |
| field:"process.thread.Ext.call_stack_final_user_module.allocation_private_bytes" kind:ge value:"100000" |
process.thread.Ext.call_stack_final_user_module.name | eq |
| field:"process.thread.Ext.call_stack_final_user_module.name" kind:eq value:"Unbacked" |