M365 Identity Login from Atypical Travel Location

Detects successful Microsoft 365 portal logins from rare locations. Rare locations are defined as locations that are not commonly associated with the user's account. This behavior may indicate an adversary attempting to access a Microsoft 365 account from an unusual location or behind a VPN.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/09/04"
  3integration = ["o365"]
  4maturity = "production"
  5updated_date = "2025/10/30"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects successful Microsoft 365 portal logins from rare locations. Rare locations are defined as locations that are not
 11commonly associated with the user's account. This behavior may indicate an adversary attempting to access a Microsoft
 12365 account from an unusual location or behind a VPN.
 13"""
 14false_positives = [
 15    """
 16    False positives may occur when users are using a VPN or when users are traveling to different locations"
 17    """,
 18    """
 19    Mobile access may also result in false positives, as users may log in from various locations while on the go.
 20    """,
 21]
 22from = "now-15m"
 23index = ["logs-o365.audit-*"]
 24language = "kuery"
 25license = "Elastic License v2"
 26name = "M365 Identity Login from Atypical Travel Location"
 27note = """## Triage and analysis
 28
 29### Investigating M365 Identity Login from Atypical Travel Location
 30
 31Microsoft 365 is a cloud-based suite offering productivity tools accessible from anywhere, making it crucial for business operations. Adversaries may exploit this by logging in from uncommon locations, potentially using VPNs to mask their origin. The detection rule identifies successful logins from atypical locations, flagging potential unauthorized access attempts by analyzing login events and user location patterns.
 32
 33### Possible investigation steps
 34
 35- Review the user associated with these sign-ins to determine if the login attempt was legitimate or if further investigation is needed.
 36- Analyze the geographic locations of the logins to identify any patterns or anomalies that may indicate malicious activity.
 37- Review the ISP information for the login attempts to identify any unusual or suspicious providers.
 38- Review the authorization request type to understand the context of the login attempts and whether they align with the user's typical behavior.
 39- 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.)
 40- Analyze the user-agent associated with the login attempts to identify any unusual or suspicious patterns. These could also indicate mobile and endpoint logins causing false-positives.
 41
 42### False positive analysis
 43
 44- 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.
 45- Mobile access may also result in false positives, as users may log in from various locations while on the go.
 46
 47### Response and remediation
 48
 49- Investigate the login attempt further by checking for any additional context or related events that may provide insight into the user's behavior.
 50- If the login attempt is deemed suspicious, consider implementing additional security measures, such as requiring multi-factor authentication (MFA) for logins from unusual locations.
 51- 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.
 52- Monitor for any subsequent login attempts from the same location or IP address to identify potential patterns of malicious activity.
 53- Consider adding exceptions to this rule for the user or source application ID if the login attempts are determined to be legitimate and not a security concern.
 54"""
 55references = ["https://www.huntress.com/blog/time-travelers-busted-how-to-detect-impossible-travel-"]
 56risk_score = 47
 57rule_id = "32d3ad0e-6add-11ef-8c7b-f661ea17fbcc"
 58severity = "medium"
 59tags = [
 60    "Domain: Cloud",
 61    "Domain: Identity",
 62    "Data Source: Microsoft 365",
 63    "Data Source: Microsoft 365 Audit Logs",
 64    "Use Case: Threat Detection",
 65    "Use Case: Identity and Access Audit",
 66    "Tactic: Initial Access",
 67    "Resources: Investigation Guide",
 68]
 69timestamp_override = "event.ingested"
 70type = "new_terms"
 71
 72query = '''
 73event.dataset:o365.audit and
 74    event.provider:AzureActiveDirectory and
 75    event.action:UserLoggedIn and
 76    event.outcome:success and
 77    o365.audit.Target.Type:(0 or 10 or 2 or 3 or 5 or 6) and
 78    o365.audit.UserId:(* and not "Not Available") and
 79    source.geo.region_iso_code:* and
 80    not o365.audit.ApplicationId:(
 81        29d9ed98-a469-4536-ade2-f981bc1d605e or
 82        38aa3b87-a06d-4817-b275-7a316988d93b or
 83        a809996b-059e-42e2-9866-db24b99a9782
 84    ) and not o365.audit.ExtendedProperties.RequestType:(
 85        "Cmsi:Cmsi" or
 86        "Consent:Set" or
 87        "Login:reprocess" or
 88        "Login:resume" or
 89        "MessagePrompt:MessagePrompt" or
 90        "SAS:EndAuth"
 91    )
 92'''
 93
 94
 95[[rule.threat]]
 96framework = "MITRE ATT&CK"
 97[[rule.threat.technique]]
 98id = "T1078"
 99name = "Valid Accounts"
100reference = "https://attack.mitre.org/techniques/T1078/"
101[[rule.threat.technique.subtechnique]]
102id = "T1078.004"
103name = "Cloud Accounts"
104reference = "https://attack.mitre.org/techniques/T1078/004/"
105
106
107
108[rule.threat.tactic]
109id = "TA0001"
110name = "Initial Access"
111reference = "https://attack.mitre.org/tactics/TA0001/"
112
113[rule.investigation_fields]
114field_names = [
115    "@timestamp",
116    "organization.id",
117    "o365.audit.UserId",
118    "o365.audit.ActorIpAddress",
119    "o365.audit.ApplicationId",
120    "o365.audit.ExtendedProperties.RequestType",
121    "o365.audit.Target.ID",
122    "source.geo.region_iso_code",
123]
124
125[rule.new_terms]
126field = "new_terms_fields"
127value = ["o365.audit.UserId", "source.geo.region_iso_code"]
128[[rule.new_terms.history_window_start]]
129field = "history_window_start"
130value = "now-14d"

Triage and analysis

Investigating M365 Identity Login from Atypical Travel Location

Microsoft 365 is a cloud-based suite offering productivity tools accessible from anywhere, making it crucial for business operations. Adversaries may exploit this by logging in from uncommon locations, potentially using VPNs to mask their origin. The detection rule identifies successful logins from atypical locations, flagging potential unauthorized access attempts by analyzing login events and user location patterns.

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. These could also indicate mobile and endpoint logins causing false-positives.

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.
  • Consider adding exceptions to this rule for the user or source application ID if the login attempts are determined to be legitimate and not a security concern.

References

Related rules

to-top