Detection rules › YARA-L
YARA-L rules: 2w
| Rule | Severity |
|---|---|
| AWS GuardDuty Black Hole Traffic Detected | high |
| GCP BigQuery Datasets Opened To Public | high |
| O365 OneDrive Anonymous Link Accessed | medium |
AWS GuardDuty Black Hole Traffic Detected
#Amazon GuardDuty detects an Amazon EC2 instance or a container attempting to communicate with a black hole IP address.
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Command & Control |
Rule Body
// Copyright 2023 Google LLC. Licensed under Apache-2.0.
rule aws_guardduty_black_hole_traffic_detected {
meta:
author = "Google Cloud Security"
description = "Amazon GuardDuty detects an Amazon EC2 instance or a container attempting to communicate with a black hole IP address."
rule_id = "mr_8ac55f38-9c11-4f51-89cd-c40e9b6238b3"
rule_name = "AWS GuardDuty Black Hole Traffic Detected"
mitre_attack_tactic = "Command and Control"
mitre_attack_technique = "Application Layer Protocol"
mitre_attack_url = "https://attack.mitre.org/techniques/T1071/"
mitre_attack_version = "v13.1"
type = "Alert"
data_source = "AWS GuardDuty"
platform = "AWS"
severity = "High"
priority = "High"
events:
$guardduty.metadata.vendor_name = "AMAZON"
$guardduty.metadata.product_name = "AWS GuardDuty"
$guardduty.metadata.product_event_type = /BlackholeTraffic/
//Filter out sample findings
$guardduty.security_result.about.labels["Sample"] != "true"
outcome:
$risk_score = max(35)
$mitre_attack_tactic = "Command and Control"
$mitre_attack_technique = "Application Layer Protocol"
$mitre_attack_technique_id = "T1071"
$event_count = count_distinct($guardduty.metadata.id)
$principal_ip = array_distinct($guardduty.principal.ip)
$principal_ip_country = array_distinct($guardduty.principal.ip_geo_artifact.location.country_or_region)
$principal_ip_state = array_distinct($guardduty.principal.ip_geo_artifact.location.state)
$principal_user_display_name = $guardduty.principal.user.user_display_name
$aws_region = $guardduty.target.location.name
$target_resource_name = $guardduty.target.resource.name
$target_resource_product_object_id = $guardduty.target.resource.product_object_id
$security_result_summary = array_distinct($guardduty.security_result.summary)
$security_result_description = array_distinct($guardduty.security_result.description)
$security_result_severity = array_distinct($guardduty.security_result.severity)
$security_result_severity_details = array_distinct($guardduty.security_result.severity_details)
$metadata_product_event_type = array_distinct($guardduty.metadata.product_event_type)
condition:
$guardduty
}
YARA-L Rule Structure
Condition
Fires when at least one $guardduty event.
Events
$guardduty
metadata.product_event_type matches "BlackholeTraffic"security_result.about.labels["Sample"] != "true"
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | max(35) |
event_count | count_distinct($guardduty.metadata.id) |
principal_ip | array_distinct($guardduty.principal.ip) |
principal_ip_country | array_distinct($guardduty.principal.ip_geo_artifact.location.country_or_region) |
principal_ip_state | array_distinct($guardduty.principal.ip_geo_artifact.location.state) |
principal_user_display_name | $guardduty.principal.user.user_display_name |
aws_region | $guardduty.target.location.name |
target_resource_name | $guardduty.target.resource.name |
target_resource_product_object_id | $guardduty.target.resource.product_object_id |
security_result_summary | array_distinct($guardduty.security_result.summary) |
security_result_description | array_distinct($guardduty.security_result.description) |
security_result_severity | array_distinct($guardduty.security_result.severity) |
security_result_severity_details | array_distinct($guardduty.security_result.severity_details) |
metadata_product_event_type | array_distinct($guardduty.metadata.product_event_type) |
GCP BigQuery Datasets Opened To Public
#Detect when GCP BigQuery datasets are opened to public by adding allUsers or allAuthenticatedUsers to the access policy.
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Defense Impairment |
Telemetry Coverage
| Platform | Record / event type |
|---|---|
| GCP | google.iam.IAMPolicy.SetIamPolicy: Set IAM policy (IAMPolicy service) |
Rule Body
// Copyright 2024 Google LLC. Licensed under Apache-2.0.
rule gcp_bigquery_datasets_opened_to_public {
meta:
author = "Google Cloud Security"
description = "Detect when GCP BigQuery datasets are opened to public by adding allUsers or allAuthenticatedUsers to the access policy."
rule_id = "mr_6d331411-347b-432e-ba52-ff78e4c66a3f"
rule_name = "GCP BigQuery Datasets Opened To Public"
mitre_attack_tactic = "Defense Evasion"
mitre_attack_technique = "Impair Defenses"
mitre_attack_url = "https://attack.mitre.org/techniques/T1562/"
mitre_attack_version = "v14.1"
type = "Alert"
data_source = "GCP Cloud Audit"
platform = "GCP"
severity = "High"
priority = "High"
events:
$gcp.metadata.event_type = "USER_RESOURCE_UPDATE_PERMISSIONS"
$gcp.metadata.log_type = "GCP_CLOUDAUDIT"
$gcp.metadata.vendor_name = "Google Cloud Platform"
$gcp.metadata.product_name = "BigQuery"
$gcp.metadata.product_event_type = "google.iam.v1.IAMPolicy.SetIamPolicy"
$gcp.target.application = "bigquery.googleapis.com"
$gcp.security_result.action = "ALLOW"
$gcp.target.resource.attribute.labels["dataset_change_binding_deltas_action"] = "ADD"
$gcp.target.resource.attribute.labels["dataset_change_binding_deltas_role"] = /roles\/bigquery.*/
$gcp.target.resource.attribute.labels["dataset_change_binding_deltas_member"] = /allUsers|allAuthenticatedUsers/
$gcp.target.resource.resource_subtype = "bigquery_dataset"
$gcp.target.resource.resource_type = "DATABASE"
outcome:
$risk_score = max(75)
$mitre_attack_tactic = "Defense Evasion"
$mitre_attack_technique = "Impair Defenses"
$mitre_attack_technique_id = "T1562"
$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_id = $gcp.principal.user.userid
$principal_user_display_name = $gcp.principal.user.user_display_name
$target_resource_name = $gcp.target.resource.name
$event_name = $gcp.metadata.product_event_type
condition:
$gcp
}
YARA-L Rule Structure
Condition
Fires when at least one $gcp event.
Events
$gcp
metadata.log_type = "GCP_CLOUDAUDIT"metadata.product_event_type = "google.iam.v1.IAMPolicy.SetIamPolicy"target.application = "bigquery.googleapis.com"security_result.action = "ALLOW"target.resource.attribute.labels["dataset_change_binding_deltas_action"] = "ADD"target.resource.attribute.labels["dataset_change_binding_deltas_role"] matches "roles\/bigquery.*"target.resource.attribute.labels["dataset_change_binding_deltas_member"] matches "allUsers|allAuthenticatedUsers"target.resource.resource_subtype = "bigquery_dataset"target.resource.resource_type = "DATABASE"
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | max(75) |
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_id | $gcp.principal.user.userid |
principal_user_display_name | $gcp.principal.user.user_display_name |
target_resource_name | $gcp.target.resource.name |
event_name | $gcp.metadata.product_event_type |
O365 OneDrive Anonymous Link Accessed
#Anonymous links can be used to access files from OneDrive. While this isn't always a sign of malicious activity, some organizations do not support the use of anonymous links because of the risk of data leakage. This rule detects when anonymous links are used to access files from OneDrive.
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Exfiltration |
Telemetry Coverage
| Platform | Record / event type |
|---|---|
| Microsoft 365 | AnonymousLinkUsed |
Rule Body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule o365_onedrive_anonymous_link_accessed {
meta:
author = "Google Cloud Security"
description = "Anonymous links can be used to access files from OneDrive. While this isn't always a sign of malicious activity, some organizations do not support the use of anonymous links because of the risk of data leakage. This rule detects when anonymous links are used to access files from OneDrive."
rule_id = "mr_7e67005a-d5fc-4497-8e81-e6797b2f54e9"
rule_name = "O365 OneDrive Anonymous Link Accessed"
tactic = "TA0010"
technique = "T1048.002"
type = "hunt"
platform = "azure"
data_source = "o365"
severity = "Medium"
priority = "Medium"
events:
$file.metadata.event_type = "USER_RESOURCE_ACCESS"
$file.metadata.product_event_type = "AnonymousLinkUsed"
$file.metadata.product_name = "Office 365"
$file.metadata.vendor_name = "Microsoft"
$file.principal.user.userid = "anonymous"
$file.principal.ip = $ip
match:
$ip over 5m
outcome:
$risk_score = 35
$event_count = count_distinct($file.metadata.id)
$referral_url = array_distinct($file.network.http.referral_url)
$user_agent = array_distinct($file.network.http.user_agent)
$principal_application = array_distinct($file.principal.application)
$principal_ip = array_distinct($file.principal.ip)
$target_application = array_distinct($file.target.application)
$principal_user_userid = array_distinct($file.principal.user.userid)
$target_file_full_path = array_distinct($file.target.file.full_path)
$target_url = array_distinct($file.target.url)
condition:
$file
}
YARA-L Rule Structure
Condition
Fires when at least one $file event in the 5m window.
Events
$file
metadata.product_event_type = "AnonymousLinkUsed"principal.user.userid = "anonymous"
Match and Correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | 35 |
event_count | count_distinct($file.metadata.id) |
referral_url | array_distinct($file.network.http.referral_url) |
user_agent | array_distinct($file.network.http.user_agent) |
principal_application | array_distinct($file.principal.application) |
principal_ip | array_distinct($file.principal.ip) |
target_application | array_distinct($file.target.application) |
principal_user_userid | array_distinct($file.principal.user.userid) |
target_file_full_path | array_distinct($file.target.file.full_path) |
target_url | array_distinct($file.target.url) |