o365_login_activity_to_azure_ad_powershell_app


Description

Logins to Azure AD PowerShell app can have legitimate purposes, but are also abused to gain access to user information. Programmatic access to Entra ID (Azure AD) should generally be through apps, so reviewing these activities is needed.

Query · yara_l

events:
    $login.metadata.event_type = "USER_LOGIN"
    $login.metadata.product_event_type = "UserLoggedIn"
    $login.metadata.product_name = "Office 365"
    $login.metadata.vendor_name = "Microsoft"
    $login.target.resource.product_object_id = "1b730954-1685-4b74-9bfd-dac224a7b894"
    $login.security_result.action = "ALLOW"

    // Below filters ADFS Sync Account that runs every 30 minutes between AD and Entra ID (for federated environments); can use display name or email address
    //$login.target.user.userid != "insert your email address here" and
    //$login.target.user.user_display_name != "On-Premises Directory Synchronization Service Account"
    $login.target.user.userid = $userid

  match:
    $userid over 5m

  outcome:
    $risk_score = 65
    $event_count = count_distinct($login.metadata.id)
    $security_summary = array_distinct($login.security_result.summary)
    $user_agent = array_distinct($login.network.http.user_agent)
    $country_region_login_attempt = array_distinct($login.principal.ip_geo_artifact.location.country_or_region)
    //added to populate alert graph with additional context
    $principal_ip = array_distinct($login.principal.ip)
    $target_user_userid = array_distinct($login.target.user.userid)

  condition:
    $login
Raw source o365_login_activity_to_azure_ad_powershell_app · YARA-L
Esc
Published by chronicle/detection-rules ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
rule o365_login_activity_to_azure_ad_powershell_app {

  meta:
    author = "Google Cloud Security"
    description = "Logins to Azure AD PowerShell app can have legitimate purposes, but are also abused to gain access to user information. Programmatic access to Entra ID (Azure AD) should generally be through apps, so reviewing these activities is needed."
    rule_id = "mr_0cc56eaf-4176-444d-874d-9780bbb29d4f"
    rule_name = "O365 Login Activity To Azure AD PowerShell App"
    tactic = "TA0001"
    technique = "T1078.004"
    type = "hunt"
    platform = "azure"
    data_source = "o365"
    severity = "Medium"
    priority = "Medium"

  events:
    $login.metadata.event_type = "USER_LOGIN"
    $login.metadata.product_event_type = "UserLoggedIn"
    $login.metadata.product_name = "Office 365"
    $login.metadata.vendor_name = "Microsoft"
    $login.target.resource.product_object_id = "1b730954-1685-4b74-9bfd-dac224a7b894"
    $login.security_result.action = "ALLOW"

    // Below filters ADFS Sync Account that runs every 30 minutes between AD and Entra ID (for federated environments); can use display name or email address
    //$login.target.user.userid != "insert your email address here" and
    //$login.target.user.user_display_name != "On-Premises Directory Synchronization Service Account"
    $login.target.user.userid = $userid

  match:
    $userid over 5m

  outcome:
    $risk_score = 65
    $event_count = count_distinct($login.metadata.id)
    $security_summary = array_distinct($login.security_result.summary)
    $user_agent = array_distinct($login.network.http.user_agent)
    $country_region_login_attempt = array_distinct($login.principal.ip_geo_artifact.location.country_or_region)
    //added to populate alert graph with additional context
    $principal_ip = array_distinct($login.principal.ip)
    $target_user_userid = array_distinct($login.target.user.userid)

  condition:
    $login
}

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.