Detection rules › YARA-L
O365 Add User To Admin Role
Adding users to administrative roles is not malicious, but due to the sensitivity of certain roles, validation should occur when this occurs
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Persistence |
Telemetry coverage
| Platform | Record / event type |
|---|---|
| Microsoft 365 | Add member to role. |
Rules detecting the same action
These rules filter on the same operation.
Rule body
// Copyright 2023 Google LLC. Licensed under Apache-2.0.
rule o365_add_user_to_admin_role {
meta:
author = "Google Cloud Security"
description = "Adding users to administrative roles is not malicious, but due to the sensitivity of certain roles, validation should occur when this occurs"
rule_id = "mr_ee28c257-d2c7-490c-addf-aef35d07f29d"
rule_name = "O365 Add User To Admin Role"
assumption = "The list msgraph_watchlist_roles is populated with role names, example: Application Administrator"
mitre_attack_tactic = "TA0003"
mitre_attack_technique = "T1098.003"
type = "alert"
platform = "azure"
data_source = "o365"
severity = "Medium"
priority = "Medium"
events:
$app.metadata.event_type = "USER_UNCATEGORIZED"
$app.metadata.product_event_type = "Add member to role."
$app.metadata.product_name = "Office 365"
$app.metadata.vendor_name = "Microsoft"
$app.security_result.action = "ALLOW"
$app.target.resource.attribute.roles.name in %msgraph_watchlist_roles
$app.principal.user.userid = $userid
match:
$userid over 5m
outcome:
$risk_score = 65
$event_count = count_distinct($app.metadata.id)
$security_summary = array_distinct($app.security_result.summary)
$user_agent = array_distinct($app.network.http.user_agent)
$assigned_role = array_distinct($app.target.resource.attribute.roles.name)
//added to populate alert graph with additional context
//$principal_user_userid = array_distinct($app.principal.user.userid)
$target_user_userid = array_distinct($app.target.user.userid)
condition:
$app
}
YARA-L rule structure
Condition
Fires when at least one $app event in the 5m window.
Events
$app
metadata.product_event_type = "Add member to role."security_result.action = "ALLOW"target.resource.attribute.roles.name in "%msgraph_watchlist_roles"
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 | 65 |
event_count | count_distinct($app.metadata.id) |
security_summary | array_distinct($app.security_result.summary) |
user_agent | array_distinct($app.network.http.user_agent) |
assigned_role | array_distinct($app.target.resource.attribute.roles.name) |
target_user_userid | array_distinct($app.target.user.userid) |