Detection rules › YARA-L

sap critial role assigned to new user

Severity
critical
Time window
1h
Match by
target_user
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects the assignment of high-privilege roles by correlating Change Documents (PFCG) with Security Audit logs (AUD) for IP attribution.

MITRE ATT&CK coverage

TacticTechniques
Privilege Escalation

Rule body

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

rule sap_critial_role_assigned_to_new_user {

  meta:
    author = "Google Cloud Security"
    name = "SAP - Critical Authorization Assignment"
    description = "Detects the assignment of high-privilege roles by correlating Change Documents (PFCG) with Security Audit logs (AUD) for IP attribution."
    severity = "Critical"
    tactic = "TA0004"
    technique = "T1098"

  events:
    $change.metadata.log_type = "SAP_CHANGE_DOCUMENT"
    $change.target.resource.attribute.labels["TABNAME"] = "AGR_USERS"
    $change.target.resource.attribute.labels["CHNGIND"] = "I"

    $role = $change.target.resource.product_object_id

    $audit.metadata.log_type = "SAP_SECURITY_AUDIT"
    $audit.additional.fields["msg_1"] = "AU7"

    //join
    $target_user = re.capture($change.target.resource.attribute.labels["TABKEY"], "^.{33}\\s*(\\S+)\\s*\\d{16}$")
    $target_user = $audit.additional.fields["param1_1"]

    $role in %sap_sensitive_roles.role

  match:
    $target_user over 1h

  outcome:
    $user_that_created_account = array_distinct($audit.principal.user.userid)
    $user_that_assigned_role = array_distinct($change.principal.user.userid)
    $source_ip = array_distinct($audit.principal.ip)
    $assigned_role = array_distinct($role)
    $system_id = array_distinct($audit.target.application)
    $risk_score = 95

  condition:
    $change and $audit
}

YARA-L rule structure

Condition

Fires when at least one $change event in the 1h window and at least one $audit event in the 1h window.

Events

$audit

  • metadata.log_type = "SAP_SECURITY_AUDIT"
  • additional.fields["msg_1"] = "AU7"
  • additional.fields["param1_1"] macro "re.capture()"

$change

  • metadata.log_type = "SAP_CHANGE_DOCUMENT"
  • target.resource.attribute.labels["TABNAME"] = "AGR_USERS"
  • target.resource.attribute.labels["CHNGIND"] = "I"
  • target.resource.product_object_id in "%sap_sensitive_roles.role"

Match and correlation

Match key
$target_user
Within
1h

Outcome

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

FieldExpression
user_that_created_accountarray_distinct($audit.principal.user.userid)
user_that_assigned_rolearray_distinct($change.principal.user.userid)
source_iparray_distinct($audit.principal.ip)
assigned_rolearray_distinct($role)
system_idarray_distinct($audit.target.application)
risk_score95