Detection rules › YARA-L

YARA-L rules: 31

AWS Account Leaving Or Removed From The Organization

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

Detect an AWS account attempting to leave or being removed from an AWS organization.

MITRE ATT&CK Coverage

TacticTechniques
Defense Impairment

Telemetry Coverage

Rule Body

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

rule aws_account_leaving_or_removed_from_organization {

  meta:
    author = "Google Cloud Security"
    description = "Detect an AWS account attempting to leave or being removed from an AWS organization."
    rule_id = "mr_eb9b7a74-0ad2-43e1-bf93-376844fe62b6"
    rule_name = "AWS Account Leaving Or Removed From The Organization"
    mitre_attack_tactic = "Defense Evasion"
    mitre_attack_technique = "Impair Defenses"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1562/"
    mitre_attack_version = "v13.1"
    type = "Alert"
    data_source = "AWS CloudTrail"
    platform = "AWS"
    severity = "Low"
    priority = "Low"

  events:
    $cloudtrail.metadata.vendor_name = "AMAZON"
    $cloudtrail.metadata.product_name = "AWS CloudTrail"
    (
     $cloudtrail.metadata.product_event_type = "LeaveOrganization" or
     $cloudtrail.metadata.product_event_type = "RemoveAccountFromOrganization"
    )

  outcome:
    $risk_score = max(35)
    $mitre_attack_tactic = "Defense Evasion"
    $mitre_attack_technique = "Impair Defenses"
    $mitre_attack_technique_id = "T1562"
    $event_count = count_distinct($cloudtrail.metadata.id)
    $network_http_user_agent = $cloudtrail.network.http.user_agent
    $principal_ip = array_distinct($cloudtrail.principal.ip)
    $principal_ip_country = array_distinct($cloudtrail.principal.ip_geo_artifact.location.country_or_region)
    $principal_ip_state = array_distinct($cloudtrail.principal.ip_geo_artifact.location.state)
    $principal_user_display_name = $cloudtrail.principal.user.user_display_name
    $recipient_aws_account_id = $cloudtrail.additional.fields["recipientAccountId"]
    $aws_region = $cloudtrail.principal.location.name
    $target_resource_name = $cloudtrail.target.resource.name
    $target_resource_product_object_id = $cloudtrail.target.resource.product_object_id

  condition:
    $cloudtrail
}

YARA-L Rule Structure

Condition

Fires when at least one $cloudtrail event.

Events

$cloudtrail

  • metadata.product_event_type is one of:
    • LeaveOrganization
    • RemoveAccountFromOrganization

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($cloudtrail.metadata.id)
network_http_user_agent$cloudtrail.network.http.user_agent
principal_iparray_distinct($cloudtrail.principal.ip)
principal_ip_countryarray_distinct($cloudtrail.principal.ip_geo_artifact.location.country_or_region)
principal_ip_statearray_distinct($cloudtrail.principal.ip_geo_artifact.location.state)
principal_user_display_name$cloudtrail.principal.user.user_display_name
recipient_aws_account_id$cloudtrail.additional.fields["recipientAccountId"]
aws_region$cloudtrail.principal.location.name
target_resource_name$cloudtrail.target.resource.name
target_resource_product_object_id$cloudtrail.target.resource.product_object_id

sap gateway ufo table access

#
Severity
high
Time window
30m
Match by
source_ip, user
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects external RFC calls to generic table-read modules via the SAP Gateway.

MITRE ATT&CK Coverage

TacticTechniques
Discovery

Rule Body

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

rule sap_gateway_ufo_table_access {

  meta:
    author = "Google Cloud Security"
    description = "Detects external RFC calls to generic table-read modules via the SAP Gateway."
    severity = "High"
    tactic = "TA0007"
    technique = "T1082"

  events:
    $e.metadata.product_name = "SAP_GATEWAY"

    (
      $e.security_result.summary = /RFC_READ_TABLE|BBP_RFC_READ_TABLE|RFC_GET_TABLE_ENTRIES/ nocase or
      $e.metadata.description = /RFC_READ_TABLE/ nocase
    )

    $user = $e.principal.user.userid
    $source_ip = $e.principal.ip
    $external_tp = $e.target.process.file.full_path

    not $user in %sap_service_accounts.name

  match:
    $user, $source_ip over 30m

  outcome:
    $risk_score = 40
    $calling_program = array_distinct($external_tp)
    $target_function = array_distinct($e.security_result.summary)
    $gateway_action = array_distinct($e.security_result.action)

  condition:
    $e
}

YARA-L Rule Structure

Condition

Fires when at least one $e event in the 30m window.

Events

$e

  • security_result.summary matches "RFC_READ_TABLE|BBP_RFC_READ_TABLE|RFC_GET_TABLE_ENTRIES"
  • metadata.description matches "RFC_READ_TABLE"
  • principal.user.userid in "%sap_service_accounts.name"

Match and Correlation

Match key
$source_ip, $user
Within
30m

Outcome

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

FieldExpression
risk_score40
calling_programarray_distinct($external_tp)
target_functionarray_distinct($e.security_result.summary)
gateway_actionarray_distinct($e.security_result.action)

sap user creates and uses new user

#
Severity
critical
Time window
30m
Match by
sid, terminal
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects a user creating a new account (AU7) and subsequently logging into it (AU1, AU5) from the same terminal within a short timeframe.

MITRE ATT&CK Coverage

TacticTechniques
Persistence

Rule Body

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

rule sap_user_creates_and_uses_new_user {

  meta:
    author = "Google Cloud Security"
    description = "Detects a user creating a new account (AU7) and subsequently logging into it (AU1, AU5) from the same terminal within a short timeframe."
    severity = "Critical"
    tactic = "TA0003"
    technique = "T1136"

  events:
    $create.metadata.log_type = "SAP_SECURITY_AUDIT"
    $create.additional.fields["msg_1"] = "AU7"
    $creator = $create.principal.user.userid

    $login.metadata.log_type = "SAP_SECURITY_AUDIT"
    $login.additional.fields["msg_1"] = /^AU1$|^AU5$/

    //join
    $new_user = $create.additional.fields["param1_1"]
    $new_user = $login.principal.user.userid
    $terminal = $create.principal.ip
    $terminal = $login.principal.ip
    $sid = $create.target.application
    $sid = $login.target.application

    //sequence
    $create.metadata.event_timestamp.seconds <= $login.metadata.event_timestamp.seconds

    //exclusions
    not $create.principal.user.userid in %sap_admin_users.user

  match:
    $terminal, $sid over 30m

  outcome:
    $risk_score = 85
    $creating_user = array_distinct($creator)
    $created_user = array_distinct($new_user)
    $description = array_distinct($create.metadata.description)

  condition:
    $create and $login
}

YARA-L Rule Structure

Condition

Fires when at least one $create event in the 30m window and at least one $login event in the 30m window.

Events

$create

  • metadata.log_type = "SAP_SECURITY_AUDIT"
  • additional.fields["msg_1"] = "AU7"
  • principal.user.userid in "%sap_admin_users.user"

$login

  • metadata.log_type = "SAP_SECURITY_AUDIT"
  • additional.fields["msg_1"] matches "^AU1$|^AU5$"

Match and Correlation

Order
$create before $login
Match key
$sid, $terminal
Within
30m

Outcome

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

FieldExpression
risk_score85
creating_userarray_distinct($creator)
created_userarray_distinct($new_user)
descriptionarray_distinct($create.metadata.description)

Back to all YARA-L rules