Detection rules › YARA-L
GCP Firewall Rule Opened To The World
Detect when a GCP Firewall rule is opened to the world (0.0.0.0/0) on all protocols.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Defense Impairment |
Telemetry coverage
| Platform | Record / event type |
|---|---|
| GCP | compute.firewalls.insert: Insert firewall rule |
Rule body
// Copyright 2024 Google LLC. Licensed under Apache-2.0.
rule gcp_firewall_rule_opened_to_world {
meta:
author = "Google Cloud Security"
description = "Detect when a GCP Firewall rule is opened to the world (0.0.0.0/0) on all protocols."
rule_id = "mr_340c7a66-56ea-498a-bf00-270e9e61fed0"
rule_name = "GCP Firewall Rule Opened To The World"
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 = "RESOURCE_CREATION"
$gcp.metadata.log_type = "GCP_CLOUDAUDIT"
$gcp.metadata.product_event_type = /compute.firewalls.insert$/ nocase
$gcp.metadata.product_name = "Google Compute Engine"
$gcp.security_result.action = "ALLOW"
$gcp.target.resource.attribute.labels["source_ranges"] = "0.0.0.0/0"
$gcp.security_result.detection_fields["allowed_ipprotocol"] = "all"
$gcp.target.resource.attribute.labels["response_status"] = "RUNNING"
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 matches "compute.firewalls.insert$"security_result.action = "ALLOW"target.resource.attribute.labels["source_ranges"] = "0.0.0.0/0"security_result.detection_fields["allowed_ipprotocol"] = "all"target.resource.attribute.labels["response_status"] = "RUNNING"
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 |