Detection rules › YARA-L

YARA-L rules: 3c

GCP Successful API Call From Tor Exit Node

#
Severity
high
Type
Alert
Time window
5m
Match by
ip
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects successful API executions from a Tor exit node.

MITRE ATT&CK Coverage

TacticTechniques
Execution

Rule Body

// Copyright 2024 Google LLC. Licensed under Apache-2.0.

 rule gcp_successful_api_from_tor_exit_node {

  meta:
    author = "Google Cloud Security"
    description = "Detects successful API executions from a Tor exit node."
    rule_id = "mr_5912e2be-4366-4f34-a770-0ac8358f2cb9"
    rule_name = "GCP Successful API Call From Tor Exit Node"
    mitre_attack_tactic = "Execution"
    mitre_attack_technique = "User Execution"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1204/"
    mitre_attack_version = "v14.1"
    type = "Alert"
    data_source = "GCP Cloud Audit"
    platform = "GCP"
    severity = "High"
    priority = "High"

  events:

    $gcp.metadata.log_type = "GCP_CLOUDAUDIT"
    $gcp.security_result.action = "ALLOW"
    $gcp.principal.ip = $ip

    // Tor IP listing provided by GCTI Feed
    $gcti_feed.graph.entity.artifact.ip = $ip
    $gcti_feed.graph.metadata.entity_type = "IP_ADDRESS"
    $gcti_feed.graph.metadata.threat.threat_feed_name = "Tor Exit Nodes"
    $gcti_feed.graph.metadata.product_name = "GCTI Feed"
    $gcti_feed.graph.metadata.source_type = "GLOBAL_CONTEXT"

  match:
    $ip over 5m

  outcome:
    $risk_score = max(
        //Baseline
        35 +
        // Unauthorized geographies
        if($gcp.principal.ip_geo_artifact.location.country_or_region = "Cuba", 40) +
        if($gcp.principal.ip_geo_artifact.location.country_or_region = "Iran", 40) +
        if($gcp.principal.ip_geo_artifact.location.country_or_region = "North Korea" , 40) +
        if($gcp.principal.ip_geo_artifact.location.country_or_region = "Russia", 40) +
        if($gcp.principal.ip_geo_artifact.location.country_or_region = "Syria", 40)
    )
    $mitre_attack_tactic = "Execution"
    $mitre_attack_technique = "User Execution"
    $mitre_attack_technique_id = "T1204"
    $event_count = count_distinct($gcp.metadata.id)
    $network_http_user_agent = array_distinct($gcp.network.http.user_agent)
    $principal_ip = array_distinct($gcp.principal.ip)
    $principal_ip_country = array_distinct($gcp.principal.ip_geo_artifact.location.country_or_region)
    $principal_ip_state = array_distinct($gcp.principal.ip_geo_artifact.location.state)
    $principal_user_display_name = array_distinct($gcp.principal.user.user_display_name)
    $dc_principal_user_display_name = count_distinct($gcp.principal.user.user_display_name)
    $target_resource_name = array_distinct($gcp.target.resource.name)

  condition:
    $gcp and $gcti_feed
}

YARA-L Rule Structure

Condition

Fires when at least one $gcp event in the 5m window and $gcti_feed matches entity context.

Events

$gcp

  • metadata.log_type = "GCP_CLOUDAUDIT"
  • security_result.action = "ALLOW"

$gcti_feed entity context (IP_ADDRESS)

  • graph.metadata.entity_type = "IP_ADDRESS"
  • graph.metadata.threat.threat_feed_name = "Tor Exit Nodes"
  • graph.metadata.product_name = "GCTI Feed"
  • graph.metadata.source_type = "GLOBAL_CONTEXT"

Match and Correlation

Match key
$ip (principal.ip)
Within
5m

Outcome

Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.

