Skip to content

Commit c6e37d6

Browse files
[Rule Tuning] Tuning Illicit Grant Consent Detections in Azure and M365 (#4557)
* tuning Azure rule for illicit grant activity; creating new rule for M365 * Update rules/integrations/o365/initial_access_microsoft_365_illicit_consent_grant_via_registered_application.toml * Update rules/integrations/azure/initial_access_entra_illicit_consent_grant_via_registered_application.toml * adjusted tags * Update rules/integrations/azure/initial_access_entra_illicit_consent_grant_via_registered_application.toml
1 parent 2801406 commit c6e37d6

3 files changed

+299
-126
lines changed

rules/integrations/azure/initial_access_consent_grant_attack_via_azure_registered_application.toml

Lines changed: 0 additions & 126 deletions
This file was deleted.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
[metadata]
2+
creation_date = "2020/09/01"
3+
integration = ["azure"]
4+
maturity = "production"
5+
updated_date = "2025/03/24"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
Identifies an illicit consent grant request on-behalf-of a registered Entra ID application. Adversaries may create and
11+
register an application in Microsoft Entra ID for the purpose of requesting user consent to access resources. This is
12+
accomplished by tricking a user into granting consent to the application, typically via a pre-made phishing URL. This
13+
establishes an OAuth grant that allows the malicious client applocation to access resources on-behalf-of the user.
14+
"""
15+
from = "now-9m"
16+
index = ["filebeat-*", "logs-azure*"]
17+
language = "kuery"
18+
license = "Elastic License v2"
19+
name = "Microsoft Entra ID Illicit Consent Grant via Registered Application"
20+
note = """## Triage and analysis
21+
22+
### Investigating Microsoft Entra ID Illicit Consent Grant via Registered Application
23+
24+
Adversaries may register a malicious application in Microsoft Entra ID and trick users into granting excessive permissions via OAuth consent. These applications can access sensitive data—such as mail, profiles, or files—on behalf of the user once consent is granted. This is commonly delivered via spearphishing links that prompt users to approve permissions for seemingly legitimate applications.
25+
26+
This rule identifies a new consent grant event based on Azure audit logs where the application was granted access with potentially risky scopes, such as offline_access, Mail.Read, or User.Read, and may include admin consent or tenant-wide delegation.
27+
28+
This is a New Terms rule that will only trigger if the user and client ID have not been seen doing this activity in the last 14 days.
29+
30+
#### Possible investigation steps
31+
32+
- Review `azure.auditlogs.properties.additional_details.value` to identify the AppId and User-Agent values to determine which application was granted access and how the request was initiated. Pivot on the AppId in the Azure portal under Enterprise Applications to investigate further.
33+
- Review `azure.auditlogs.properties.initiated_by.user.userPrincipalName` to identify the user who approved the application. Investigate their recent activity for signs of phishing, account compromise, or anomalous behavior during the timeframe of the consent.
34+
- Review `azure.auditlogs.properties.initiated_by.user.ipAddress` to assess the geographic source of the consent action. Unexpected locations or IP ranges may indicate adversary-controlled infrastructure.
35+
- Review `azure.auditlogs.properties.target_resources.display_name` to evaluate whether the application name is familiar, expected, or potentially spoofing a known service.
36+
- Review `azure.auditlogs.properties.target_resources.modified_properties.display_name` to inspect key indicators of elevated privilege or risk, including:
37+
- ConsentContext.IsAdminConsent to determine if the application was granted tenant-wide admin access.
38+
- ConsentContext.OnBehalfOfAll to identify whether the app was granted permissions on behalf of all users in the tenant.
39+
- ConsentAction.Permissions to evaluate the specific scopes and data access the application requested.
40+
- ConsentAction.Reason to understand if Microsoft flagged the activity or if any reason was recorded by the platform.
41+
- TargetId.ServicePrincipalNames to confirm the service principal associated with the granted permissions.
42+
- Review `azure.tenant_id` to confirm the activity originated from your tenant and is not related to a cross-tenant application.
43+
- Review `@timestamp` and `azure.auditlogs.properties.correlation_id` to pivot into related sign-in, token usage, or application activity for further context.
44+
45+
### False positive analysis
46+
47+
- Some applications may request high-privilege scopes for legitimate purposes. Validate whether the application is verified, developed by Microsoft, or approved internally by your organization.
48+
- Review publisher verification, app ownership, and scope alignment with the intended business use case.
49+
50+
### Response and remediation
51+
52+
- Revoke the application’s OAuth grant using Graph API or PowerShell. Use the Remove-AzureADOAuth2PermissionGrant cmdlet.
53+
- Remove the associated service principal from Azure AD.
54+
- Reset credentials or revoke tokens for affected users.
55+
- Block the application via Conditional Access or Defender for Cloud Apps policies.
56+
- Enable the Admin Consent Workflow in Azure AD to prevent unsanctioned user approvals in the future.
57+
- Report any malicious applications to Microsoft to protect other tenants.
58+
"""
59+
references = [
60+
"https://www.wiz.io/blog/midnight-blizzard-microsoft-breach-analysis-and-best-practices",
61+
"https://docs.microsoft.com/en-us/microsoft-365/security/office-365-security/detect-and-remediate-illicit-consent-grants?view=o365-worldwide",
62+
"https://www.cloud-architekt.net/detection-and-mitigation-consent-grant-attacks-azuread/",
63+
"https://docs.microsoft.com/en-us/defender-cloud-apps/investigate-risky-oauth#how-to-detect-risky-oauth-apps",
64+
]
65+
risk_score = 47
66+
rule_id = "1c6a8c7a-5cb6-4a82-ba27-d5a5b8a40a38"
67+
severity = "medium"
68+
tags = [
69+
"Domain: Cloud",
70+
"Data Source: Azure",
71+
"Data Source: Microsoft Entra ID",
72+
"Data Source: Microsoft Entra ID Audit Logs",
73+
"Use Case: Identity and Access Audit",
74+
"Resources: Investigation Guide",
75+
"Tactic: Initial Access",
76+
"Tactic: Credential Access",
77+
]
78+
timestamp_override = "event.ingested"
79+
type = "new_terms"
80+
81+
query = '''
82+
event.dataset: "azure.auditlogs" and
83+
(
84+
azure.auditlogs.operation_name:"Consent to application"
85+
or event.action:"Consent to application"
86+
)
87+
and event.outcome: "success"
88+
and azure.auditlogs.properties.additional_details.key: "AppId"
89+
'''
90+
91+
92+
[[rule.threat]]
93+
framework = "MITRE ATT&CK"
94+
[[rule.threat.technique]]
95+
id = "T1566"
96+
name = "Phishing"
97+
reference = "https://attack.mitre.org/techniques/T1566/"
98+
[[rule.threat.technique.subtechnique]]
99+
id = "T1566.002"
100+
name = "Spearphishing Link"
101+
reference = "https://attack.mitre.org/techniques/T1566/002/"
102+
103+
104+
105+
[rule.threat.tactic]
106+
id = "TA0001"
107+
name = "Initial Access"
108+
reference = "https://attack.mitre.org/tactics/TA0001/"
109+
[[rule.threat]]
110+
framework = "MITRE ATT&CK"
111+
[[rule.threat.technique]]
112+
id = "T1528"
113+
name = "Steal Application Access Token"
114+
reference = "https://attack.mitre.org/techniques/T1528/"
115+
116+
117+
[rule.threat.tactic]
118+
id = "TA0006"
119+
name = "Credential Access"
120+
reference = "https://attack.mitre.org/tactics/TA0006/"
121+
122+
[rule.investigation_fields]
123+
field_names = [
124+
"@timestamp",
125+
"event.action",
126+
"event.outcome",
127+
"azure.auditlogs.properties.initiated_by.user.userPrincipalName",
128+
"azure.auditlogs.properties.initiated_by.user.ipAddress",
129+
"azure.auditlogs.properties.additional_details.value",
130+
"azure.tenant_id",
131+
"cloud.region",
132+
"azure.auditlogs.properties.target_resources.0.display_name"
133+
]
134+
135+
[rule.new_terms]
136+
field = "new_terms_fields"
137+
value = [
138+
"azure.auditlogs.properties.initiated_by.user.userPrincipalName",
139+
"azure.auditlogs.properties.additional_details.value",
140+
]
141+
[[rule.new_terms.history_window_start]]
142+
field = "history_window_start"
143+
value = "now-14d"
144+
145+

0 commit comments

Comments
 (0)