Detection rules › YARA-L

YARA-L rules: 2e

GCP Multiple KMS Keys Disabled Or Destroyed

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

Detect when multiple KMS crypto key versions are disabled or destroyed from GCP Cloud KMS.

MITRE ATT&CK Coverage

TacticTechniques
Impact

Telemetry Coverage

Rules Detecting the Same Action

These rules filter on the same operation.

Rule Body

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

 rule gcp_multiple_kms_keys_disabled_or_destroyed {

  meta:
    author = "Google Cloud Security"
    description = "Detect when multiple KMS crypto key versions are disabled or destroyed from GCP Cloud KMS."
    rule_id = "mr_1457dcf4-b20b-4ec0-a295-d04074889991"
    rule_name = "GCP Multiple KMS Keys Disabled Or Destroyed"
    mitre_attack_tactic = "Impact"
    mitre_attack_technique = "Data Destruction"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1485/"
    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.product_event_type = "DestroyCryptoKeyVersion" or
        (
            $gcp.metadata.product_event_type = "UpdateCryptoKeyVersion" and
            $gcp.target.resource.attribute.labels["req_cryptokey_version_state"] = "DISABLED"
        )
    )
    $gcp.target.application = "cloudkms.googleapis.com"
    $gcp.security_result.action = "ALLOW"
    $gcp.target.user.userid = $user_id

  match:
    $user_id over 1h

  outcome:
    $risk_score = max(75)
    $mitre_attack_tactic = "Impact"
    $mitre_attack_technique = "Data Destruction"
    $mitre_attack_technique_id = "T1485"
    $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 = array_distinct($gcp.principal.user.userid)
    $principal_user_display_name = array_distinct($gcp.principal.user.user_display_name)
    $target_resource_name = array_distinct($gcp.target.resource.name)

  condition:
    #gcp >= 10
}

YARA-L Rule Structure

Condition

Fires when $gcp occurs at least 10 times in the 1h window.

Events

$gcp

  • metadata.log_type = "GCP_CLOUDAUDIT"
  • metadata.product_event_type = "DestroyCryptoKeyVersion"
  • metadata.product_event_type = "UpdateCryptoKeyVersion"
  • target.resource.attribute.labels["req_cryptokey_version_state"] = "DISABLED"
  • target.application = "cloudkms.googleapis.com"
  • security_result.action = "ALLOW"

Match and Correlation

Match key
$user_id (target.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(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_idarray_distinct($gcp.principal.user.userid)
principal_user_display_namearray_distinct($gcp.principal.user.user_display_name)
target_resource_namearray_distinct($gcp.target.resource.name)

New User Created Via Net.EXE

#
Severity
medium
Type
Detection
Time window
5m
Match by
hostname
Author
Endgame, JHasenbusch (adapted to Sigma for oscd.community)
Source
github.com/chronicle/detection-rules

Identifies the creation of local users via the net.exe command

Known False Positives

  • Legitimate user creation. Better use event IDs for user creation rather than command line rules.

MITRE ATT&CK Coverage

TacticTechniques
Persistence

References

Telemetry Coverage

Rule Body

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

rule new_user_created_via_net_exe {

  meta:
    author = "Endgame, JHasenbusch (adapted to Sigma for oscd.community)"
    description = "Identifies the creation of local users via the net.exe command"
    reference = "https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_net_user_add.yml"
    license = "https://github.com/SigmaHQ/Detection-Rule-License/blob/main/LICENSE.Detection.Rules.md"
    rule_name = "New User Created Via Net.EXE"
    sigma_uuid = "cd219ff3-fa99-45d4-8380-a7d15116c6dc"
    sigma_status = "test"
    rule_id = "mr_c5c37a7b-d892-4592-a726-b0dbb45c1e55"
    tactic = "TA0003"
    technique = "T1136.001"
    type = "Detection"
    data_source = "Sysmon"
    platform = "Windows"
    severity = "Medium"
    priority = "Medium"
    false_positives = "Legitimate user creation. Better use event IDs for user creation rather than command line rules."

  events:
    $process.metadata.event_type = "PROCESS_LAUNCH"
    (
        re.regex($process.target.process.file.full_path, `net(|1)\.exe$`) nocase or
        $process.src.process.file.full_path = "net.exe" nocase or
        $process.src.process.file.full_path = "net1.exe" nocase
    )
    (
        strings.contains(strings.to_lower($process.target.process.command_line), "user") and
        strings.contains(strings.to_lower($process.target.process.command_line), "add")
    )
    $process.principal.hostname = $hostname

  match:
    $hostname over 5m

   outcome:
    //example usage of specifying test user and hostname to adjust risk score
    $risk_score = max(if($process.principal.user.userid = "user" and $process.principal.hostname = "hostname", 0, 15))
    $principal_process_pid = array_distinct($process.principal.process.pid)
    $principal_process_command_line = array_distinct($process.principal.process.command_line)
    $principal_process_file_sha256 = array_distinct($process.principal.process.file.sha256)
    $principal_process_file_full_path = array_distinct($process.principal.process.file.full_path)
    $principal_process_product_specfic_process_id = array_distinct($process.principal.process.product_specific_process_id)
    $principal_process_parent_process_product_specfic_process_id = array_distinct($process.principal.process.parent_process.product_specific_process_id)
    $target_process_pid = array_distinct($process.target.process.pid)
    $target_process_command_line = array_distinct($process.target.process.command_line)
    $target_process_file_sha256 = array_distinct($process.target.process.file.sha256)
    $target_process_file_full_path = array_distinct($process.target.process.file.full_path)
    $target_process_product_specfic_process_id = array_distinct($process.target.process.product_specific_process_id)
    $principal_user_userid = array_distinct($process.principal.user.userid)
    $log_type = array_distinct(strings.concat($process.metadata.log_type,"/",$process.metadata.product_event_type))

  condition:
    $process
}

YARA-L Rule Structure

Condition

Fires when at least one $process event in the 5m window.

Events

$process PROCESS_LAUNCH (1, 4688)

  • target.process.file.full_path matches "net(|1)\.exe$"
  • src.process.file.full_path = "net.exe"
  • src.process.file.full_path = "net1.exe"
  • target.process.command_line contains "user"
  • target.process.command_line contains "add"

Match and Correlation

Match key
$hostname (principal.hostname)
Within
5m

Outcome

Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.

FieldExpression
risk_scoremax(if($process.principal.user.userid = "user" and $process.principal.hostname = "hostname", 0, 15))
principal_process_pidarray_distinct($process.principal.process.pid)
principal_process_command_linearray_distinct($process.principal.process.command_line)
principal_process_file_sha256array_distinct($process.principal.process.file.sha256)
principal_process_file_full_patharray_distinct($process.principal.process.file.full_path)
principal_process_product_specfic_process_idarray_distinct($process.principal.process.product_specific_process_id)
principal_process_parent_process_product_specfic_process_idarray_distinct($process.principal.process.parent_process.product_specific_process_id)
target_process_pidarray_distinct($process.target.process.pid)
target_process_command_linearray_distinct($process.target.process.command_line)
target_process_file_sha256array_distinct($process.target.process.file.sha256)
target_process_file_full_patharray_distinct($process.target.process.file.full_path)
target_process_product_specfic_process_idarray_distinct($process.target.process.product_specific_process_id)
principal_user_useridarray_distinct($process.principal.user.userid)
log_typearray_distinct(strings.concat($process.metadata.log_type,"/",$process.metadata.product_event_type))

Back to all YARA-L rules