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/09/18"
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 "Noise: Medium",
77 "Performance: Normal",
78 "Rule Type: ES|QL",
79 "Platform: Entra ID",
80 "Domain: Identity",
81 "Platform: Microsoft 365",
82 "Domain: Email",
83]
84timestamp_override = "event.ingested"
85type = "esql"
86
87query = '''
88from logs-o365.audit-*, logs-azure.signinlogs-*, .alerts-security.*
89// filter for azure or m365 sign-in and external alerts with source.ip not null
90| where to_ip(source.ip) is not null
91 and (data_stream.dataset in ("o365.audit", "azure.signinlogs") or kibana.alert.rule.rule_id == "eb079c62-4481-4d6e-9643-3ca499df7aaa")
92 and not cidr_match(
93 to_ip(source.ip),
94 "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",
95 "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",
96 "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",
97 "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",
98 "240.0.0.0/4", "::1", "FE80::/10", "FF00::/8"
99 )
100
101// capture relevant raw fields
102| keep source.ip, event.action, event.outcome, data_stream.dataset, kibana.alert.rule.rule_id, event.category
103
104// classify each source ip based on alert type
105| eval
106 Esql.source_ip_mail_access_case = case(data_stream.dataset == "o365.audit" and event.action == "MailItemsAccessed" and event.outcome == "success", to_ip(source.ip)),
107 Esql.source_ip_azure_signin_case = case(data_stream.dataset == "azure.signinlogs" and event.outcome == "success", to_ip(source.ip)),
108 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))
109
110// aggregate by source ip
111| stats
112 Esql.event_count = count(*),
113 Esql.source_ip_mail_access_case_count_distinct = count_distinct(Esql.source_ip_mail_access_case),
114 Esql.source_ip_azure_signin_case_count_distinct = count_distinct(Esql.source_ip_azure_signin_case),
115 Esql.source_ip_network_alert_case_count_distinct = count_distinct(Esql.source_ip_network_alert_case),
116 Esql.data_stream_dataset_count_distinct = count_distinct(data_stream.dataset),
117 Esql.data_stream_dataset_values = values(data_stream.dataset),
118 Esql.kibana_alert_rule_id_values = values(kibana.alert.rule.rule_id),
119 Esql.event_category_values = values(event.category)
120 by Esql.source_ip = to_ip(source.ip)
121
122// correlation condition
123| where
124 Esql.source_ip_network_alert_case_count_distinct > 0
125 and Esql.data_stream_dataset_count_distinct >= 2
126 and (Esql.source_ip_mail_access_case_count_distinct > 0 or Esql.source_ip_azure_signin_case_count_distinct > 0)
127 and Esql.event_count <= 100
128'''
129
130
131[[rule.threat]]
132framework = "MITRE ATT&CK"
133[[rule.threat.technique]]
134id = "T1078"
135name = "Valid Accounts"
136reference = "https://attack.mitre.org/techniques/T1078/"
137
138
139[rule.threat.tactic]
140id = "TA0001"
141name = "Initial Access"
142reference = "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 Kali365 Default User-Agent Detected
- M365 Identity Device Code Grant by an Unusual User (Non-Compliant Device)
- Entra ID OAuth Flow by Microsoft Authentication Broker to Device Registration Service (DRS)
- Entra ID Sign-in BloodHound Suite User-Agent Detected
- Entra ID Sign-in Brute Force Attempted (Microsoft 365)