Detection rules › Elastic
Shellcode Allocation from Free Memory
Identifies when a process attempts to allocate shellcode from a memory region marked as free.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth |
Rule body
[rule]
description = "Identifies when a process attempts to allocate shellcode from a memory region marked as free."
id = "ea26cec9-aa4f-422e-b6e6-f75901c05e21"
license = "Elastic License v2"
name = "Shellcode Allocation from Free Memory"
os_list = ["windows"]
version = "1.0.3"
query = '''
api where process.Ext.api.behaviors == "allocate_shellcode" and
process.thread.Ext.call_stack_final_user_module.name == "Unbacked" and
process.thread.Ext.call_stack_summary in
("ntdll.dll|kernelbase.dll|Unbacked",
"ntdll.dll|Unbacked",
"ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|Unbacked",
"ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|Unbacked") and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.callsite_trailing_bytes like "FREE___*" and not $entry.protection_provenance like ("Kernel", "Kernel|*")) and
not _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry, $entry.trusted == true) and
not (process.executable : "C:\\Windows\\SysWOW64\\msiexec.exe" and process.thread.Ext.call_stack_final_user_module.protection_provenance_path like "c:\\windows\\installer\\msi*.tmp")
'''
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 = "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.18.0"
Stages and Predicates
Stage 1: api
api where process.Ext.api.behaviors == "allocate_shellcode" and
process.thread.Ext.call_stack_final_user_module.name == "Unbacked" and
process.thread.Ext.call_stack_summary in
("ntdll.dll|kernelbase.dll|Unbacked",
"ntdll.dll|Unbacked",
"ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|Unbacked",
"ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|Unbacked") and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.callsite_trailing_bytes like "FREE___*" and not $entry.protection_provenance like ("Kernel", "Kernel|*")) and
not _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry, $entry.trusted == true) and
not (process.executable : "C:\\Windows\\SysWOW64\\msiexec.exe" and process.thread.Ext.call_stack_final_user_module.protection_provenance_path like "c:\\windows\\installer\\msi*.tmp")
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.executable | eq | C:\Windows\SysWOW64\msiexec.exe | excludes:process.executable field:"process.executable" value:"C:\Windows\SysWOW64\msiexec.exe" |
process.thread.Ext.call_stack_final_user_module.protection_provenance_path | wildcard | c:\windows\installer\msi*.tmp | excludes:process.thread.Ext.call_stack_final_user_module.protection_provenance_path field:"process.thread.Ext.call_stack_final_user_module.protection_provenance_path" value:"c:\windows\installer\msi*.tmp" |
process.thread.Ext.call_stack_final_user_module.code_signature | array_any | excludes:process.thread.Ext.call_stack_final_user_module.code_signature |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
process.Ext.api.behaviors | eq |
| field:"process.Ext.api.behaviors" kind:eq value:"allocate_shellcode" |
process.thread.Ext.call_stack_final_user_module.name | eq |
| field:"process.thread.Ext.call_stack_final_user_module.name" kind:eq value:"Unbacked" |
process.thread.Ext.call_stack_summary | in |
| field:"process.thread.Ext.call_stack_summary" kind:in |