Detection rules › YARA-L
Entra ID Recently Created User Assigned an Entra ID Role
Detect users who are newly created and then immediately assigned administrator level roles
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Persistence |
References
Telemetry coverage
| Platform | Record / event type |
|---|---|
| Azure | Add member to role |
| Azure | Add user |
Rules detecting the same action
These rules filter on the same operation.
- [Entra ID] Application Assigned Administrator Permissions Immediately After Obtaining Role Management Permissions (Kusto)
- [Entra ID] Authentication Method Changed for Privileged Account (Kusto)
- [Entra ID] Mass Privileged Role Change Activity Detected (Kusto)
- [Entra ID] Privilege Elevation Request Denied (Kusto)
- [Entra ID] Privileged Role Assigned to a New User (Kusto)
- [Entra ID] Privileged Role Assigned to User (Kusto)
- Account Created and Deleted in Short Timeframe (Kusto)
- Account Created And Deleted Within A Close Time Frame (Sigma)
Rule body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule entra_id_recently_created_user_assigned_entra_id_roles {
meta:
author = "Google Cloud Security"
description = "Detect users who are newly created and then immediately assigned administrator level roles"
rule_id = "mr_ab6067cd-b8a0-49f7-9efb-8a9b3b096a49"
rule_name = "Entra ID Recently Created User Assigned an Entra ID Role"
tactic = "TA0003"
technique = "T1098.003"
assumption = "The list msgraph_watchlist_roles_guid is popualted with admin role guids, ie 62e90394-69f5-4237-9190-012177145e10"
reference = "https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/permissions-reference"
type = "alert"
platform = "azure"
data_source = "azure ad"
severity = "High"
priority = "High"
events:
(
$create.metadata.event_type = "USER_CREATION" and
$create.metadata.product_event_type = "Add user" and
$create.metadata.product_name = "Azure AD Directory Audit" and
$create.metadata.vendor_name = "Microsoft" and
$create.security_result.action = "ALLOW" and
$create.principal.user.userid = $principal_userid and
$create.target.user.userid = $target_userid
)
$create.metadata.event_timestamp.seconds < $role.metadata.event_timestamp.seconds
(
$role.metadata.event_type = "USER_CHANGE_PERMISSIONS" and
$role.metadata.product_event_type = "Add member to role" and
$role.metadata.product_name = "Azure AD Directory Audit" and
$role.metadata.vendor_name = "Microsoft" and
$role.security_result.action = "ALLOW" and
//To detect on specific roles, they can be added to a reference list and the following line uncommented
//$role.target.resource.attribute.labels["Role.Role.TemplateId"] in %msgraph_watchlist_roles_guid and
$role.principal.user.userid = $principal_userid and
re.replace($role.target.user.userid, `@.*$`, "") = $target_userid
)
match:
$principal_userid, $target_userid over 30m
outcome:
$risk_score = 85
$principal_county_region = array_distinct(strings.concat($create.principal.location.city," ",$create.principal.location.state," ",$create.principal.location.country_or_region))
$assigned_role = array_distinct($role.target.user.title)
$assigned_role_guid = array_distinct($role.target.resource.attribute.labels["Role.TemplateId"])
condition:
$create and $role
}
YARA-L rule structure
Condition
Fires when at least one $create event in the 30m window and at least one $role event in the 30m window.
Events
$create
metadata.product_event_type = "Add user"security_result.action = "ALLOW"
$role
metadata.product_event_type = "Add member to role"security_result.action = "ALLOW"
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 |
principal_county_region | array_distinct(strings.concat($create.principal.location.city," ",$create.principal.location.state," ",$create.principal.location.country_or_region)) |
assigned_role | array_distinct($role.target.user.title) |
assigned_role_guid | array_distinct($role.target.resource.attribute.labels["Role.TemplateId"]) |