Google Chronicle low experimental yara-l

GCP Service Account Key Used From Multiple Countries

Detects usage of service account key from multiple countries using Chronicle GeoIP enrichment.

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 gcp_service_account_key_used_from_multiple_countries {

  meta:
    author = "Google Cloud Security"
    description = "Detects usage of service account key from multiple countries using Chronicle GeoIP enrichment."
    rule_id = "mr_dbc9cf09-7c2d-4c9e-b9d4-60df60f360a1"
    rule_name = "GCP Service Account Key Used From Multiple Countries"
    mitre_attack_tactic = "Credential Access"
    mitre_attack_technique = "Unsecured Credentials: Private Keys"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1552/004/"
    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 = "ALLOW"
    $gcp.principal.ip_geo_artifact.location.country_or_region != ""
    $gcp.principal.ip_geo_artifact.network.organization_name != /google/
    $gcp.security_result.detection_fields["key_id"] = $sa_key_id

  match:
    $sa_key_id over 1h

  outcome:
    $risk_score = max(35)
    $mitre_attack_tactic = "Credential Access"
    $mitre_attack_technique = "Unsecured Credentials: Private Keys"
    $mitre_attack_technique_id = "T1552.004"
    $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)
    $dc_principal_ip_country = count_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)
    $sa_key_name = array_distinct($gcp.security_result.detection_fields["service_account_key_name"])

  condition:
    $gcp and $dc_principal_ip_country > 2
}

Field Validations

Loading…

Comments (0)

Loading comments...