M365 Portal Login (Impossible Travel)
Detects successful Microsoft 365 portal logins from impossible travel locations. Impossible travel locations are defined as two different countries within a short time frame. This behavior may indicate an adversary attempting to access a Microsoft 365 account from a compromised account or a malicious actor attempting to access a Microsoft 365 account from a different location.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/09/04"
3integration = ["o365"]
4maturity = "production"
5updated_date = "2025/08/26"
6
7[rule]
8author = ["Elastic"]
9description = """
10Detects successful Microsoft 365 portal logins from impossible travel locations. Impossible travel locations are defined
11as two different countries within a short time frame. This behavior may indicate an adversary attempting to access a
12Microsoft 365 account from a compromised account or a malicious actor attempting to access a Microsoft 365 account from
13a different location.
14"""
15false_positives = [
16 """
17 False positives may occur when users are using a VPN or when users are traveling to different locations for
18 legitimate purposes.
19 """,
20]
21from = "now-15m"
22index = ["filebeat-*", "logs-o365.audit-*"]
23language = "kuery"
24license = "Elastic License v2"
25name = "M365 Portal Login (Impossible Travel)"
26note = """## Triage and analysis
27
28### Investigating M365 Portal Login (Impossible Travel)
29
30Microsoft 365's cloud-based services enable global access, but this can be exploited by adversaries logging in from disparate locations within short intervals, indicating potential account compromise. The detection rule identifies such anomalies by analyzing login events for rapid geographic shifts, flagging suspicious activity that may suggest unauthorized access attempts.
31
32### Possible investigation steps
33
34- Review the user associated with these sign-ins to determine if the login attempt was legitimate or if further investigation is needed.
35- Analyze the geographic locations of the logins to identify any patterns or anomalies that may indicate malicious activity.
36- Review the ISP information for the login attempts to identify any unusual or suspicious providers.
37- Review the authorization request type to understand the context of the login attempts and whether they align with the user's typical behavior.
38- Analyze the client application used for the login attempts to determine if it is consistent with the user's normal usage patterns (Teams, Office, etc.)
39- Analyze the user-agent associated with the login attempts to identify any unusual or suspicious patterns.
40
41### False positive analysis
42
43- 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.
44- Mobile access may also result in false positives, as users may log in from various locations while on the go.
45
46### Response and remediation
47
48- Investigate the login attempt further by checking for any additional context or related events that may provide insight into the user's behavior.
49- If the login attempt is deemed suspicious, consider implementing additional security measures, such as requiring multi-factor authentication (MFA) for logins from unusual locations.
50- Educate users about the risks of accessing corporate resources from unfamiliar locations and the importance of using secure connections (e.g., VPNs) when doing so.
51- Monitor for any subsequent login attempts from the same location or IP address to identify potential patterns of malicious activity.
52"""
53references = ["https://www.huntress.com/blog/time-travelers-busted-how-to-detect-impossible-travel-"]
54risk_score = 47
55rule_id = "3896d4c0-6ad1-11ef-8c7b-f661ea17fbcc"
56severity = "medium"
57tags = [
58 "Domain: Cloud",
59 "Domain: SaaS",
60 "Data Source: Microsoft 365",
61 "Data Source: Microsoft 365 Audit Logs",
62 "Use Case: Threat Detection",
63 "Use Case: Identity and Access Audit",
64 "Tactic: Initial Access",
65 "Resources: Investigation Guide",
66]
67timestamp_override = "event.ingested"
68type = "threshold"
69
70query = '''
71event.dataset:o365.audit and
72 event.provider:AzureActiveDirectory and
73 event.action:UserLoggedIn and
74 event.outcome:success and
75 o365.audit.Target.Type:(0 or 10 or 2 or 3 or 5 or 6) and
76 o365.audit.UserId:(* and not "Not Available") and
77 source.geo.country_name:* and
78 o365.audit.Target.ID:(
79 00000006-0000-0ff1-ce00-000000000000 or
80 4765445b-32c6-49b0-83e6-1d93765276ca
81 ) and not o365.audit.ApplicationId:(
82 29d9ed98-a469-4536-ade2-f981bc1d605e or
83 38aa3b87-a06d-4817-b275-7a316988d93b or
84 a809996b-059e-42e2-9866-db24b99a9782
85 ) and not o365.audit.ExtendedProperties.RequestType:(
86 "Cmsi:Cmsi" or
87 "Consent:Set" or
88 "Login:reprocess" or
89 "Login:resume" or
90 "MessagePrompt:MessagePrompt" or
91 "SAS:EndAuth"
92 )
93'''
94
95
96[[rule.threat]]
97framework = "MITRE ATT&CK"
98[[rule.threat.technique]]
99id = "T1078"
100name = "Valid Accounts"
101reference = "https://attack.mitre.org/techniques/T1078/"
102[[rule.threat.technique.subtechnique]]
103id = "T1078.004"
104name = "Cloud Accounts"
105reference = "https://attack.mitre.org/techniques/T1078/004/"
106
107
108
109[rule.threat.tactic]
110id = "TA0001"
111name = "Initial Access"
112reference = "https://attack.mitre.org/tactics/TA0001/"
113
114[rule.investigation_fields]
115field_names = [
116 "@timestamp",
117 "organization.id",
118 "o365.audit.UserId",
119 "o365.audit.ActorIpAddress",
120 "o365.audit.ApplicationId",
121 "o365.audit.ExtendedProperties.RequestType",
122 "o365.audit.Target.ID",
123 "source.geo.country_name",
124]
125
126[rule.threshold]
127field = ["o365.audit.UserId"]
128value = 1
129[[rule.threshold.cardinality]]
130field = "source.geo.country_name"
131value = 2
Triage and analysis
Investigating M365 Portal Login (Impossible Travel)
Microsoft 365's cloud-based services enable global access, but this can be exploited by adversaries logging in from disparate locations within short intervals, indicating potential account compromise. The detection rule identifies such anomalies by analyzing login events for rapid geographic shifts, flagging suspicious activity that may suggest unauthorized access attempts.
Possible investigation steps
- Review the user associated with these sign-ins to determine if the login attempt was legitimate or if further investigation is needed.
- Analyze the geographic locations of the logins to identify any patterns or anomalies that may indicate malicious activity.
- Review the ISP information for the login attempts to identify any unusual or suspicious providers.
- Review the authorization request type to understand the context of the login attempts and whether they align with the user's typical behavior.
- Analyze the client application used for the login attempts to determine if it is consistent with the user's normal usage patterns (Teams, Office, etc.)
- Analyze the user-agent associated with the login attempts to identify any unusual or suspicious patterns.
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 also result in false positives, as users may log in from various locations while on the go.
Response and remediation
- Investigate the login attempt further by checking for any additional context or related events that may provide insight into the user's behavior.
- If the login attempt is deemed suspicious, consider implementing additional security measures, such as requiring multi-factor authentication (MFA) for logins from unusual locations.
- Educate users about the risks of accessing corporate resources from unfamiliar locations and the importance of using secure connections (e.g., VPNs) when doing so.
- Monitor for any subsequent login attempts from the same location or IP address to identify potential patterns of malicious activity.
References
Related rules
- M365 Portal Login (Atypical Travel)
- Microsoft 365 or Entra ID Sign-in from a Suspicious Source
- Multiple Microsoft 365 User Account Lockouts in Short Time Window
- Potential Microsoft 365 User Account Brute Force
- Microsoft 365 OAuth Phishing via Visual Studio Code Client