Detection rules › YARA-L

O365 Add User To Admin Role

Severity
medium
Type
alert
Time window
5m
Match by
userid
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

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

Event coverage

Rules detecting the same action

Other rules on this platform that filter on the same API call or operation.

Rule body yaral

/*
 * Copyright 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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
}

Detection logic

Fires when at least one $app event in the 5m window.

Events

$app USER_UNCATEGORIZED

  • metadata.product_event_type = "Add member to role."
  • security_result.action = "ALLOW"
  • target.resource.attribute.roles.name in "%msgraph_watchlist_roles"

Correlation

Match key
$userid (principal.user.userid)
Within
5m

Outcome

Fields the detection emits on a match. $risk_score drives alerting; Chronicle surfaces the rest on the detection.

FieldExpression
risk_score65
event_countcount_distinct($app.metadata.id)
security_summaryarray_distinct($app.security_result.summary)
user_agentarray_distinct($app.network.http.user_agent)
assigned_rolearray_distinct($app.target.resource.attribute.roles.name)
target_user_useridarray_distinct($app.target.user.userid)