Detection rules › YARA-L
sap critical role assigned to new user
Detects the assignment of high-privilege roles by correlating Change Documents (PFCG) with Security Audit logs (AUD) for IP attribution.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Privilege Escalation |
Rule body
// Copyright 2026 Google LLC. Licensed under Apache-2.0.
rule sap_critical_role_assigned_to_new_user {
meta:
author = "Google Cloud Security"
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
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
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 |