|
| 1 | +[metadata] |
| 2 | +creation_date = "2024/09/04" |
| 3 | +integration = ["o365"] |
| 4 | +maturity = "production" |
| 5 | +updated_date = "2025/08/26" |
| 6 | + |
| 7 | +[rule] |
| 8 | +author = ["Elastic"] |
| 9 | +description = """ |
| 10 | +Detects successful Microsoft 365 portal logins from rare locations. Rare locations are defined as locations that are not |
| 11 | +commonly associated with the user's account. This behavior may indicate an adversary attempting to access a Microsoft |
| 12 | +365 account from an unusual location or behind a VPN. |
| 13 | +""" |
| 14 | +false_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 | +] |
| 22 | +from = "now-15m" |
| 23 | +index = ["filebeat-*", "logs-o365.audit-*"] |
| 24 | +language = "kuery" |
| 25 | +license = "Elastic License v2" |
| 26 | +name = "M365 Portal Login (Atypical Travel)" |
| 27 | +note = """## Triage and analysis |
| 28 | +
|
| 29 | +### Investigating M365 Portal Login (Atypical Travel) |
| 30 | +
|
| 31 | +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. |
| 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. |
| 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 | +""" |
| 54 | +references = ["https://www.huntress.com/blog/time-travelers-busted-how-to-detect-impossible-travel-"] |
| 55 | +risk_score = 47 |
| 56 | +rule_id = "32d3ad0e-6add-11ef-8c7b-f661ea17fbcc" |
| 57 | +severity = "medium" |
| 58 | +tags = [ |
| 59 | + "Domain: Cloud", |
| 60 | + "Domain: SaaS", |
| 61 | + "Data Source: Microsoft 365", |
| 62 | + "Data Source: Microsoft 365 Audit Logs", |
| 63 | + "Use Case: Threat Detection", |
| 64 | + "Use Case: Identity and Access Audit", |
| 65 | + "Tactic: Initial Access", |
| 66 | + "Resources: Investigation Guide", |
| 67 | +] |
| 68 | +timestamp_override = "event.ingested" |
| 69 | +type = "new_terms" |
| 70 | + |
| 71 | +query = ''' |
| 72 | +event.dataset:o365.audit and |
| 73 | + event.provider:AzureActiveDirectory and |
| 74 | + event.action:UserLoggedIn and |
| 75 | + event.outcome:success and |
| 76 | + o365.audit.Target.Type:(0 or 10 or 2 or 3 or 5 or 6) and |
| 77 | + o365.audit.UserId:(* and not "Not Available") and |
| 78 | + source.geo.region_iso_code:* and |
| 79 | + o365.audit.Target.ID:( |
| 80 | + 00000006-0000-0ff1-ce00-000000000000 or |
| 81 | + 4765445b-32c6-49b0-83e6-1d93765276ca |
| 82 | + ) and not o365.audit.ApplicationId:( |
| 83 | + 29d9ed98-a469-4536-ade2-f981bc1d605e or |
| 84 | + 38aa3b87-a06d-4817-b275-7a316988d93b or |
| 85 | + a809996b-059e-42e2-9866-db24b99a9782 |
| 86 | + ) and not o365.audit.ExtendedProperties.RequestType:( |
| 87 | + "Cmsi:Cmsi" or |
| 88 | + "Consent:Set" or |
| 89 | + "Login:reprocess" or |
| 90 | + "Login:resume" or |
| 91 | + "MessagePrompt:MessagePrompt" or |
| 92 | + "SAS:EndAuth" |
| 93 | + ) |
| 94 | +''' |
| 95 | + |
| 96 | + |
| 97 | +[[rule.threat]] |
| 98 | +framework = "MITRE ATT&CK" |
| 99 | +[[rule.threat.technique]] |
| 100 | +id = "T1078" |
| 101 | +name = "Valid Accounts" |
| 102 | +reference = "https://attack.mitre.org/techniques/T1078/" |
| 103 | +[[rule.threat.technique.subtechnique]] |
| 104 | +id = "T1078.004" |
| 105 | +name = "Cloud Accounts" |
| 106 | +reference = "https://attack.mitre.org/techniques/T1078/004/" |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | +[rule.threat.tactic] |
| 111 | +id = "TA0001" |
| 112 | +name = "Initial Access" |
| 113 | +reference = "https://attack.mitre.org/tactics/TA0001/" |
| 114 | + |
| 115 | +[rule.investigation_fields] |
| 116 | +field_names = [ |
| 117 | + "@timestamp", |
| 118 | + "organization.id", |
| 119 | + "o365.audit.UserId", |
| 120 | + "o365.audit.ActorIpAddress", |
| 121 | + "o365.audit.ApplicationId", |
| 122 | + "o365.audit.ExtendedProperties.RequestType", |
| 123 | + "o365.audit.Target.ID", |
| 124 | + "source.geo.region_iso_code", |
| 125 | +] |
| 126 | + |
| 127 | +[rule.new_terms] |
| 128 | +field = "new_terms_fields" |
| 129 | +value = ["o365.audit.UserId", "source.geo.region_iso_code"] |
| 130 | +[[rule.new_terms.history_window_start]] |
| 131 | +field = "history_window_start" |
| 132 | +value = "now-14d" |
| 133 | + |
| 134 | + |
0 commit comments