M365 Identity Login from Atypical Region

Last updated 4 days ago on 2026-11-19
Created 2 years ago on 2024-09-04

About

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.
Tags
Domain: CloudDomain: IdentityData Source: Microsoft 365Data Source: Microsoft 365 Audit LogsUse Case: Threat DetectionUse Case: Identity and Access AuditTactic: Initial AccessNoise: HighPerformance: NormalProfile: RecommendedThreat: Impossible TravelRule Type: ES|QLPlatform: Microsoft 365Domain: SaaSLanguage: esql
Severity
medium
Risk Score
47
MITRE ATT&CK™

Initial Access (TA0001)(external, opens in a new tab or window)

False Positive Examples
False positives may occur when users are using a VPN or traveling to different locations. Corporate CASB proxies (Zscaler and Netskope) are excluded; other proxy services routing traffic through distant network points of presence may trigger this rule. Mobile access may also result in false positives, as users may log in from various locations while on the go. Mobile user-agents (Android, iPad, iPhone) are excluded.
License
Elastic License v2(external, opens in a new tab or window)

Definition

Integration Pack
Prebuilt Security Detection Rules
Related Integrations

o365(external, opens in a new tab or window)

Query
text code block:
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

Install detection rules in Elastic Security

Detect M365 Identity Login from Atypical Region in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).