Skip to content

Commit 8b293e7

Browse files
adjusting/adding consentfix detections
1 parent 6ac69db commit 8b293e7

10 files changed

+743
-280
lines changed

rules/integrations/azure/collection_graph_email_access_by_unusual_public_client_via_graph.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2025/05/06"
33
integration = ["azure"]
44
maturity = "production"
5-
updated_date = "2025/12/10"
5+
updated_date = "2025/12/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -61,6 +61,7 @@ references = [
6161
"https://www.volexity.com/blog/2025/04/22/phishing-for-codes-russian-threat-actors-target-microsoft-365-oauth-workflows/",
6262
"https://github.com/dirkjanm/ROADtools",
6363
"https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/",
64+
"https://pushsecurity.com/blog/consentfix",
6465
]
6566
risk_score = 47
6667
rule_id = "e882e934-2aaa-11f0-8272-f661ea17fbcc"

rules/integrations/azure/initial_access_entra_id_graph_single_session_from_multiple_addresses.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2025/05/08"
33
integration = ["azure"]
44
maturity = "production"
5-
updated_date = "2025/12/10"
5+
updated_date = "2025/12/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -64,6 +64,7 @@ references = [
6464
"https://www.volexity.com/blog/2025/04/22/phishing-for-codes-russian-threat-actors-target-microsoft-365-oauth-workflows/",
6565
"https://github.com/dirkjanm/ROADtools",
6666
"https://attack.mitre.org/techniques/T1078/004/",
67+
"https://pushsecurity.com/blog/consentfix",
6768
]
6869
risk_score = 47
6970
rule_id = "0d3d2254-2b4a-11f0-a019-f661ea17fbcc"
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
[metadata]
2+
creation_date = "2025/12/17"
3+
integration = ["azure"]
4+
maturity = "production"
5+
updated_date = "2025/12/17"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
Identifies the first occurrence of an OAuth 2.0 authorization code grant flow for a specific combination of client
11+
application, target resource, and user principal in Microsoft Entra ID. This rule uses split detection logic: (1)
12+
Developer tools like Azure CLI, Visual Studio Code, and Azure PowerShell accessing either Microsoft Graph or legacy AAD
13+
are flagged for first-time usage by a user. (2) Any FOCI (Family of Client IDs) application accessing legacy Windows
14+
Azure Active Directory for the first time by a user is flagged, as this deprecated resource is rarely accessed
15+
legitimately. This pattern is indicative of OAuth phishing attacks like ConsentFix, where attackers steal authorization
16+
codes and exchange them for tokens from attacker-controlled infrastructure.
17+
"""
18+
from = "now-9m"
19+
index = ["filebeat-*", "logs-azure.signinlogs-*"]
20+
language = "kuery"
21+
license = "Elastic License v2"
22+
name = "Entra ID OAuth Authorization Code Grant for Unusual User, App, and Resource"
23+
note = """## Triage and analysis
24+
25+
### Investigating Entra ID OAuth Authorization Code Grant for Unusual User, App, and Resource
26+
27+
This rule identifies the first occurrence of an OAuth 2.0 authorization code grant flow for a specific combination of client application ID, target resource ID, and user principal in Microsoft Entra ID. This is a New Terms rule that only fires when a user has not been observed using this specific app+resource combination in the last 14 days.
28+
29+
**Why This Matters for ConsentFix Detection:**
30+
31+
ConsentFix and similar OAuth phishing attacks exploit first-party Microsoft applications (Azure CLI, VS Code, Azure PowerShell) because:
32+
- They are trusted by default in all tenants
33+
- They can request permissions without admin approval
34+
- They cannot be deleted or blocked
35+
36+
When an attacker steals an OAuth authorization code and exchanges it for tokens, the resulting sign-in event shows:
37+
- The victim's UPN
38+
- The first-party app ID (e.g., Azure CLI)
39+
- A target resource (often legacy AAD for stealth)
40+
41+
If a user has never used Azure CLI to access Windows Azure Active Directory before, this is highly suspicious.
42+
43+
**Detection Logic 1 - Developer Tools → Graph or Legacy AAD (First-Time)**:
44+
- **Azure CLI**: `04b07795-8ddb-461a-bbee-02f9e1bf7b46`
45+
- **Visual Studio Code**: `aebc6443-996d-45c2-90f0-388ff96faa56`
46+
- **Azure PowerShell**: `1950a258-227b-4e31-a9cf-717495945fc2`
47+
48+
**Detection Logic 2 - Any FOCI App → Legacy AAD Only (First-Time)**:
49+
Any of the 38 FOCI family applications (Microsoft Office, Teams, Outlook, OneDrive, etc.) accessing legacy Windows Azure Active Directory for the first time by a user is suspicious because this deprecated API is rarely used legitimately.
50+
51+
### Sensitive Target Resources:
52+
- **Windows Azure Active Directory (Legacy)**: `00000002-0000-0000-c000-000000000000` - Deprecated, rarely legitimate
53+
- **Microsoft Graph**: `00000003-0000-0000-c000-000000000000` - Common but verify context
54+
55+
### Possible investigation steps
56+
57+
- Review `azure.signinlogs.properties.user_principal_name` to identify the affected user.
58+
- Confirm the `azure.signinlogs.properties.app_id` matches a first-party Microsoft application. If it's Azure CLI or Azure PowerShell and the user doesn't typically use these tools, this is suspicious.
59+
- Check `azure.signinlogs.properties.resource_id` to identify what resource was accessed. Legacy AAD (`00000002-0000-0000-c000-000000000000`) access by developer tools is unusual.
60+
- Analyze `source.ip` and `source.geo.*` for geographic anomalies. ConsentFix attackers exchange codes from different IPs than the victim.
61+
- Review `azure.signinlogs.properties.is_interactive` - if this is a non-interactive sign-in shortly after an interactive one from a different IP, it may indicate token replay.
62+
- Check `azure.signinlogs.properties.session_id` and correlate with other sign-in events to identify the full OAuth flow sequence.
63+
- Look for subsequent Graph API or AAD API activity from the same session or user from unusual locations.
64+
65+
### False positive analysis
66+
67+
- Developers or IT administrators legitimately using Azure CLI, PowerShell, or VS Code for the first time to access specific resources.
68+
- Users onboarding to new development environments or tools.
69+
- Automation scripts that run with user-delegated permissions for the first time.
70+
71+
### Response and remediation
72+
73+
- Contact the user to confirm if they initiated the OAuth flow and used the detected application.
74+
- If unauthorized, immediately revoke all refresh tokens for the user via Entra ID.
75+
- Review recent activity from the same session ID for signs of data access or enumeration.
76+
- Block the source IP if confirmed malicious.
77+
- Implement Conditional Access policies to restrict OAuth flows for these applications.
78+
- Educate users about OAuth phishing and the risks of pasting authorization codes.
79+
"""
80+
references = [
81+
"https://pushsecurity.com/blog/consentfix",
82+
"https://www.volexity.com/blog/2025/04/22/phishing-for-codes-russian-threat-actors-target-microsoft-365-oauth-workflows/",
83+
"https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow",
84+
"https://github.com/secureworks/family-of-client-ids-research",
85+
]
86+
risk_score = 47
87+
rule_id = "c8e5f6a2-1234-4d5e-9f8a-b7c6d5e4f3a2"
88+
severity = "medium"
89+
tags = [
90+
"Domain: Cloud",
91+
"Domain: Identity",
92+
"Data Source: Azure",
93+
"Data Source: Microsoft Entra ID",
94+
"Data Source: Microsoft Entra ID Sign-in Logs",
95+
"Use Case: Identity and Access Audit",
96+
"Use Case: Threat Detection",
97+
"Tactic: Initial Access",
98+
"Tactic: Credential Access",
99+
"Resources: Investigation Guide",
100+
]
101+
timestamp_override = "event.ingested"
102+
type = "new_terms"
103+
104+
query = '''
105+
event.dataset: "azure.signinlogs" and
106+
event.outcome: "success" and
107+
azure.signinlogs.properties.user_type: "Member" and
108+
(
109+
(
110+
azure.signinlogs.properties.app_id: (
111+
"04b07795-8ddb-461a-bbee-02f9e1bf7b46" or
112+
"aebc6443-996d-45c2-90f0-388ff96faa56" or
113+
"1950a258-227b-4e31-a9cf-717495945fc2"
114+
) and
115+
azure.signinlogs.properties.resource_id: (
116+
"00000002-0000-0000-c000-000000000000" or
117+
"00000003-0000-0000-c000-000000000000"
118+
)
119+
) or
120+
(
121+
azure.signinlogs.properties.app_id: (
122+
"00b41c95-dab0-4487-9791-b9d2c32c80f2" or
123+
"1fec8e78-bce4-4aaf-ab1b-5451cc387264" or
124+
"26a7ee05-5602-4d76-a7ba-eae8b7b67941" or
125+
"27922004-5251-4030-b22d-91ecd9a37ea4" or
126+
"4813382a-8fa7-425e-ab75-3b753aab3abb" or
127+
"ab9b8c07-8f02-4f72-87fa-80105867a763" or
128+
"d3590ed6-52b3-4102-aeff-aad2292ab01c" or
129+
"872cd9fa-d31f-45e0-9eab-6e460a02d1f1" or
130+
"af124e86-4e96-495a-b70a-90f90ab96707" or
131+
"2d7f3606-b07d-41d1-b9d2-0d0c9296a6e8" or
132+
"844cca35-0656-46ce-b636-13f48b0eecbd" or
133+
"87749df4-7ccf-48f8-aa87-704bad0e0e16" or
134+
"cf36b471-5b44-428c-9ce7-313bf84528de" or
135+
"0ec893e0-5785-4de6-99da-4ed124e5296c" or
136+
"22098786-6e16-43cc-a27d-191a01a1e3b5" or
137+
"4e291c71-d680-4d0e-9640-0a3358e31177" or
138+
"57336123-6e14-4acc-8dcf-287b6088aa28" or
139+
"57fcbcfa-7cee-4eb1-8b25-12d2030b4ee0" or
140+
"66375f6b-983f-4c2c-9701-d680650f588f" or
141+
"9ba1a5c7-f17a-4de9-a1f1-6178c8d51223" or
142+
"a40d7d7d-59aa-447e-a655-679a4107e548" or
143+
"a569458c-7f2b-45cb-bab9-b7dee514d112" or
144+
"b26aadf8-566f-4478-926f-589f601d9c74" or
145+
"c0d2a505-13b8-4ae0-aa9e-cddd5eab0b12" or
146+
"d326c1ce-6cc6-4de2-bebc-4591e5e13ef0" or
147+
"e9c51622-460d-4d3d-952d-966a5b1da34c" or
148+
"eb539595-3fe1-474e-9c1d-feb3625d1be5" or
149+
"ecd6b820-32c2-49b6-98a6-444530e5a77a" or
150+
"f05ff7c9-f75a-4acd-a3b5-f4b6a870245d" or
151+
"f44b1140-bc5e-48c6-8dc0-5cf5a53c0e34" or
152+
"be1918be-3fe3-4be9-b32b-b542fc27f02e" or
153+
"cab96880-db5b-4e15-90a7-f3f1d62ffe39" or
154+
"d7b530a4-7680-4c23-a8bf-c52c121d2e87" or
155+
"dd47d17a-3194-4d86-bfd5-c6ae6f5651e3" or
156+
"e9b154d0-7658-433b-bb25-6b8e0a8a7c59"
157+
) and
158+
azure.signinlogs.properties.resource_id: "00000002-0000-0000-c000-000000000000"
159+
)
160+
)
161+
'''
162+
163+
164+
[[rule.threat]]
165+
framework = "MITRE ATT&CK"
166+
[[rule.threat.technique]]
167+
id = "T1078"
168+
name = "Valid Accounts"
169+
reference = "https://attack.mitre.org/techniques/T1078/"
170+
[[rule.threat.technique.subtechnique]]
171+
id = "T1078.004"
172+
name = "Cloud Accounts"
173+
reference = "https://attack.mitre.org/techniques/T1078/004/"
174+
175+
176+
[[rule.threat.technique]]
177+
id = "T1566"
178+
name = "Phishing"
179+
reference = "https://attack.mitre.org/techniques/T1566/"
180+
[[rule.threat.technique.subtechnique]]
181+
id = "T1566.002"
182+
name = "Spearphishing Link"
183+
reference = "https://attack.mitre.org/techniques/T1566/002/"
184+
185+
186+
187+
[rule.threat.tactic]
188+
id = "TA0001"
189+
name = "Initial Access"
190+
reference = "https://attack.mitre.org/tactics/TA0001/"
191+
[[rule.threat]]
192+
framework = "MITRE ATT&CK"
193+
[[rule.threat.technique]]
194+
id = "T1528"
195+
name = "Steal Application Access Token"
196+
reference = "https://attack.mitre.org/techniques/T1528/"
197+
198+
199+
[rule.threat.tactic]
200+
id = "TA0006"
201+
name = "Credential Access"
202+
reference = "https://attack.mitre.org/tactics/TA0006/"
203+
204+
[rule.investigation_fields]
205+
field_names = [
206+
"@timestamp",
207+
"azure.signinlogs.properties.user_principal_name",
208+
"azure.signinlogs.properties.app_id",
209+
"azure.signinlogs.properties.app_display_name",
210+
"azure.signinlogs.properties.resource_id",
211+
"azure.signinlogs.properties.resource_display_name",
212+
"azure.signinlogs.properties.is_interactive",
213+
"azure.signinlogs.properties.session_id",
214+
"azure.signinlogs.properties.incoming_token_type",
215+
"source.ip",
216+
"source.geo.country_name",
217+
"source.geo.city_name",
218+
"user_agent.original",
219+
]
220+
221+
[rule.new_terms]
222+
field = "new_terms_fields"
223+
value = [
224+
"azure.signinlogs.properties.user_principal_name",
225+
"azure.signinlogs.properties.app_id",
226+
"azure.signinlogs.properties.resource_id",
227+
]
228+
[[rule.new_terms.history_window_start]]
229+
field = "history_window_start"
230+
value = "now-14d"
231+
232+

0 commit comments

Comments
 (0)