Memory Threat - Detected - Elastic Defend
Generates a detection alert each time an Elastic Defend alert for memory signatures are received. Enabling this rule allows you to immediately begin investigating your Endpoint memory signature alerts. This rule identifies Elastic Defend memory signature detections only, and does not include prevention alerts.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/03/24"
3integration = ["endpoint"]
4maturity = "production"
5min_stack_comments = "Defend alerting adjustments patch to distinguish prevention and detection."
6min_stack_version = "8.16.0"
7promotion = true
8updated_date = "2024/11/26"
9
10[rule]
11author = ["Elastic"]
12description = """
13Generates a detection alert each time an Elastic Defend alert for memory signatures are received. Enabling this rule
14allows you to immediately begin investigating your Endpoint memory signature alerts. This rule identifies Elastic Defend
15memory signature detections only, and does not include prevention alerts.
16"""
17enabled = false
18from = "now-10m"
19index = ["logs-endpoint.alerts-*"]
20interval = "5m"
21language = "kuery"
22license = "Elastic License v2"
23max_signals = 10000
24name = "Memory Threat - Detected - Elastic Defend"
25note = """## Triage and analysis
26
27### Investigating Memory Threat Alerts
28
29Elastic Endpoint’s memory threat protection adds a layer of coverage for advanced attacks which avoid the traditional approach of writing payloads to disk. Instead, the malicious code runs only in-memory, an effective technique for evading legacy security products. There are currently two sub-categories of memory threat protection.
30
31The first category is referred to as memory signatures and is available on all supported OS. It operates by periodically scanning process executable memory regions based on their activity to identify and terminate known bad malware.
32
33The second category is referred to as shellcode thread and is unique to Windows endpoints today. A common technique of in-memory malware is to load the payload in a memory region not backed by a file on disk and create a thread to execute it.
34
35
36### Possible investigation steps
37
38- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
39- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts :
40 - For shellcode alerts, the key for bucketing alerts is stored in the `Memory_protection.unique_key_v1` field.
41 - For Memory signature alerts, bucket based on the signatures which match `rule.name`.
42- Examine the following fields if there are any matches on known Yara signatures:
43 - `process.Ext.memory_region.malware_signature.all_names`
44 - `Target.process.Ext.memory_region.malware_signature.all_names`
45 - `process.Ext.memory_region.malware_signature.primary.signature.name`
46- Review the memory region strings for any suspicious or unique keywords captured in `process.Ext.memory_region.strings` and `Target.process.Ext.memory_region.strings`.
47- For signature matches review the `process.Ext.memory_region.malware_signature.primary.matches` and `process.Ext.memory_region.malware_signature.secondary.matches` to understand which keywords or byte sequences matched on the memory Yara signature.
48- For shellcode alerts, check the field `Memory_protection.self_injection` value, if it's false it means it's a remote shellcode injection and you need to review the Target process details like `Target.process.executable` fields.
49- Even if the acting process is signed, review any unsigned or suspicious loaded libraries (adversaries may use `DLL Side-Loading`) captured in:
50 - `process.thread.Ext.call_stack.module_path`
51 - `process.Ext.dll.path and process.Ext.dll.hash.sha256`
52 - `Target.process.Ext.dll.hash.sha256`
53 - `Target.process.Ext.dll.path`
54- If you have access to VirusTotal of similar services, you can also perform vGrep searches to look for files with bytes matching on `process.thread.Ext.start_address_bytes` or `Target.process.thread.Ext.start_address_bytes`.
55- Investigate any abnormal behavior by the subject process, such as network connections, registry or file modifications, and any spawned child processes.
56
57### False positive analysis
58
59- False positives may include Yara signature matches on generic keywords or some third party softwares performing code injection (often all involved files are signed and by the same vendor).
60
61### Response and Remediation
62
63- Initiate the incident response process based on the outcome of the triage.
64 - If malicious activity is confirmed, perform a broader investigation to identify the scope of the compromise and determine the appropriate remediation steps.
65- Implement Elastic Endpoint Security to detect and prevent further post exploitation activities in the environment.
66 - Contain the affected system by isolating it from the network to prevent further spread of the attack.
67- If the triage identified malware, search the environment for additional compromised hosts.
68 - Implement temporary network rules, procedures, and segmentation to contain the malware.
69 - Stop suspicious processes.
70 - Immediately block the identified indicators of compromise (IoCs).
71 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
72- Remove and block malicious artifacts identified during triage.
73- Restore the affected system to its operational state by applying any necessary patches, updates, or configuration changes.
74- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
75- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
76- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
77- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
78"""
79references = [
80 "https://github.com/elastic/protections-artifacts/tree/main/yara",
81 "https://docs.elastic.co/en/integrations/endpoint",
82]
83risk_score = 73
84rule_id = "017de1e4-ea35-11ee-a417-f661ea17fbce"
85rule_name_override = "message"
86setup = """## Setup
87
88### Elastic Defend Alerts
89This rule is designed to capture specific alerts generated by Elastic Defend.
90
91To capture all the Elastic Defend alerts, it is recommended to use all of the Elastic Defend feature-specific protection rules:
92
93Behavior - Detected - Elastic Defend (UUID: 0f615fe4-eaa2-11ee-ae33-f661ea17fbce)
94Behavior - Prevented - Elastic Defend (UUID: eb804972-ea34-11ee-a417-f661ea17fbce)
95Malicious File - Detected - Elastic Defend (UUID: f2c3caa6-ea34-11ee-a417-f661ea17fbce)
96Malicious File - Prevented - Elastic Defend (UUID: f87e6122-ea34-11ee-a417-f661ea17fbce)
97Memory Threat - Detected - Elastic Defend (UUID: 017de1e4-ea35-11ee-a417-f661ea17fbce)
98Memory Threat - Prevented - Elastic Defend (UUID: 06f3a26c-ea35-11ee-a417-f661ea17fbce)
99Ransomware - Detected - Elastic Defend (UUID: 0c74cd7e-ea35-11ee-a417-f661ea17fbce)
100Ransomware - Prevented - Elastic Defend (UUID: 10f3d520-ea35-11ee-a417-f661ea17fbce)
101
102To avoid generating duplicate alerts, you should enable either all feature-specific protection rules or the Endpoint Security (Elastic Defend) rule (UUID: 9a1a2dae-0b5f-4c3d-8305-a268d404c306).
103
104### Additional notes
105This rule is configured to generate more **Max alerts per run** than the default 1000 alerts per run set for all rules. This is to ensure that it captures as many alerts as possible.
106
107**IMPORTANT:** The rule's **Max alerts per run** setting can be superseded by the `xpack.alerting.rules.run.alerts.max` Kibana config setting, which determines the maximum alerts generated by _any_ rule in the Kibana alerting framework. For example, if `xpack.alerting.rules.run.alerts.max` is set to 1000, this rule will still generate no more than 1000 alerts even if its own **Max alerts per run** is set higher.
108
109To make sure this rule can generate as many alerts as it's configured in its own **Max alerts per run** setting, increase the `xpack.alerting.rules.run.alerts.max` system setting accordingly.
110
111**NOTE:** Changing `xpack.alerting.rules.run.alerts.max` is not possible in Serverless projects.
112"""
113severity = "high"
114tags = ["Data Source: Elastic Defend", "Tactic: Defense Evasion"]
115timestamp_override = "event.ingested"
116type = "query"
117
118query = '''
119event.kind : alert and event.code : (memory_signature or shellcode_thread) and (event.type : allowed or (event.type: denied and event.outcome: failure))
120'''
121
122
123[[rule.exceptions_list]]
124id = "endpoint_list"
125list_id = "endpoint_list"
126namespace_type = "agnostic"
127type = "endpoint"
128
129[[rule.risk_score_mapping]]
130field = "event.risk_score"
131operator = "equals"
132value = ""
133
134[[rule.severity_mapping]]
135field = "event.severity"
136operator = "equals"
137severity = "low"
138value = "21"
139
140[[rule.severity_mapping]]
141field = "event.severity"
142operator = "equals"
143severity = "medium"
144value = "47"
145
146[[rule.severity_mapping]]
147field = "event.severity"
148operator = "equals"
149severity = "high"
150value = "73"
151
152[[rule.severity_mapping]]
153field = "event.severity"
154operator = "equals"
155severity = "critical"
156value = "99"
157
158[[rule.threat]]
159framework = "MITRE ATT&CK"
160[[rule.threat.technique]]
161id = "T1055"
162name = "Process Injection"
163reference = "https://attack.mitre.org/techniques/T1055/"
164
165[[rule.threat.technique]]
166id = "T1620"
167name = "Reflective Code Loading"
168reference = "https://attack.mitre.org/techniques/T1620/"
169
170
171[rule.threat.tactic]
172id = "TA0005"
173name = "Defense Evasion"
174reference = "https://attack.mitre.org/tactics/TA0005/"
Triage and analysis
Investigating Memory Threat Alerts
Elastic Endpoint’s memory threat protection adds a layer of coverage for advanced attacks which avoid the traditional approach of writing payloads to disk. Instead, the malicious code runs only in-memory, an effective technique for evading legacy security products. There are currently two sub-categories of memory threat protection.
The first category is referred to as memory signatures and is available on all supported OS. It operates by periodically scanning process executable memory regions based on their activity to identify and terminate known bad malware.
The second category is referred to as shellcode thread and is unique to Windows endpoints today. A common technique of in-memory malware is to load the payload in a memory region not backed by a file on disk and create a thread to execute it.
Possible investigation steps
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts :
- For shellcode alerts, the key for bucketing alerts is stored in the
Memory_protection.unique_key_v1
field. - For Memory signature alerts, bucket based on the signatures which match
rule.name
.
- For shellcode alerts, the key for bucketing alerts is stored in the
- Examine the following fields if there are any matches on known Yara signatures:
process.Ext.memory_region.malware_signature.all_names
Target.process.Ext.memory_region.malware_signature.all_names
process.Ext.memory_region.malware_signature.primary.signature.name
- Review the memory region strings for any suspicious or unique keywords captured in
process.Ext.memory_region.strings
andTarget.process.Ext.memory_region.strings
. - For signature matches review the
process.Ext.memory_region.malware_signature.primary.matches
andprocess.Ext.memory_region.malware_signature.secondary.matches
to understand which keywords or byte sequences matched on the memory Yara signature. - For shellcode alerts, check the field
Memory_protection.self_injection
value, if it's false it means it's a remote shellcode injection and you need to review the Target process details likeTarget.process.executable
fields. - Even if the acting process is signed, review any unsigned or suspicious loaded libraries (adversaries may use
DLL Side-Loading
) captured in:process.thread.Ext.call_stack.module_path
process.Ext.dll.path and process.Ext.dll.hash.sha256
Target.process.Ext.dll.hash.sha256
Target.process.Ext.dll.path
- If you have access to VirusTotal of similar services, you can also perform vGrep searches to look for files with bytes matching on
process.thread.Ext.start_address_bytes
orTarget.process.thread.Ext.start_address_bytes
. - Investigate any abnormal behavior by the subject process, such as network connections, registry or file modifications, and any spawned child processes.
False positive analysis
- False positives may include Yara signature matches on generic keywords or some third party softwares performing code injection (often all involved files are signed and by the same vendor).
Response and Remediation
- Initiate the incident response process based on the outcome of the triage.
- If malicious activity is confirmed, perform a broader investigation to identify the scope of the compromise and determine the appropriate remediation steps.
- Implement Elastic Endpoint Security to detect and prevent further post exploitation activities in the environment.
- Contain the affected system by isolating it from the network to prevent further spread of the attack.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove and block malicious artifacts identified during triage.
- Restore the affected system to its operational state by applying any necessary patches, updates, or configuration changes.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Memory Threat - Prevented- Elastic Defend
- Kernel Module Removal
- Process Termination followed by Deletion
- Potential Hex Payload Execution
- Unusual Interactive Shell Launched from System User