Detection rules › YARA-L
High Risk User Download Executable From Macro
Executable downloaded by Microsoft Excel by user with GCP entity relationship
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1204.002 User Execution: Malicious File |
Event coverage
| Provider | Event | Title |
|---|---|---|
| Sysmon | Event ID 3 | Network connection |
| Security-Auditing | Event ID 5156 | The Windows Filtering Platform has permitted a connection. |
Rule body yaral
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
rule high_risk_user_download_executable_from_macro {
meta:
author = "Google Cloud Security"
description = "Executable downloaded by Microsoft Excel by user with GCP entity relationship"
rule_id = "mr_352c77a7-67b6-4dfb-95e5-75fef8fa4a6c"
rule_name = "High Risk User Download Executable From Macro"
type = "alert"
data_source = "zscaler nss, crowdstrike"
tags = "user entity, resource entity"
severity = "High"
priority = "High"
platform = "Windows"
assumption = "This rule assumes that GCP DLP has been deployed and resources have been assigned to a user context"
tactic = "TA0002"
technique = "T1204.002"
events:
// proxy event with suspected executable download
$proxy_event.metadata.event_type = "NETWORK_HTTP"
$proxy_event.target.url = /.*\.exe$/ or
$proxy_event.network.received_bytes > 102400
$proxy_event.principal.user.userid = $user
$proxy_event.principal.user.userid != /test/
$proxy_event.target.hostname = $hostname
// correlate with EDR event indicating Excel activity
$edr_event.target.user.userid = $user
$edr_event.target.process.file.full_path = /excel/ nocase
($edr_event.metadata.event_type = "NETWORK_HTTP" or $edr_event.metadata.event_type = "NETWORK_CONNECTION")
$edr_event.target.hostname = $hostname
// first hop into entity graph to find the permissions
$user_entity.graph.entity.user.userid = $user
$user_entity.graph.metadata.entity_type = "USER"
$user_entity.graph.metadata.source_type = "ENTITY_CONTEXT"
$user_entity.graph.relations.entity.resource.name != ""
$user_entity.graph.relations.entity.resource.name = $table_name
// second hop for the table context
$table_context.graph.entity.resource.product_object_id = $table_name
$table_context.graph.metadata.entity_type = "RESOURCE"
$table_context.graph.metadata.source_type = "ENTITY_CONTEXT"
$table_context.graph.metadata.product_name = "GCP DLP CONTEXT"
match:
$user, $hostname over 5m
outcome:
$risk_score = max(if($table_context.graph.entity.resource.attribute.labels.value = "US_SOCIAL_SECURITY_NUMBER", 80))
$entity_resource_name = array_distinct($table_context.graph.entity.resource.name)
// added to populate alert graph with additional context
$principal_hostname = array_distinct($proxy_event.principal.hostname)
// Commented out target.hostname because it is already represented in graph as match variable. If match changes, can uncomment to add to results
//$target_hostname = array_distinct($proxy_event.target.hostname)
$principal_process_pid = array_distinct($edr_event.principal.process.pid)
$principal_process_command_line = array_distinct($edr_event.principal.process.command_line)
$principal_process_file_sha256 = array_distinct($edr_event.principal.process.file.sha256)
$principal_process_file_full_path = array_distinct($edr_event.principal.process.file.full_path)
$principal_process_product_specific_process_id = array_distinct($edr_event.principal.process.product_specific_process_id)
$principal_process_parent_process_product_specific_process_id = array_distinct($edr_event.principal.process.parent_process.product_specific_process_id)
$target_process_pid = array_distinct($edr_event.target.process.pid)
$target_process_command_line = array_distinct($edr_event.target.process.command_line)
$target_process_file_sha256 = array_distinct($edr_event.target.process.file.sha256)
$target_process_file_full_path = array_distinct($edr_event.target.process.file.full_path)
$target_process_product_specific_process_id = array_distinct($edr_event.target.process.product_specific_process_id)
$target_process_parent_process_product_specific_process_id = array_distinct($edr_event.target.process.parent_process.product_specific_process_id)
// Commented out principal.user.userid because it is already represented in graph as match variable. If match changes, can uncomment to add to results
//$principal_user_userid = array_distinct($edr_event.principal.user.userid)
$target_user_userid = array_distinct($edr_event.target.user.userid)
$target_url = array_distinct($proxy_event.target.url)
condition:
$proxy_event and $edr_event and $user_entity and $table_context
}
Detection logic
Fires when at least one $proxy_event event in the 5m window and at least one $edr_event event in the 5m window and $user_entity matches entity context and $table_context matches entity context.
Events
$edr_event
target.process.file.full_path matches "excel"
$proxy_event
target.url matches ".*\.exe$"network.received_bytes > "102400"principal.user.userid matches "test"
$table_context
graph.metadata.entity_type = "RESOURCE"graph.metadata.source_type = "ENTITY_CONTEXT"graph.metadata.product_name = "GCP DLP CONTEXT"
$user_entity
graph.metadata.entity_type = "USER"graph.metadata.source_type = "ENTITY_CONTEXT"graph.relations.entity.resource.name is not null
Correlation
Outcome
Fields the detection emits on a match. $risk_score drives alerting; Chronicle surfaces the rest on the detection.
| Field | Expression |
|---|---|
risk_score | max(if($table_context.graph.entity.resource.attribute.labels.value = "US_SOCIAL_SECURITY_NUMBER", 80)) |
entity_resource_name | array_distinct($table_context.graph.entity.resource.name) |
principal_hostname | array_distinct($proxy_event.principal.hostname) |
principal_process_pid | array_distinct($edr_event.principal.process.pid) |
principal_process_command_line | array_distinct($edr_event.principal.process.command_line) |
principal_process_file_sha256 | array_distinct($edr_event.principal.process.file.sha256) |
principal_process_file_full_path | array_distinct($edr_event.principal.process.file.full_path) |
principal_process_product_specific_process_id | array_distinct($edr_event.principal.process.product_specific_process_id) |
principal_process_parent_process_product_specific_process_id | array_distinct($edr_event.principal.process.parent_process.product_specific_process_id) |
target_process_pid | array_distinct($edr_event.target.process.pid) |
target_process_command_line | array_distinct($edr_event.target.process.command_line) |
target_process_file_sha256 | array_distinct($edr_event.target.process.file.sha256) |
target_process_file_full_path | array_distinct($edr_event.target.process.file.full_path) |
target_process_product_specific_process_id | array_distinct($edr_event.target.process.product_specific_process_id) |
target_process_parent_process_product_specific_process_id | array_distinct($edr_event.target.process.parent_process.product_specific_process_id) |
target_user_userid | array_distinct($edr_event.target.user.userid) |
target_url | array_distinct($proxy_event.target.url) |