high_risk_user_download_executable_from_macro


Description

Executable downloaded by Microsoft Excel by user with GCP entity relationship

Query · yara_l

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
Raw source high_risk_user_download_executable_from_macro · YARA-L
Esc
Published by chronicle/detection-rules ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
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 rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.