Detection rules › YARA-L

GCP Excessive Permission Denied Events

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

Detects excessive PermissionDenied events within an hour timeframe from a user

MITRE ATT&CK coverage

TacticTechniques
Discovery

Rule body

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

 rule gcp_excessive_permission_denied_events {

  meta:
    author = "Google Cloud Security"
    description = "Detects excessive PermissionDenied events within an hour timeframe from a user"
    rule_id = "mr_2edbd86a-703a-41a3-b2b2-596dd9dbed8d"
    rule_name = "GCP Excessive Permission Denied Events"
    mitre_attack_tactic = "Discovery"
    mitre_attack_technique = "Cloud Infrastructure Discovery"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1580/"
    mitre_attack_version = "v14.1"
    type = "Alert"
    data_source = "GCP Cloud Audit"
    platform = "GCP"
    severity = "Low"
    priority = "Low"

 events:
    $gcp.metadata.log_type = "GCP_CLOUDAUDIT"
    $gcp.security_result.action = "BLOCK"
    $gcp.security_result.severity = "ERROR"
    $gcp.security_result.detection_fields["status_code"] = "7"
    $gcp.principal.user.userid = $user_id
    $gcp.target.application = $target_application
    $gcp.metadata.product_event_type = $product_event_type

  match:
    $user_id over 1h

  outcome:
    $risk_score = max(35)
    $mitre_attack_tactic = "Discovery"
    $mitre_attack_technique = "Cloud Infrastructure Discovery"
    $mitre_attack_technique_id = "T1580"
    $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)
    $target_resource_name = array_distinct($gcp.target.resource.name)

  condition:
    #gcp > 5 and #target_application > 1 and #product_event_type > 1
}

YARA-L rule structure

Condition

Fires when $gcp occurs more than 5 times in the 1h window and $target_application occurs more than 1 times in the 1h window and $product_event_type occurs more than 1 times in the 1h window.

Events

$gcp

  • metadata.log_type = "GCP_CLOUDAUDIT"
  • security_result.action = "BLOCK"
  • security_result.severity = "ERROR"
  • security_result.detection_fields["status_code"] = "7"

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(35)
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)
target_resource_namearray_distinct($gcp.target.resource.name)