o365_entra_id_app_modify_permission_change_on_watchlist
Description
Alerts when a permission on the watchlist is applied to an Entra ID application.
Query · yara_l
events:
$app.metadata.event_type = "USER_RESOURCE_UPDATE_CONTENT"
$app.metadata.product_name = "Office 365"
$app.metadata.product_event_type = "Update application."
$app.metadata.vendor_name = "Microsoft"
$app.security_result.action = "ALLOW"
(
$app.target.resource.attribute.labels.key = /NewValue_EntitlementId-/ or
$app.target.resource.attribute.labels.key = /OldValue_EntitlementId-/
)
$app.security_result.detection_fields["target_1"] = $app_name
match:
$app_name 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)
//The reference list msgraph_watchlist_permissions matches on the GUID. List contents example row: 6aedf524-7e1c-45a7-bd76-ded8cab8d0fc //SecurityEvents.ReadWrite.All
$watchlist_permissions_after_modification = array_distinct(if($app.target.resource.attribute.labels.key = /NewValue_EntitlementId/ and $app.target.resource.attribute.labels.value IN %msgraph_watchlist_permissions, $app.target.resource.attribute.labels.value,""))
$watchlist_permissions_before_modification = array_distinct(if($app.target.resource.attribute.labels.key = /OldValue_EntitlementId/ and $app.target.resource.attribute.labels.value IN %msgraph_watchlist_permissions, $app.target.resource.attribute.labels.value,""))
$permissions_after_modification = array_distinct(if($app.target.resource.attribute.labels.key = /NewValue_EntitlementId/ and $app.target.resource.attribute.labels.value !="", $app.target.resource.attribute.labels.value,""))
$permissions_before_modification = array_distinct(if($app.target.resource.attribute.labels.key = /OldValue_EntitlementId/ and $app.target.resource.attribute.labels.value !="", $app.target.resource.attribute.labels.value,""))
$total_permissions_after_modification = count_distinct(if($app.target.resource.attribute.labels.key = /NewValue_EntitlementId/ and $app.target.resource.attribute.labels.value !="", $app.target.resource.attribute.labels.value, "")) - 1
$total_permissions_before_modification = count_distinct(if($app.target.resource.attribute.labels.key = /OldValue_EntitlementId/ and $app.target.resource.attribute.labels.value !="", $app.target.resource.attribute.labels.value, "")) - 1
//added to populate alert graph with additional context
$principal_user_userid = array_distinct($app.principal.user.userid)
condition:
$app