Google Chronicle medium experimental yara-l

Google Cloud Service Account Key Created or Uploaded

Detects when a service account key is created in or uploaded to a monitored Google Cloud project.

View Source

Detection Logic

/*
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES 
OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
rule google_cloud_service_account_key_created_or_uploaded {

  meta:
    author = "Google Cloud Security"
    description = "Detects when a service account key is created in or uploaded to a monitored Google Cloud project."
    rule_id = "mr_751d64b3-2aef-4c5b-bf39-abc6577f6ce8"
    rule_name = "Google Cloud Service Account Key Created or Uploaded"
    assumption = "Google SecOps is ingesting Google Cloud logs. Reference: https://cloud.google.com/chronicle/docs/ingestion/cloud/ingest-gcp-logs"
    type = "alert"
    severity = "Medium"
    priority = "Medium"
    platform = "Google Cloud"
    data_source = "GCP Cloud Audit"
    mitre_attack_tactic = "Persistence"
    mitre_attack_technique = "Account Manipulation: Additional Cloud Credentials"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1098/001/"
    mitre_attack_version = "v15"
    reference = "https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys"

  events:
    $gc.metadata.log_type = "GCP_CLOUDAUDIT"
    $gc.metadata.product_name = "Google Cloud IAM"
    (
        $gc.metadata.product_event_type = "google.iam.admin.v1.CreateServiceAccountKey" or
        $gc.metadata.product_event_type = "google.iam.admin.v1.UploadServiceAccountKey"
    )
    $gc.security_result.action = "ALLOW"
    $gc.security_result.detection_fields["key_id"] = $sa_key_id

  match:
    $sa_key_id over 30m

  outcome:
    $risk_score = max(65)
    $mitre_attack_tactic = "Persistence"
    $mitre_attack_technique = "Account Manipulation: Additional Cloud Credentials"
    $mitre_attack_technique_id = "T1098.001"
    $event_count = count_distinct($gc.metadata.id)
    $principal_ip = array_distinct($gc.principal.ip)
    $principal_user_userid = array_distinct($gc.principal.user.userid)
    $principal_ip_country = array_distinct($gc.principal.ip_geo_artifact.location.country_or_region)
    $principal_ip_state = array_distinct($gc.principal.ip_geo_artifact.location.state)
    $principal_ip_city = array_distinct($gc.principal.location.city)
    $security_result_summary = array_distinct($gc.security_result.summary)
    $sa_key_expiry_date = array_distinct(timestamp.get_date(cast.as_int($gc.about.labels["res_valid_before_time"])))

  condition:
    $gc
}

Field Validations

Loading…

Comments (0)

Loading comments...