Skip to content

Commit 01c2889

Browse files
terrancedejesustradebot-elastic
authored andcommitted
[Rule Tuning] Microsoft Entra ID MFA TOTP Brute Force Attempts (#4937)
* tuning rule 'Microsoft Entra ID MFA TOTP Brute Force Attempts' * adjusted logic (cherry picked from commit 756a7f4)
1 parent 3abfb33 commit 01c2889

File tree

1 file changed

+81
-59
lines changed

1 file changed

+81
-59
lines changed

rules/integrations/azure/credential_access_azure_entra_totp_brute_force_attempts.toml

Lines changed: 81 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,90 +2,61 @@
22
creation_date = "2024/12/11"
33
integration = ["azure"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/07/28"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
1010
Identifies brute force attempts against Azure Entra multi-factor authentication (MFA) Time-based One-Time Password
1111
(TOTP) verification codes. This rule detects high frequency failed TOTP code attempts for a single user in a short
12-
time-span. Adversaries with valid credentials, when attempting to login to Azure portal or other Azure services, may be
13-
prompted to provide a TOTP code as part of the MFA process. If successful, adversaries can bypass MFA and gain
14-
unauthorized access to Azure resources.
12+
time-span with a high number of distinct session IDs. Adversaries may programmatically attemopt to brute-force TOTP
13+
codes by generating several sessions and attempt to guess the correct code.
1514
"""
1615
false_positives = [
1716
"""
1817
Based on the high-frequency threshold, it would be unlikely for a legitimate user to exceed the threshold for failed
19-
TOTP code attempts in a short time-span.
18+
TOTP code attempts in a short time-span over multiple sessions.
2019
""",
2120
]
2221
from = "now-9m"
2322
language = "esql"
2423
license = "Elastic License v2"
25-
name = "Azure Entra MFA TOTP Brute Force Attempts"
24+
name = "Microsoft Entra ID MFA TOTP Brute Force Attempts"
2625
note = """## Triage and analysis
2726
28-
### Investigating Azure Entra MFA TOTP Brute Force Attempts
27+
### Investigating Microsoft Entra ID MFA TOTP Brute Force Attempts
2928
30-
This rule detects high-frequency failed TOTP code attempts for a single user in a short time span. Such behavior could indicate an adversary attempting to bypass multi-factor authentication (MFA) protections using valid credentials. Understanding the context of the user's typical behavior and identifying anomalies in the log data are critical to determining the nature of the activity.
29+
This rule detects brute force attempts against Azure Entra multi-factor authentication (MFA) Time-based One-Time Password (TOTP) verification codes. It identifies high-frequency failed TOTP code attempts for a single user in a short time-span with a high number of distinct session IDs. Adversaries may programmatically attempt to brute-force TOTP codes by generating several sessions and attempting to guess the correct code.
3130
3231
#### Possible Investigation Steps:
3332
34-
**Review the Source IP Address**:
35-
- Check the `source.ip` or `azure.signinlogs.caller_ip_address` field.
36-
- Determine if the IP address is associated with the user’s typical login locations.
33+
- Check the source addresses associated with the failed TOTP attempts.
34+
- Determine if the source IP address is consistent with the user’s typical login locations.
3735
- Look for unusual geographic patterns or anomalous IP addresses (e.g., proxies, VPNs, or locations outside the user’s normal activity).
38-
39-
**Analyze User Activity**:
40-
- Identify the user from the `azure.signinlogs.properties.sign_in_identifier` field.
41-
- Determine if the user is currently active from another device or session. Session hijacking could explain parallel activity with failed attempts.
42-
- Review past logs for the user to determine whether MFA failures or other anomalies are consistent or new.
43-
44-
**Inspect the Authentication Method**:
45-
- Evaluate the `azure.signinlogs.properties.mfa_detail.auth_method` field: `OATH verification code`.
46-
- Confirm if the user typically uses TOTP codes or another MFA method (e.g., push notifications).
47-
- Verify if there are any recent changes to the user’s MFA settings that may explain multiple failed attempts.
48-
49-
**Evaluate the User Agent**:
50-
- Check the `user_agent.original` field.
51-
- Identify if the user agent matches a typical browser or a potentially malicious script (e.g., Python-based).
52-
- Look for deviations in operating system or browser versions from the user’s normal activity.
53-
54-
**Analyze Conditional Access Policies**:
55-
- Review the `azure.signinlogs.properties.applied_conditional_access_policies` for enforced grant controls.
56-
- Verify if MFA failures are tied to legitimate security policies (`display_name: Require multifactor authentication for admins`).
57-
58-
**Correlate with Other Events**:
59-
- Search for other authentication attempts involving the same `azure.signinlogs.caller_ip_address`, `user_principal_name`, or `azure.signinlogs.properties.app_id`.
60-
- Look for suspicious activity patterns, such as password resets, privilege escalation, or account lockouts.
61-
36+
- Review the error code associated with the failed attempts. This can help identify if the failures are due to incorrect TOTP codes or other issues.
37+
- Verify that that auth metho reported is `OAth` as it indicates the use of TOTP codes.
38+
- Pivot into signin logs for the target user and check if auth via TOTP was successful which would indicate a successful brute force attempt.
39+
- Review conditional access policies applied to the user or group as reported by the sign-in logs.
40+
- Analyze the client application ID and display name to determine if the attempts are coming from a legitimate application or a potentially malicious script.
41+
- Adversaries may use legitimate FOCI applications to bypass security controls or make login attempts appear legitimate.
42+
- Review the resource ID access is being attempted against such as MyApps, Microsoft Graph, or other resources. This can help identify if the attempts are targeting specific applications or services.
43+
- The correlation IDs or session IDs can be used to trace the authentication attempts across different logs or systems. Note that for this specific behavior, unique session ID count is high and could be challenging to correlate.
6244
6345
#### False Positive Analysis:
6446
65-
- **Unintentional User Behavior**:
6647
- Verify if the failed attempts could result from the user’s unfamiliarity with TOTP codes or issues with device synchronization.
6748
- Check if the user recently switched MFA methods or devices, which could explain multiple failures.
6849
- Determine if this is whitebox testing or a developer testing MFA integration.
6950
70-
- **Administrative Actions**:
71-
- Determine if the activity is related to legitimate administrative testing or configuration changes in the MFA system.
72-
7351
#### Response and Remediation:
7452
75-
- **Immediate Actions**:
7653
- If proven malicious, lock the affected account temporarily to prevent further unauthorized attempts.
7754
- Notify the user of suspicious activity and validate their access to the account.
7855
- Reset passwords and MFA settings for the affected user to prevent unauthorized access while communicating with the user.
79-
80-
- **Strengthen Authentication Policies**:
8156
- Ensure conditional access policies are configured to monitor and restrict anomalous login behavior.
8257
- Consider a different MFA method or additional security controls to prevent future bypass attempts.
83-
84-
- **Monitor and Audit**:
8558
- Implement additional monitoring to track high-frequency authentication failures across the environment.
8659
- Audit historical logs for similar patterns involving other accounts to identify broader threats.
87-
88-
- **Educate and Train Users**:
8960
- Provide guidance on the secure use of MFA and the importance of recognizing and reporting suspicious activity.
9061
"""
9162
references = [
@@ -95,16 +66,16 @@ references = [
9566
]
9667
risk_score = 47
9768
rule_id = "3fac01b2-b811-11ef-b25b-f661ea17fbce"
98-
setup = """#### Required Azure Entra Sign-In Logs
99-
This rule requires the Azure logs integration be enabled and configured to collect all logs, including sign-in logs from Entra. In Entra, sign-in logs must be enabled and streaming to the Event Hub used for the Azure logs integration.
69+
setup = """#### Required Entra ID Sign-In Logs
70+
This rule requires the Entra ID sign-in logs via the Azure integration be enabled. In Entra ID, sign-in logs must be enabled and streaming to the Event Hub used for the Entra ID logs integration.
10071
"""
10172
severity = "medium"
10273
tags = [
10374
"Domain: Cloud",
104-
"Domain: SaaS",
75+
"Domain: Identity",
10576
"Data Source: Azure",
10677
"Data Source: Entra ID",
107-
"Data Source: Entra ID Sign-in",
78+
"Data Source: Entra ID Sign-in logs",
10879
"Use Case: Identity and Access Audit",
10980
"Use Case: Threat Detection",
11081
"Tactic: Credential Access",
@@ -115,25 +86,76 @@ type = "esql"
11586

11687
query = '''
11788
from logs-azure.signinlogs* metadata _id, _version, _index
89+
11890
| where
11991
// filter for Entra Sign-In Logs
12092
event.dataset == "azure.signinlogs"
12193
and azure.signinlogs.operation_name == "Sign-in activity"
94+
and azure.signinlogs.properties.user_type == "Member"
12295
12396
// filter for MFA attempts with OATH conditional access attempts or TOTP
124-
and azure.signinlogs.properties.authentication_requirement == "multiFactorAuthentication"
12597
and azure.signinlogs.properties.mfa_detail.auth_method == "OATH verification code"
12698
12799
// filter on failures only from brute-force attempts
128-
and azure.signinlogs.properties.conditional_access_status == "failure"
129-
and azure.signinlogs.result_description == "Authentication failed during strong authentication request."
130-
| keep azure.signinlogs.properties.sign_in_identifier
100+
and (
101+
(
102+
azure.signinlogs.result_signature == "FAILURE" and
103+
azure.signinlogs.result_description == "Authentication failed during strong authentication request."
104+
) or azure.signinlogs.properties.status.error_code == 500121
105+
)
106+
131107
| stats
132-
// aggregate by the sign-in account or principal
133-
failed_totp_code_attempts = count(*) by azure.signinlogs.properties.sign_in_identifier
134-
| where
135-
// filter on high frequency for a single user
136-
failed_totp_code_attempts > 30
108+
Esql.event_count = COUNT(*),
109+
Esql.azure_signinlogs_properties.session_id_count_distinct = COUNT_DISTINCT(azure.signinlogs.properties.session_id),
110+
Esql.source_address_values = VALUES(source.address),
111+
Esql.azure_tenant_id_valuues = VALUES(azure.tenant_id),
112+
Esql_priv.azure_identity_values = VALUES(azure.signinlogs.identity),
113+
Esql_priv.azure_signinlogs_properties_user_principal_name_values = VALUES(azure.signinlogs.properties.user_principal_name),
114+
Esql.azure_signinlogs_properties_app_id_values = VALUES(azure.signinlogs.properties.app_id),
115+
Esql.azure_signinlogs_properties_app_display_name_values = VALUES(azure.signinlogs.properties.app_display_name),
116+
Esql.azure_signinlogs_properties_authentication_requirement_values = VALUES(azure.signinlogs.properties.authentication_requirement),
117+
Esql.azure_signinlogs_properties_authentication_protocol_values = VALUES(azure.signinlogs.properties.authentication_protocol),
118+
Esql.azure_signinlogs_properties_client_app_used_values = VALUES(azure.signinlogs.properties.client_app_used),
119+
Esql.azure_signinlogs_properties_client_credential_type_values = VALUES(azure.signinlogs.properties.client_credential_type),
120+
Esql.azure_signinlogs_properties_conditional_access_status_values = VALUES(azure.signinlogs.properties.conditional_access_status),
121+
Esql.azure_signinlogs_properties_correlation_id_values = VALUES(azure.signinlogs.properties.correlation_id),
122+
Esql.azure_signinlogs_properties_is_interactive_values = VALUES(azure.signinlogs.properties.is_interactive),
123+
Esql.azure_signinlogs_properties_mfa_detail_auth_method_values = VALUES(azure.signinlogs.properties.mfa_detail.auth_method),
124+
Esql.azure_signinlogs_properties_resource_display_name_values = VALUES(azure.signinlogs.properties.resource_display_name),
125+
Esql.azure_signinlogs_properties_resource_id_values = VALUES(azure.signinlogs.properties.resource_id),
126+
Esql.azure_signinlogs_properties_risk_state_values = VALUES(azure.signinlogs.properties.risk_state),
127+
Esql.azure_signinlogs_properties_risk_detail_values = VALUES(azure.signinlogs.properties.risk_detail),
128+
Esql.azure_signinlogs_properties_status.error_code_values = VALUES(azure.signinlogs.properties.status.error_code),
129+
Esql.azure_signinlogs_properties_original_request_id_values = VALUES(azure.signinlogs.properties.original_request_id),
130+
Esql.user_id_values = VALUES(user.id)
131+
by user.id
132+
133+
| where Esql.event_count >= 20 and Esql.azure_signinlogs_properties.session_id_count_distinct >= 10
134+
135+
| keep
136+
Esql.event_count,
137+
Esql.azure_signinlogs_properties.session_id_count_distinct,
138+
Esql.source_address_values,
139+
Esql.azure_tenant_id_valuues,
140+
Esql_priv.azure_identity_values,
141+
Esql_priv.azure_signinlogs_properties_user_principal_name_values,
142+
Esql.azure_signinlogs_properties_app_id_values,
143+
Esql.azure_signinlogs_properties_app_display_name_values,
144+
Esql.azure_signinlogs_properties_authentication_requirement_values,
145+
Esql.azure_signinlogs_properties_authentication_protocol_values,
146+
Esql.azure_signinlogs_properties_client_app_used_values,
147+
Esql.azure_signinlogs_properties_client_credential_type_values,
148+
Esql.azure_signinlogs_properties_conditional_access_status_values,
149+
Esql.azure_signinlogs_properties_correlation_id_values,
150+
Esql.azure_signinlogs_properties_is_interactive_values,
151+
Esql.azure_signinlogs_properties_mfa_detail_auth_method_values,
152+
Esql.azure_signinlogs_properties_resource_display_name_values,
153+
Esql.azure_signinlogs_properties_resource_id_values,
154+
Esql.azure_signinlogs_properties_risk_state_values,
155+
Esql.azure_signinlogs_properties_risk_detail_values,
156+
Esql.azure_signinlogs_properties_status.error_code_values,
157+
Esql.azure_signinlogs_properties_original_request_id_values,
158+
Esql.user_id_values
137159
'''
138160

139161

0 commit comments

Comments
 (0)