M365 or Entra ID Identity Sign-in from a Suspicious Source
This rule correlate Entra-ID or Microsoft 365 mail successful sign-in events with network security alerts by source address. Adversaries may trigger some network security alerts such as reputation or other anomalies before accessing cloud resources.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/04/29"
3integration = ["azure", "o365"]
4maturity = "production"
5updated_date = "2026/05/22"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule correlate Entra-ID or Microsoft 365 mail successful sign-in events with network security alerts by source address.
11Adversaries may trigger some network security alerts such as reputation or other anomalies before accessing cloud
12resources.
13"""
14false_positives = [
15 """
16 Custom network security rules that triggers on a proxy or gateway used by users to access Azure or O365.
17 """,
18]
19from = "now-8h"
20interval="1h"
21language = "esql"
22license = "Elastic License v2"
23name = "M365 or Entra ID Identity Sign-in from a Suspicious Source"
24note = """## Triage and analysis
25
26### Investigating M365 or Entra ID Identity Sign-in from a Suspicious Source
27
28#### Possible investigation steps
29
30- Investiguate all the alerts associated with the source.ip.
31 - Verify the network security alert details associated with this source.ip.
32 - Verify all sign-in events associated with this source.ip.
33 - Consider the source IP address and geolocation for the involved user account.
34 - Consider the device used to sign in. Is it registered and compliant?
35- Investigate other alerts associated with the user account during the past 48 hours.
36- Contact the account owner and confirm whether they are aware of this activity.
37- Check if this operation was approved and performed according to the organization's change management policy.
38- If you suspect the account has been compromised, scope potentially compromised assets by tracking servers, services, and data accessed by the account in the last 24 hours.
39
40### Response and remediation
41
42- Initiate the incident response process based on the outcome of the triage.
43- Disable or limit the account during the investigation and response.
44- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
45 - Identify the account role in the cloud environment.
46 - Assess the criticality of affected services and servers.
47 - Work with your IT team to identify and minimize the impact on users.
48 - Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
49 - Identify any regulatory or legal ramifications related to this activity.
50- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords or delete API keys as needed to revoke the attacker's access to the environment. Work with your IT teams to minimize the impact on business operations during these actions.
51- Check if unauthorized new users were created, remove unauthorized new accounts, and request password resets for other IAM users.
52- Consider enabling multi-factor authentication for users.
53- Follow security best practices [outlined](https://docs.microsoft.com/en-us/azure/security/fundamentals/identity-management-best-practices) by Microsoft.
54- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
55- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
56
57## Setup
58
59The Azure Fleet integration, Office 365 Logs Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule."""
60risk_score = 73
61rule_id = "f0cc239b-67fa-46fc-89d4-f861753a40f5"
62severity = "high"
63tags = [
64 "Domain: Cloud",
65 "Domain: SaaS",
66 "Data Source: Azure",
67 "Data Source: Entra ID",
68 "Data Source: Entra ID Sign-in Logs",
69 "Data Source: Microsoft 365",
70 "Data Source: Microsoft 365 Audit Logs",
71 "Use Case: Identity and Access Audit",
72 "Use Case: Threat Detection",
73 "Tactic: Initial Access",
74 "Resources: Investigation Guide",
75 "Rule Type: Higher-Order Rule",
76]
77timestamp_override = "event.ingested"
78type = "esql"
79
80query = '''
81from logs-o365.audit-*, logs-azure.signinlogs-*, .alerts-security.*
82// filter for azure or m365 sign-in and external alerts with source.ip not null
83| where to_ip(source.ip) is not null
84 and (data_stream.dataset in ("o365.audit", "azure.signinlogs") or kibana.alert.rule.rule_id == "eb079c62-4481-4d6e-9643-3ca499df7aaa")
85 and not cidr_match(
86 to_ip(source.ip),
87 "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29",
88 "192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24",
89 "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24", "224.0.0.0/4",
90 "100.64.0.0/10", "192.175.48.0/24", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24",
91 "240.0.0.0/4", "::1", "FE80::/10", "FF00::/8"
92 )
93
94// capture relevant raw fields
95| keep source.ip, event.action, event.outcome, data_stream.dataset, kibana.alert.rule.rule_id, event.category
96
97// classify each source ip based on alert type
98| eval
99 Esql.source_ip_mail_access_case = case(data_stream.dataset == "o365.audit" and event.action == "MailItemsAccessed" and event.outcome == "success", to_ip(source.ip)),
100 Esql.source_ip_azure_signin_case = case(data_stream.dataset == "azure.signinlogs" and event.outcome == "success", to_ip(source.ip)),
101 Esql.source_ip_network_alert_case = case(kibana.alert.rule.rule_id == "eb079c62-4481-4d6e-9643-3ca499df7aaa" and not data_stream.dataset in ("o365.audit", "azure.signinlogs"), to_ip(source.ip))
102
103// aggregate by source ip
104| stats
105 Esql.event_count = count(*),
106 Esql.source_ip_mail_access_case_count_distinct = count_distinct(Esql.source_ip_mail_access_case),
107 Esql.source_ip_azure_signin_case_count_distinct = count_distinct(Esql.source_ip_azure_signin_case),
108 Esql.source_ip_network_alert_case_count_distinct = count_distinct(Esql.source_ip_network_alert_case),
109 Esql.data_stream_dataset_count_distinct = count_distinct(data_stream.dataset),
110 Esql.data_stream_dataset_values = values(data_stream.dataset),
111 Esql.kibana_alert_rule_id_values = values(kibana.alert.rule.rule_id),
112 Esql.event_category_values = values(event.category)
113 by Esql.source_ip = to_ip(source.ip)
114
115// correlation condition
116| where
117 Esql.source_ip_network_alert_case_count_distinct > 0
118 and Esql.data_stream_dataset_count_distinct >= 2
119 and (Esql.source_ip_mail_access_case_count_distinct > 0 or Esql.source_ip_azure_signin_case_count_distinct > 0)
120 and Esql.event_count <= 100
121'''
122
123
124[[rule.threat]]
125framework = "MITRE ATT&CK"
126[[rule.threat.technique]]
127id = "T1078"
128name = "Valid Accounts"
129reference = "https://attack.mitre.org/techniques/T1078/"
130
131
132[rule.threat.tactic]
133id = "TA0001"
134name = "Initial Access"
135reference = "https://attack.mitre.org/tactics/TA0001/"
Triage and analysis
Investigating M365 or Entra ID Identity Sign-in from a Suspicious Source
Possible investigation steps
- Investiguate all the alerts associated with the source.ip.
- Verify the network security alert details associated with this source.ip.
- Verify all sign-in events associated with this source.ip.
- Consider the source IP address and geolocation for the involved user account.
- Consider the device used to sign in. Is it registered and compliant?
- Investigate other alerts associated with the user account during the past 48 hours.
- Contact the account owner and confirm whether they are aware of this activity.
- Check if this operation was approved and performed according to the organization's change management policy.
- If you suspect the account has been compromised, scope potentially compromised assets by tracking servers, services, and data accessed by the account in the last 24 hours.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Disable or limit the account during the investigation and response.
- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
- Identify the account role in the cloud environment.
- Assess the criticality of affected services and servers.
- Work with your IT team to identify and minimize the impact on users.
- Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
- Identify any regulatory or legal ramifications related to this activity.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords or delete API keys as needed to revoke the attacker's access to the environment. Work with your IT teams to minimize the impact on business operations during these actions.
- Check if unauthorized new users were created, remove unauthorized new accounts, and request password resets for other IAM users.
- Consider enabling multi-factor authentication for users.
- Follow security best practices outlined by Microsoft.
- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
Setup
The Azure Fleet integration, Office 365 Logs Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule.
Related rules
- Entra ID OAuth Flow by Microsoft Authentication Broker to Device Registration Service (DRS)
- Entra ID Sign-in Brute Force Attempted (Microsoft 365)
- M365 Potential AiTM UserLoggedIn via Office App (Tycoon2FA)
- M365 Identity Login from Atypical Region
- M365 Identity Login from Impossible Travel Location