Detection rules › YARA-L
Office 365 logging has been enabled
Detect when the Unified Audit Log is enabled
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Defense Impairment |
Telemetry coverage
| Platform | Record / event type |
|---|---|
| Microsoft 365 | Exchange audit operation Set-AdminAuditLogConfig: Federated domain added |
Rules detecting the same action
These rules filter on the same operation.
- Office 365 logging is disabled (YARA-L)
Rule body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule o365_logging_enabled {
meta:
author = "Google Cloud Security"
description = "Detect when the Unified Audit Log is enabled"
rule_id = "mr_a45012d7-4430-4666-b172-5488a48e9ca6"
rule_name = "Office 365 logging has been enabled"
assumption = "If logging is expected, there is no reason for this to be switched off. If it has been disabled and then this event triggers, it has been enabled which may indicate a gap in logging."
tactic = "TA0005"
technique = "T1562.008"
type = "alert"
platform = "azure"
data_source = "o365"
severity = "Critical"
priority = "Critical"
events:
$log.metadata.event_type = "SETTING_CREATION"
$log.metadata.product_event_type = "Set-AdminAuditLogConfig"
$log.metadata.product_name = "Office 365"
$log.metadata.vendor_name = "Microsoft"
$log.security_result.detection_fields["UnifiedAuditLogIngestionEnabled"] = "True"
$log.principal.user.userid = $user
match:
$user over 5m
outcome:
$risk_score = 85
$event_count = count_distinct($log.metadata.id)
$referral_url = array_distinct($log.network.http.referral_url)
$user_agent = array_distinct($log.network.http.user_agent)
$principal_application = array_distinct($log.principal.application)
$principal_ip = array_distinct($log.principal.ip)
$target_application = array_distinct($log.target.application)
//$principal_user_email_address = array_distinct(principal.user.email_addresses)
//$principal_user_userid = array_distinct($log.principal.user.userid)
$session = array_distinct($log.network.session_id)
$location = array_distinct(strings.coalesce($log.principal.location.state,$log.principal.location.country_or_region))
$target_resource_resource_type = array_distinct($log.target.resource.resource_type)
$target_url = array_distinct($log.target.url)
condition:
$log
}
YARA-L rule structure
Condition
Fires when at least one $log event in the 5m window.
Events
$log
metadata.product_event_type = "Set-AdminAuditLogConfig"security_result.detection_fields["UnifiedAuditLogIngestionEnabled"] = "True"
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 |
event_count | count_distinct($log.metadata.id) |
referral_url | array_distinct($log.network.http.referral_url) |
user_agent | array_distinct($log.network.http.user_agent) |
principal_application | array_distinct($log.principal.application) |
principal_ip | array_distinct($log.principal.ip) |
target_application | array_distinct($log.target.application) |
session | array_distinct($log.network.session_id) |
location | array_distinct(strings.coalesce($log.principal.location.state,$log.principal.location.country_or_region)) |
target_resource_resource_type | array_distinct($log.target.resource.resource_type) |
target_url | array_distinct($log.target.url) |