FieldExpression
risk_scoremax( 35 + if($gcp.principal.ip_geo_artifact.location.country_or_region = "Cuba", 40) + if($gcp.principal.ip_geo_artifact.location.country_or_region = "Iran", 40) + if($gcp.principal.ip_geo_artifact.location.country_or_region = "North Korea" , 40) + if($gcp.principal.ip_geo_artifact.location.country_or_region = "Russia", 40) + if($gcp.principal.ip_geo_artifact.location.country_or_region = "Syria", 40) )
event_countcount_distinct($gcp.metadata.id)
network_http_user_agentarray_distinct($gcp.network.http.user_agent)
principal_iparray_distinct($gcp.principal.ip)
principal_ip_countryarray_distinct($gcp.principal.ip_geo_artifact.location.country_or_region)
principal_ip_statearray_distinct($gcp.principal.ip_geo_artifact.location.state)
principal_user_display_namearray_distinct($gcp.principal.user.user_display_name)
dc_principal_user_display_namecount_distinct($gcp.principal.user.user_display_name)
target_resource_namearray_distinct($gcp.target.resource.name)

Google Workspace Multiple Files Sent As Email Attachments From Google Drive

#
Severity
high
Type
Alert
Time window
1h
Match by
user_id
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Identifies when a user sends multiple files from Google Drive as an email attachment to a free email domain, which may indicate data exfiltration.

MITRE ATT&CK Coverage

TacticTechniques
Exfiltration

Telemetry Coverage

Rule Body

// Copyright 2023 Google LLC. Licensed under Apache-2.0.

rule google_workspace_multiple_files_sent_as_email_attachment_from_google_drive {

  meta:
    author = "Google Cloud Security"
    description = "Identifies when a user sends multiple files from Google Drive as an email attachment to a free email domain, which may indicate data exfiltration."
    rule_id = "mr_125c517c-3ef9-4687-8af6-d71eff83d0e9"
    rule_name = "Google Workspace Multiple Files Sent As Email Attachments From Google Drive"
    mitre_attack_tactic = "Exfiltration"
    mitre_attack_technique = "Exfiltration Over Web Service"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1567/"
    mitre_attack_version = "v13.1"
    type = "Alert"
    data_source = "Workspace Activity"
    severity = "High"
    priority = "High"

  events:
    $email.metadata.vendor_name = "Google Workspace"
    $email.metadata.product_name = "drive"
    $email.metadata.event_type = "EMAIL_TRANSACTION"
    $email.metadata.product_event_type = "email_as_attachment"
    $email.target.user.email_addresses = /.*@gmail\.com|.*@aol\.com|.*@ymail\.com|.*@ymail\.com|.*@hotmail\.com|.*@outlook\.com|.*@icloud\.com/
    $email.principal.user.userid = $user_id

  match:
    $user_id over 1h

  outcome:
    $risk_score = max(75)
    $mitre_attack_tactic = "Exfiltration"
    $mitre_attack_technique = "Exfiltration Over Web Service"
    $mitre_attack_technique_id = "T1567"
    $event_count = count_distinct($email.metadata.id)
    $product_event_type = array_distinct($email.metadata.product_event_type)
    $userid = array_distinct($email.principal.user.userid)
    $doc_type = array_distinct($email.src.resource.attribute.labels["doc_type"])
    $owner = array_distinct($email.target.resource.attribute.labels["owner"])
    $target_emails = array_distinct($email.target.user.email_addresses)
    $doc_name = array_distinct($email.target.resource.name)
    $doc_id = array_distinct($email.target.resource.product_object_id)
    $count_docs = count_distinct($email.target.resource.product_object_id)

  condition:
    // Customize the value of $count_docs to set the alerting threshold for your environment
    $email and $count_docs > 10
}

YARA-L Rule Structure

Condition

Fires when at least one $email event in the 1h window and $count_docs > 10.

Events

$email EMAIL_TRANSACTION

  • metadata.product_event_type = "email_as_attachment"
  • target.user.email_addresses matches ".*@gmail\.com|.*@aol\.com|.*@ymail\.com|.*@ymail\.com|.*@hotmail\.com|.*@outlook\.com|.*@icloud\.com"

Match and Correlation

Match key
$user_id (principal.user.userid)
Within
1h

