Detection rules › YARA-L

Entra ID Login Activity to Uncommon MS Cloud Apps

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

This rule detects Azure AD login activity to apps other than a defined list of first party MS Cloud Apps. Note that Azure Active Directory PowerShell and custom Azure apps are not in this list by default

MITRE ATT&CK coverage

TacticTechniques
Initial AccessT1078.004 Valid Accounts: Cloud Accounts

References

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 entra_id_login_activity_to_uncommon_mscloud_apps {

  meta:
    author = "Google Cloud Security"
    description = "This rule detects Azure AD login activity to apps other than a defined list of first party MS Cloud Apps. Note that Azure Active Directory PowerShell and custom Azure apps are not in this list by default"
    assumption = "The lists first_party_ms_cloud_apps is populated and tuned as needed"
    rule_id = "mr_1a39c017-9045-48d4-928d-096511edf3cc"
    rule_name = "Entra ID Login Activity to Uncommon MS Cloud Apps"
    tactic = "TA0001"
    technique = "T1078.004"
    reference = "https://learn.microsoft.com/en-us/troubleshoot/azure/active-directory/verify-first-party-apps-sign-in"
    type = "alert"
    platform = "azure"
    data_source = "azure ad"
    severity = "Low"
    priority = "Low"

  events:
    $login.metadata.event_type = "USER_LOGIN"
    $login.metadata.product_name = "Azure AD"
    $login.metadata.vendor_name = "Microsoft"
    $login.security_result.action = "ALLOW"
    not $login.target.resource.attribute.labels["App Id"] in %first_party_ms_cloud_apps

    // Below is to filter ADFS Sync Account that runs every 30 minutes between AD and Azure; can use userid or email address
    //$login.target.user.userid = "insert your userid here"
    $login.target.user.user_display_name != "On-Premises Directory Synchronization Service Account"

    $login.target.user.userid = $userid

  match:
    $userid over 5m

  outcome:
    $risk_score = 35
    $event_count = count_distinct($login.metadata.id)
    $target_application = array_distinct($login.target.application)
    $traget_application_guid = array_distinct($login.target.resource.attribute.labels["App Id"])
    $security_description = array_distinct($login.security_result.description)
    $security_summary = array_distinct($login.security_result.summary)
    $country_region_login_attempt = array_distinct(strings.concat($login.principal.location.city," ",$login.principal.location.state," ",$login.principal.location.country_or_region))
    //Used for match condition, don't need as outcome variable as well
    //$target_user_userid = array_distinct($login.target.user.userid)

  condition:
    $login
}

Detection logic

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

Events

$login USER_LOGIN

  • security_result.action = "ALLOW"
  • target.resource.attribute.labels["App Id"] in "%first_party_ms_cloud_apps"
  • target.user.user_display_name != "On-Premises Directory Synchronization Service Account"

Correlation

Match key
$userid (target.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($login.metadata.id)
target_applicationarray_distinct($login.target.application)
traget_application_guidarray_distinct($login.target.resource.attribute.labels["App Id"])
security_descriptionarray_distinct($login.security_result.description)
security_summaryarray_distinct($login.security_result.summary)
country_region_login_attemptarray_distinct(strings.concat($login.principal.location.city," ",$login.principal.location.state," ",$login.principal.location.country_or_region))