Detection rules › Elastic
Module Stomping from a Copied Library
Identifies the load of a library that was recently copied and with a unusual memory allocation properties. This may be the result of a code injection using module stomping or DLL hollowing via overwriting the content of legit DLL with malicious code.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth |
Rule body
[rule]
description = """
Identifies the load of a library that was recently copied and with a unusual memory allocation properties. This may be
the result of a code injection using module stomping or DLL hollowing via overwriting the content of legit DLL with
malicious code.
"""
id = "c3758f2c-66d5-4cbe-820f-1c6207c6e341"
license = "Elastic License v2"
name = "Module Stomping from a Copied Library"
os_list = ["windows"]
version = "1.0.22"
query = '''
sequence by user.id with maxspan=3m
[file where event.action != "deletion" and
not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
/* PE file dropped via CopyFile API calls */
file.Ext.header_bytes : "4d5a*" and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: ("*CopyFileEx*", "*MoveFileExW*")) and
not process.executable : ("?:\\Program Files (x86)\\Citrix\\ICA Client\\concentr.exe",
"?:\\Program Files (x86)\\InstallShield Installation Information\\*\\setup.exe") and
not file.path : ("?:\\Program Files (x86)\\Web Components\\NetStream.dll", "C:\\WINDOWS\\system32\\myah0.cpl")] as event0
[library where
/* common networing and recon system modules */
dll.name : ("ws2_32.dll", "dnsapi.dll", "wininet.dll", "psapi.dll", "vaultcli.dll") and
/* stack starts from the recently dropped PE */
endswith~(process.thread.Ext.call_stack_summary, event0.file.name) and
/* Process name is different from the dropped PE */
process.name != event0.file.name and
/* Abnormal private bytes allocation for the dropped PE when loaded in memory */
_arraysearch(process.thread.Ext.call_stack, $entry,
$entry.allocation_private_bytes >= 100000 and startswith~($entry.symbol_info, event0.file.path))]
'''
min_endpoint_version = "8.7.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1
[[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 within 3m, correlated by user.id.
Stage 1: file
[file where event.action != "deletion" and
not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
file.Ext.header_bytes : "4d5a*" and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: ("*CopyFileEx*", "*MoveFileExW*")) and
not process.executable : ("?:\\Program Files (x86)\\Citrix\\ICA Client\\concentr.exe",
"?:\\Program Files (x86)\\InstallShield Installation Information\\*\\setup.exe") and
not file.path : ("?:\\Program Files (x86)\\Web Components\\NetStream.dll", "C:\\WINDOWS\\system32\\myah0.cpl")] as event0
Stage 2: library
[library where
dll.name : ("ws2_32.dll", "dnsapi.dll", "wininet.dll", "psapi.dll", "vaultcli.dll") and
endswith~(process.thread.Ext.call_stack_summary, event0.file.name) and
process.name != event0.file.name and
_arraysearch(process.thread.Ext.call_stack, $entry,
$entry.allocation_private_bytes >= 100000 and startswith~($entry.symbol_info, event0.file.path))]
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
file.path | eq | ?:\Program Files (x86)\Web Components\NetStream.dll, C:\WINDOWS\system32\myah0.cpl | excludes:file.path field:"file.path" value:"?:\Program Files (x86)\Web Components\NetStream.dll" field:"file.path" value:"C:\WINDOWS\system32\myah0.cpl" |
process.executable | wildcard | ?:\Program Files (x86)\Citrix\ICA Client\concentr.exe, ?:\Program Files (x86)\InstallShield Installation Information\*\setup.exe | excludes:process.executable field:"process.executable" value:"?:\Program Files (x86)\Citrix\ICA Client\concentr.exe" field:"process.executable" value:"?:\Program Files (x86)\InstallShield Installation Information\*\setup.exe" |
user.id | eq | S-1-5-18, S-1-5-19, S-1-5-20 | excludes:user.id field:"user.id" value:"S-1-5-18" field:"user.id" value:"S-1-5-19" field:"user.id" value:"S-1-5-20" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
dll.name | wildcard |
| field:"dll.name" kind:wildcard |
event.action | ne |
| field:"EventType" kind:ne value:"deletion" |
file.Ext.header_bytes | wildcard |
| field:"file.Ext.header_bytes" kind:wildcard value:"4d5a*" |
process.name | ne |
| field:"process_name" kind:ne value:"event0.file.name" |
process.thread.Ext.call_stack_summary | ends_with |
| field:"process.thread.Ext.call_stack_summary" kind:ends_with value:"event0.file.name" |