Detection rules › YARA-L

GCP IAM Organization Policy Updated Or Deleted

Severity
high
Type
Alert
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detect when GCP IAM Organization Policy is updated or deleted.

MITRE ATT&CK coverage

TacticTechniques
Persistence
Privilege Escalation

Telemetry coverage

Rule body

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

 rule gcp_iam_organization_policy_updated_or_deleted {

  meta:
    author = "Google Cloud Security"
    description = "Detect when GCP IAM Organization Policy is updated or deleted."
    rule_id = "mr_327c1753-1cd5-424a-8a9f-1648278e2831"
    rule_name = "GCP IAM Organization Policy Updated Or Deleted"
    mitre_attack_tactic = "Persistence, Privilege Escalation"
    mitre_attack_technique = "Account Manipulation"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1098/"
    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.metadata.event_type = "RESOURCE_WRITTEN" and $gcp.metadata.product_event_type = "google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy") or
        ($gcp.metadata.event_type = "RESOURCE_DELETION" and $gcp.metadata.product_event_type = "google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy")
    )
    $gcp.security_result.action = "ALLOW"
    $gcp.target.application = "orgpolicy.googleapis.com"

  outcome:
    $risk_score = max(75)
    $mitre_attack_tactic = "Persistence, Privilege Escalation"
    $mitre_attack_technique = "Account Manipulation"
    $mitre_attack_technique_id = "T1098"
    $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 RESOURCE_WRITTEN

  • metadata.log_type = "GCP_CLOUDAUDIT"
  • metadata.product_event_type = "google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy"
  • metadata.product_event_type = "google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy"
  • security_result.action = "ALLOW"
  • target.application = "orgpolicy.googleapis.com"

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($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_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