Detection rules › YARA-L
sap user creates and uses new user
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
| Tactic | Techniques |
|---|---|
| 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
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | 85 |
creating_user | array_distinct($creator) |
created_user | array_distinct($new_user) |
description | array_distinct($create.metadata.description) |