Detection rules › Elastic
Remote Process Injection via Mapping
Identifies attempts to map a view of a file or a page file-backed section with execute and write permissions into the address space of a remote process. This may indicate an attempt to inject code via memory mapping.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth |
Rule body
[rule]
description = """
Identifies attempts to map a view of a file or a page file-backed section with execute and write permissions into the
address space of a remote process. This may indicate an attempt to inject code via memory mapping.
"""
id = "95c534ee-1a49-4a35-bea2-2853f2737a17"
license = "Elastic License v2"
name = "Remote Process Injection via Mapping"
os_list = ["windows"]
reference = [
"https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile2",
"https://www.elastic.co/security-labs/dissecting-remcos-rat-part-four",
"https://www.elastic.co/security-labs/doubling-down-etw-callstacks",
]
version = "1.0.13"
query = '''
api where process.Ext.api.name : "MapViewOfFile*" and
not (process.code_signature.subject_name : "MPTronic" and process.code_signature.trusted == true) and
process.Ext.api.behaviors : "cross-process" and process.Ext.api.parameters.protection : "RWX" and process.executable != null and
not _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry, $entry.trusted == true and
$entry.subject_name in ("Microsoft Windows Hardware Compatibility Publisher", "Microsoft Windows Software Compatibility Publisher")) and
not _arraysearch(process.thread.Ext.call_stack, $entry,
$entry.callsite_trailing_bytes :
("85c07562488b4b584885c97459488d7b48488974244848897c244048894c243848894c2430488974242848897424204533c94533c033d2488b4b40ff93d80000"))
'''
min_endpoint_version = "8.8.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
tree = true
[[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.8.0"
Stages and Predicates
Stage 1: api
api where process.Ext.api.name : "MapViewOfFile*" and
not (process.code_signature.subject_name : "MPTronic" and process.code_signature.trusted == true) and
process.Ext.api.behaviors : "cross-process" and process.Ext.api.parameters.protection : "RWX" and process.executable != null and
not _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry, $entry.trusted == true and
$entry.subject_name in ("Microsoft Windows Hardware Compatibility Publisher", "Microsoft Windows Software Compatibility Publisher")) and
not _arraysearch(process.thread.Ext.call_stack, $entry,
$entry.callsite_trailing_bytes :
("85c07562488b4b584885c97459488d7b48488974244848897c244048894c243848894c2430488974242848897424204533c94533c033d2488b4b40ff93d80000"))
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.thread.Ext.call_stack_final_user_module.code_signature | array_any | excludes:process.thread.Ext.call_stack_final_user_module.code_signature | |
process.code_signature.subject_name | eq | MPTronic | excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"MPTronic" |
process.code_signature.trusted | eq | true | excludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true" |
process.thread.Ext.call_stack | array_any | excludes:process.thread.Ext.call_stack |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
process.Ext.api.behaviors | wildcard |
| field:"process.Ext.api.behaviors" kind:wildcard value:"cross-process" |
process.Ext.api.name | wildcard |
| field:"process.Ext.api.name" kind:wildcard value:"MapViewOfFile*" |
process.Ext.api.parameters.protection | wildcard |
| field:"process.Ext.api.parameters.protection" kind:wildcard value:"RWX" |
process.executable | is_not_null | field:"Image" kind:is_not_null |