Detection rules › YARA-L

sap sensitive role assignment correlation

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

Correlates SAP Change Documents with Security Audit logs to detect sensitive role assignments and self-assignments.

MITRE ATT&CK coverage

TacticTechniques
Privilege Escalation

Rule body

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

rule sap_sensitive_role_assignment_correlation {

  meta:
    author = "Google Cloud Security"
    description = "Correlates SAP Change Documents with Security Audit logs to detect sensitive role assignments and self-assignments."
    severity = "Medium"
    tactic = "TA0004"
    technique = "T1098"

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

    $client = $change.target.resource.attribute.labels["MANDANT"]
    $target_user = $change.target.resource.attribute.labels["TABKEY"]

    //joining on user value
    $user = $change.principal.user.userid
    $user = $audit.principal.user.userid

    $audit.metadata.log_type = "SAP_SECURITY_AUDIT"
    $client = $audit.target.resource.attribute.labels["slgmand"]

    not $user in %sap_admin_users.user

  match:
    $user, $client over 30m

  outcome:
    $assigned_role = array_distinct($change.target.resource.product_object_id)
    $principal_ip = array_distinct($audit.principal.ip)
    $audit_description = array_distinct($audit.metadata.description)

  condition:
    $change and $audit
}

YARA-L rule structure

Condition

Fires when at least one $change event in the 30m window and at least one $audit event in the 30m window.

Events

$audit

  • metadata.log_type = "SAP_SECURITY_AUDIT"

$change

  • metadata.log_type = "SAP_CHANGE_DOCUMENT"
  • target.resource.name = "PFCG"
  • target.resource.attribute.labels["TABNAME"] = "AGR_USERS"
  • target.resource.attribute.labels["CHANGE_IND"] = "I"
  • principal.user.userid in "%sap_admin_users.user"

Match and correlation

Match key
$client, $user
Within
30m

Outcome

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

FieldExpression
assigned_rolearray_distinct($change.target.resource.product_object_id)
principal_iparray_distinct($audit.principal.ip)
audit_descriptionarray_distinct($audit.metadata.description)