Detection rules › YARA-L

O365 OneDrive Anonymous Link Created or Updated

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

Anonymous links can be used to export files from OneDrive. While this isn't always a sign of malicious activity, some organizations do not support the creation of anonymous links because of the risk of data leakage. This rule detects the creation or modification of anonymous links in OneDrive.

Event coverage

Rule body yaral

/*
 * Copyright 2025 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_onedrive_anonymous_link_created_updated {

  meta:
    author = "Google Cloud Security"
    description = "Anonymous links can be used to export files from OneDrive. While this isn't always a sign of malicious activity, some organizations do not support the creation of anonymous links because of the risk of data leakage. This rule detects the creation or modification of anonymous links in OneDrive."
    rule_id = "mr_3e2572c1-cc14-4c2b-b60b-434db1b0f4ae"
    rule_name = "O365 OneDrive Anonymous Link Created or Updated"
    type = "hunt"
    platform = "azure"
    data_source = "o365"
    severity = "Medium"
    priority = "Medium"

  events:
    (
        (
            $file.metadata.event_type = "USER_RESOURCE_CREATION" and
            $file.metadata.product_event_type = "AnonymousLinkCreated"
        )
    or
        (
            $file.metadata.event_type = "STATUS_UPDATE" and
            $file.metadata.product_event_type = "AnonymousLinkUpdated"
        )
    )
    $file.metadata.product_name = "Office 365"
    $file.metadata.vendor_name = "Microsoft"
    $file.principal.user.userid = $user

  match:
    $user over 5m

  outcome:
    $risk_score = 35
    $event_count = count_distinct($file.metadata.id)
    $referral_url = array_distinct($file.network.http.referral_url)
    $user_agent = array_distinct($file.network.http.user_agent)
    $principal_application = array_distinct($file.principal.application)
    //The IP address for creation is a Microsoft IP address while update is the system making the change
    $principal_ip = array_distinct($file.principal.ip)
    $target_application = array_distinct($file.target.application)
    $principal_user_userid = array_distinct($file.principal.user.userid)
    $target_file_full_path = array_distinct($file.target.file.full_path)
    $target_url = array_distinct($file.target.url)

  condition:
    $file
}

Detection logic

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

Events

$file USER_RESOURCE_CREATION

  • metadata.product_event_type = "AnonymousLinkCreated"
  • metadata.product_event_type = "AnonymousLinkUpdated"

Correlation

Match key
$user (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_score35
event_countcount_distinct($file.metadata.id)
referral_urlarray_distinct($file.network.http.referral_url)
user_agentarray_distinct($file.network.http.user_agent)
principal_applicationarray_distinct($file.principal.application)
principal_iparray_distinct($file.principal.ip)
target_applicationarray_distinct($file.target.application)
principal_user_useridarray_distinct($file.principal.user.userid)
target_file_full_patharray_distinct($file.target.file.full_path)
target_urlarray_distinct($file.target.url)