Detection rules › Elastic

Remote Process Injection via Mapping

Source
github.com/elastic/protections-artifacts

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

TacticTechniques
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.

FieldKindExcluded valuesSearch
process.thread.Ext.call_stack_final_user_module.code_signaturearray_any(no value, null check)excludes:process.thread.Ext.call_stack_final_user_module.code_signature
process.code_signature.subject_nameeqMPTronicexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"MPTronic"
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.thread.Ext.call_stackarray_any(no value, null check)excludes:process.thread.Ext.call_stack

Indicators

These rows show field, operator, and value matches.