Outcome

Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.

FieldExpression
risk_scoremax(75)
event_countcount_distinct($email.metadata.id)
product_event_typearray_distinct($email.metadata.product_event_type)
useridarray_distinct($email.principal.user.userid)
doc_typearray_distinct($email.src.resource.attribute.labels["doc_type"])
ownerarray_distinct($email.target.resource.attribute.labels["owner"])
target_emailsarray_distinct($email.target.user.email_addresses)
doc_namearray_distinct($email.target.resource.name)
doc_idarray_distinct($email.target.resource.product_object_id)
count_docscount_distinct($email.target.resource.product_object_id)

O365 Login Activity To Azure AD PowerShell App

#
Severity
medium
Type
hunt
Time window
5m
Match by
userid
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Logins to Azure AD PowerShell app can have legitimate purposes, but are also abused to gain access to user information. Programmatic access to Entra ID (Azure AD) should generally be through apps, so reviewing these activities is needed.

MITRE ATT&CK Coverage

TacticTechniques
Initial Access

Telemetry Coverage

PlatformRecord / event type
Microsoft 365UserLoggedIn

Rules Detecting the Same Action

These rules filter on the same operation.

Rule Body

// Copyright 2025 Google LLC. Licensed under Apache-2.0.

rule o365_login_activity_to_azure_ad_powershell_app {

  meta:
    author = "Google Cloud Security"
    description = "Logins to Azure AD PowerShell app can have legitimate purposes, but are also abused to gain access to user information. Programmatic access to Entra ID (Azure AD) should generally be through apps, so reviewing these activities is needed."
    rule_id = "mr_0cc56eaf-4176-444d-874d-9780bbb29d4f"
    rule_name = "O365 Login Activity To Azure AD PowerShell App"
    tactic = "TA0001"
    technique = "T1078.004"
    type = "hunt"
    platform = "azure"
    data_source = "o365"
    severity = "Medium"
    priority = "Medium"

  events:
    $login.metadata.event_type = "USER_LOGIN"
    $login.metadata.product_event_type = "UserLoggedIn"
    $login.metadata.product_name = "Office 365"
    $login.metadata.vendor_name = "Microsoft"
    $login.target.resource.product_object_id = "1b730954-1685-4b74-9bfd-dac224a7b894"
    $login.security_result.action = "ALLOW"

    // Below filters ADFS Sync Account that runs every 30 minutes between AD and Entra ID (for federated environments); can use display name or email address
    //$login.target.user.userid != "insert your email address here" and
    //$login.target.user.user_display_name != "On-Premises Directory Synchronization Service Account"
    $login.target.user.userid = $userid

  match:
    $userid over 5m

  outcome:
    $risk_score = 65
    $event_count = count_distinct($login.metadata.id)
    $security_summary = array_distinct($login.security_result.summary)
    $user_agent = array_distinct($login.network.http.user_agent)
    $country_region_login_attempt = array_distinct($login.principal.ip_geo_artifact.location.country_or_region)
    //added to populate alert graph with additional context
    $principal_ip = array_distinct($login.principal.ip)
    $target_user_userid = array_distinct($login.target.user.userid)

  condition:
    $login
}

YARA-L Rule Structure

Condition

Fires when at least one $login event in the 5m window.

Events

$login USER_LOGIN

  • metadata.product_event_type = "UserLoggedIn"
  • target.resource.product_object_id = "1b730954-1685-4b74-9bfd-dac224a7b894"
  • security_result.action = "ALLOW"

Match and Correlation

Match key
$userid (target.user.userid)
Within
5m

Outcome

Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.

FieldExpression
risk_score65
event_countcount_distinct($login.metadata.id)
security_summaryarray_distinct($login.security_result.summary)
user_agentarray_distinct($login.network.http.user_agent)
country_region_login_attemptarray_distinct($login.principal.ip_geo_artifact.location.country_or_region)
principal_iparray_distinct($login.principal.ip)
target_user_useridarray_distinct($login.target.user.userid)

Back to all YARA-L rules