M365 Identity Login from Atypical Region

edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

M365 Identity Login from Atypical Region

edit

Detects successful Microsoft 365 portal logins from a country and region the user has not previously authenticated from in a historical window. Atypical regions are identified by combining the user’s country and region geolocation history; an authentication from a new country/region pair for that user may indicate an adversary attempting to access the account from an unusual location or behind a VPN. Adversaries may leverage AiTM phishing kits or brokered credentials to gain unauthorized access.

Rule type: esql

Rule indices: None

Severity: medium

Risk score: 47

Runs every: 5m

Searches indices from: now-14d (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

References:

Tags:

  • Domain: Cloud
  • Domain: Identity
  • Data Source: Microsoft 365
  • Data Source: Microsoft 365 Audit Logs
  • Use Case: Threat Detection
  • Use Case: Identity and Access Audit
  • Tactic: Initial Access
  • Resources: Investigation Guide
  • Noise: High
  • Performance: Normal
  • Profile: Recommended
  • Threat: Impossible Travel
  • Rule Type: ES|QL
  • Platform: Microsoft 365
  • Domain: SaaS

Version: 15

Rule authors:

  • Elastic

Rule license: Elastic License v2

Investigation guide

edit

Triage and analysis

Investigating M365 Identity Login from Atypical Region

Detects successful Microsoft 365 portal logins from a country and region the user has not previously authenticated from in a historical window. This may indicate an adversary attempting to access the account from an unusual location or behind a VPN. Adversaries may leverage AiTM phishing kits or brokered credentials to gain unauthorized access.

Possible investigation steps

  • Identify the user in o365.audit.UserId and the new geographic combination: source.geo.country_name and source.geo.region_name.
  • Review Esql.first_seen to confirm when this geographic combination first appeared and correlate with the user’s known activity.
  • Inspect Esql.source_as_organization_name_values for the originating ASN. Corporate ISPs and known CASB proxies are lower-risk. Hosting-provider ASNs (cloud compute, bulletproof hosting) for interactive sign-ins are high-fidelity suspicious.
  • Review Esql.source_ip_values for the source IPs and correlate with threat intelligence or known VPN ranges for the user.
  • Examine Esql.request_type_values to understand the authentication flow type. OAuth2:Authorize is interactive browser login; OAuth2:Token indicates background token acquisition.
  • Analyze Esql.application_id_values to identify which application was used. Look for unexpected applications or those commonly associated with OAuth phishing campaigns.
  • Review Esql.user_agent_original_values for the browser and OS. A user-agent that diverges from the user’s baseline (different OS, browser version) may indicate session reuse or tool-based access.
  • Use Esql.aad_session_id_values to pivot directly into azure.signinlogs on the session_id field and retrieve the full interactive sign-in record, including MFA details, device compliance, and CA policy outcomes.
  • Use Esql.user_key_values (AAD object GUID) to query Entra ID user details and risk posture.
  • If Esql.token_object_id_values is populated, cross-reference against known stolen token indicators; a token object ID appearing in multiple geographic contexts is a high-confidence AiTM signal.
  • Compare Esql.source_ip_values and Esql.actor_ip_values — divergence may indicate proxied or forwarded requests.
  • Check Esql.object_id_values to identify which Microsoft resource or service was accessed from the new location.
  • If Entra ID sign-in logs are available, also check for concurrent impossible travel alerts for the same user.

False positive analysis

  • Users traveling or using VPNs may trigger this alert. Verify with the user if they were traveling or using a VPN at the time of the login attempt.
  • Mobile access may result in false positives; mobile user-agents (Android, iPad, iPhone) are already excluded.
  • Zscaler and Netskope CASB traffic is excluded. Other enterprise proxy services routing traffic through distant PoPs may generate alerts; validate the ASN in Esql.source_as_organization_name_values against the organization’s known proxy infrastructure.

Response and remediation

  • If the login attempt is deemed suspicious, immediately revoke all active sessions for the user and force re-authentication.
  • Reset the user’s password and enforce multi-factor authentication (MFA) for logins from unusual locations.
  • Review conditional access policies to ensure they require MFA or block access from unexpected geographies.
  • Investigate any OAuth consent grants, new authentication method registrations, or device joins that occurred near the same time as the atypical login.
  • Monitor for subsequent login attempts from the same location or IP address to identify persistent adversary access.
  • Consider adding exceptions for specific ASNs if the login attempts are confirmed legitimate corporate proxy behavior.

Rule query

edit
FROM logs-o365.audit-*
| WHERE @timestamp >= NOW() - 14 days
    AND data_stream.dataset == "o365.audit"
    AND event.provider == "AzureActiveDirectory"
    AND event.action == "UserLoggedIn"
    AND event.outcome == "success"
    AND TO_INTEGER(o365.audit.Target.Type) IN (0, 2, 3, 5, 6, 10)
    AND o365.audit.UserId IS NOT NULL
    AND o365.audit.UserId != "Not Available"
    AND source.geo.country_name IS NOT NULL
    AND source.geo.region_name IS NOT NULL
    AND (source.`as`.organization.name IS NULL OR source.`as`.organization.name NOT IN ("ZSCALER, INC.", "Zscaler Switzerland GmbH", "Netskope Inc"))
    AND o365.audit.ApplicationId IS NOT NULL
    AND o365.audit.ApplicationId NOT IN (
        "08e18876-6177-487e-b8b5-cf950c1e598c",
        "29d9ed98-a469-4536-ade2-f981bc1d605e",
        "38aa3b87-a06d-4817-b275-7a316988d93b",
        "3e62f81e-590b-425b-9531-cad6683656cf",
        "a809996b-059e-42e2-9866-db24b99a9782",
        "d7b530a4-7680-4c23-a8bf-c52c121d2e87"
    )
    AND o365.audit.ExtendedProperties.RequestType IS NOT NULL
    AND o365.audit.ExtendedProperties.RequestType NOT IN (
        "BulkAADJToken:BulkAADJTokenPoll",
        "Consent:Set",
        "DeviceAuth:PKeyAuth",
        "DeviceAuth:ReprocessTls",
        "Federation:externalauthcallback",
        "Federation:oauth2claimsprovider",
        "Federation:oauth2msa",
        "KerberosProxy:kerberos",
        "Kmsi:kmsi",
        "Login:reprocess",
        "Login:resume",
        "MessagePrompt:MessagePrompt",
        "OrgIdWsFederation:federation",
        "OrgIdWsTrust2:extsts",
        "PermitSso:PermitSso",
        "RegionalCacheAuth:regionalcacheauthtoken",
        "SAS:BeginAuth",
        "SAS:EndAuth",
        "SAS:ProcessAuth",
        "SSPR:end",
        "Saml2:processrequest",
        "UserInfo:Index",
        "WebNativeBridgeController:WebNativeBridgeReprocess",
        "WsFederation:wsfederation"
    )
    AND (
        user_agent.original IS NULL
        OR (
            user_agent.original NOT LIKE "*Android*"
            AND user_agent.original NOT LIKE "*PKeyAuth*"
            AND user_agent.original NOT LIKE "*WebView*"
            AND user_agent.original NOT LIKE "*iPad*"
            AND user_agent.original NOT LIKE "*iPhone*"
        )
    )
| STATS
    Esql.first_seen = MIN(@timestamp),
    Esql.first_ingested = MIN(COALESCE(event.ingested, @timestamp)),
    Esql.last_seen = MAX(@timestamp),
    Esql.event_count = COUNT(*),
    Esql.source_as_organization_name_values = VALUES(source.`as`.organization.name),
    Esql.source_ip_values = VALUES(source.ip),
    Esql.user_agent_original_values = VALUES(user_agent.original),
    Esql.application_id_values = VALUES(o365.audit.ApplicationId),
    Esql.request_type_values = VALUES(o365.audit.ExtendedProperties.RequestType),
    Esql.object_id_values = VALUES(o365.audit.ObjectId),
    Esql.result_status_detail_values = VALUES(o365.audit.ExtendedProperties.ResultStatusDetail),
    Esql.user_type_values = VALUES(o365.audit.UserType),
    Esql.aad_session_id_values = VALUES(o365.audit.AppAccessContext.AADSessionId),
    Esql.actor_ip_values = VALUES(o365.audit.ActorIpAddress),
    Esql.user_key_values = VALUES(o365.audit.UserKey),
    Esql.token_object_id_values = VALUES(o365.audit.TokenObjectId)
  BY o365.audit.UserId, source.geo.country_name, source.geo.region_name
| WHERE Esql.first_ingested >= NOW() - 10 minutes
| KEEP Esql.*, o365.audit.UserId, source.geo.country_name, source.geo.region_name

Framework: MITRE ATT&CKTM