You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rules/integrations/azure/initial_access_entra_id_oauth_auth_code_grant_unusual_app_resource_user.toml
+10-38Lines changed: 10 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -24,58 +24,30 @@ note = """## Triage and analysis
24
24
25
25
### Investigating Entra ID OAuth Authorization Code Grant for Unusual User, App, and Resource
26
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.
**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.
- **Microsoft Graph**: `00000003-0000-0000-c000-000000000000` - Common but verify context
27
+
This New Terms rule detects the first occurrence of an OAuth 2.0 authorization code grant flow for a specific combination of client application, target resource, and user principal. When a user has never used a particular app+resource combination in the last 14 days and it involves FOCI applications or legacy Azure AD, this may indicate OAuth phishing.
54
28
55
29
### Possible investigation steps
56
30
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.
31
+
- Identify the affected user and confirm if they typically use developer tools like Azure CLI or PowerShell.
32
+
- Determine if the application and resource combination is expected for this user's role.
33
+
- Analyze source IP and geolocation for anomalies. Attackers typically exchange codes from different IPs.
34
+
- Check for non-interactive sign-ins shortly after interactive ones from different IPs, indicating token replay.
35
+
- Correlate with other sign-in events using session ID to identify the full OAuth flow sequence.
36
+
- Look for subsequent Graph API or AAD API activity from unusual locations.
64
37
65
38
### False positive analysis
66
39
67
-
- Developers or IT administrators legitimately using Azure CLI, PowerShell, or VS Code for the first time to access specific resources.
40
+
- Developers or IT administrators legitimately using these tools for the first time.
68
41
- Users onboarding to new development environments or tools.
69
42
- Automation scripts that run with user-delegated permissions for the first time.
70
43
71
44
### Response and remediation
72
45
73
-
- Contact the user to confirm if they initiated the OAuth flow and used the detected application.
46
+
- Contact the user to confirm if they initiated the OAuth flow.
74
47
- 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.
48
+
- Review recent activity from the same session for signs of data access or enumeration.
76
49
- Block the source IP if confirmed malicious.
77
50
- Implement Conditional Access policies to restrict OAuth flows for these applications.
78
-
- Educate users about OAuth phishing and the risks of pasting authorization codes.
Copy file name to clipboardExpand all lines: rules/integrations/azure/initial_access_entra_id_oauth_phishing_via_first_party_microsoft_application.toml
+17-42Lines changed: 17 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -25,60 +25,35 @@ note = """## Triage and analysis
25
25
26
26
### Investigating Entra ID OAuth Phishing via First-Party Microsoft Application
27
27
28
-
This rule identifies successful Entra ID sign-ins where first-party Microsoft applications from the FOCI (Family of Client IDs) group are used in potentially suspicious OAuth flows. The rule uses split detection logic:
These developer tools accessing Microsoft Graph or legacy AAD are flagged because they use localhost redirect URIs, making them ideal for OAuth code theft attacks like ConsentFix.
Any of the 38 FOCI family applications accessing legacy Windows Azure Active Directory (`00000002-0000-0000-c000-000000000000`) is suspicious because this deprecated API is rarely used legitimately. Attackers intentionally target legacy AAD to evade detection rules focused on Microsoft Graph.
39
-
40
-
**FOCI Family Applications** (partial list - see Secureworks research for full list):
41
-
- Microsoft Office, Teams, Outlook Mobile, OneDrive, SharePoint
42
-
- Microsoft Edge, Power BI, Intune Company Portal, Microsoft Authenticator
43
-
- And 30+ other Microsoft first-party applications
44
-
45
-
**ConsentFix Attack Pattern**: Victims land on compromised high-reputation websites via search engines, are shown a fake Cloudflare Turnstile, and tricked into completing a legitimate Microsoft OAuth flow. The redirect URL contains a localhost URI with an authorization code that victims are socially engineered to paste back into the attacker's page. The attacker then uses Azure CLI to exchange the code for tokens and access legacy AAD/Intune resources.
28
+
This rule detects OAuth authorization activity where FOCI (Family of Client IDs) applications access Microsoft Graph or legacy Azure AD resources. Adversaries exploit these trusted first-party apps in phishing campaigns like ConsentFix to steal authorization codes and exchange them for tokens from attacker infrastructure.
46
29
47
30
### Possible investigation steps
48
31
49
-
- Review `azure.signinlogs.properties.user_principal_name` to identify the affected user and determine if they are a high-value target (privileged roles, executives, IT admins).
50
-
- Analyze `source.ip` and `source.geo.*` for geographic anomalies. ConsentFix attackers exchange codes from different IPs than the victim's location.
51
-
- Check `azure.signinlogs.properties.app_id` and `azure.signinlogs.properties.app_display_name` to confirm which first-party application was used. Azure CLI access by non-developers is suspicious.
52
-
- Examine `azure.signinlogs.properties.resource_id` to identify the target resource:
53
-
- `00000002-0000-0000-c000-000000000000` = Windows Azure Active Directory (legacy) - unusual for most users
54
-
- `00000003-0000-0000-c000-000000000000` = Microsoft Graph - common but verify context
55
-
- Review `azure.signinlogs.properties.is_interactive` - non-interactive sign-ins shortly after interactive ones from different IPs indicate token replay.
56
-
- Check `azure.signinlogs.properties.session_id` to correlate with other sign-in events and identify the full OAuth flow sequence.
57
-
- Look at `user_agent.original` for suspicious patterns (automation tools, headless browsers, unusual browser/OS combinations).
58
-
- Search for subsequent Graph API or AAD API activity from the same session or user from unusual locations.
59
-
- Check `azure.signinlogs.properties.device_detail` to determine if the sign-in came from a managed/compliant device.
32
+
- Identify the affected user and determine if they are a high-value target (privileged roles, executives, IT admins).
33
+
- Analyze source IP and geolocation for anomalies. Attackers typically exchange codes from different IPs than the victim.
34
+
- Confirm which first-party application was used. Azure CLI or PowerShell access by non-developers is suspicious.
35
+
- Identify the target resource. Legacy AAD access is unusual for most users and indicates potential evasion.
36
+
- Check for non-interactive sign-ins shortly after interactive ones from different IPs, which may indicate token replay.
37
+
- Correlate with other sign-in events using session ID to identify the full OAuth flow sequence.
38
+
- Look for suspicious user agent patterns (automation tools, headless browsers).
39
+
- Search for subsequent Graph API or AAD API activity from unusual locations.
60
40
61
41
### False positive analysis
62
42
63
-
- Developers or IT administrators legitimately using Azure CLI, PowerShell, or VS Code to access Microsoft Graph or Azure AD.
64
-
- Legitimate Visual Studio Code extensions that sync or query Graph API data (calendars, tasks, cloud-hosted notebooks).
43
+
- Developers or IT administrators legitimately using Azure CLI, PowerShell, or VS Code.
65
44
- Enterprise automation or CI/CD pipelines using these tools with user-delegated permissions.
66
45
- Users working from multiple locations (VPN, travel) may show different IPs.
67
-
- Corporate proxies or VPNs may show unexpected IP addresses.
68
-
- Consider excluding known developer machines, managed devices, or specific user groups that regularly use these tools.
69
-
- Add exceptions for specific source IPs tied to corporate infrastructure or known developer environments.
46
+
- Consider excluding known developer machines or specific user groups that regularly use these tools.
70
47
71
48
### Response and remediation
72
49
73
-
- Contact the user immediately to confirm if they initiated the OAuth flow and used the detected application.
74
-
- If unauthorized, revoke all refresh tokens for the user via Microsoft Entra ID portal or PowerShell.
75
-
- Review the user's recent Microsoft Graph activity (email access, file downloads, Teams messages) for signs of data exfiltration.
50
+
- Contact the user to confirm if they initiated the OAuth flow.
51
+
- If unauthorized, revoke all refresh tokens for the user via Microsoft Entra ID.
52
+
- Review recent Microsoft Graph activity for signs of data exfiltration.
76
53
- Block the source IP if confirmed malicious.
77
-
- Check for any devices registered during this session and remove unauthorized device registrations.
78
-
- Implement Conditional Access policies to restrict OAuth flows for these applications to compliant devices only.
79
-
- Educate users about OAuth phishing and the risks of pasting authorization codes into websites.
80
-
- Consider blocking localhost redirect URIs for OAuth flows where possible.
81
-
- Monitor for follow-on activity such as privilege escalation, lateral movement, or data access.
54
+
- Check for and remove any unauthorized device registrations.
55
+
- Implement Conditional Access policies to restrict OAuth flows to compliant devices.
56
+
- Educate users about OAuth phishing and the risks of pasting authorization codes.
Copy file name to clipboardExpand all lines: rules/integrations/o365/defense_evasion_entra_id_susp_oauth2_authorization.toml
+16-29Lines changed: 16 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -23,41 +23,28 @@ note = """## Triage and analysis
23
23
24
24
### Investigating M365 Identity OAuth Flow by First-Party Microsoft App from Multiple IPs
25
25
26
-
This rule detects when the same user authenticates to Microsoft Graph using first-party Microsoft applications from multiple IP addresses within a short time window. This pattern is indicative of OAuth code/token theft attacks like ConsentFix, where:
26
+
This rule detects when the same user authenticates to Microsoft Graph or legacy Azure AD using FOCI applications from multiple IP addresses within a short time window. This pattern indicates OAuth code/token theft where the victim completes OAuth flow on their device and the attacker exchanges the stolen code from different infrastructure.
27
27
28
-
1. Victim completes OAuth flow on their device (first IP)
29
-
2. Attacker exchanges stolen authorization code for tokens from their infrastructure (second IP)
30
-
3. Both events share the same user principal but originate from different locations
- Identify the affected user and analyze the list of unique IP addresses used within the 30-minute window.
31
+
- Determine whether IPs originate from different geographic regions, cloud providers, or anonymizing infrastructure.
32
+
- Pivot into raw events to reconstruct the full sequence of resource access events.
33
+
- Check Azure audit logs for device join or registration events around the same timeframe.
34
+
- Review identity protection alerts for correlated risk detections such as anonymized IP access or token replay.
37
35
38
-
**Detection Logic 2 - Any FOCI App → Legacy AAD Only (Multi-IP)**:
39
-
Any of the 38 FOCI family applications (Microsoft Office, Teams, Outlook, OneDrive, etc.) accessing legacy Windows Azure Active Directory from multiple IPs is suspicious because this deprecated API is rarely used legitimately.
36
+
### False positive analysis
40
37
41
-
### Possible Investigation Steps:
38
+
- Developers or IT administrators working across environments may produce similar behavior.
39
+
- Users on VPN or traveling between networks may show multiple IPs.
42
40
43
-
- `o365.audit.UserId`: The identity value the application is acting on behalf of principal user.
44
-
- `unique_ips`: Analyze the list of unique IP addresses used within the 30-minute window. Determine whether these originate from different geographic regions, cloud providers, or anonymizing infrastructure (e.g., Tor or VPNs).
45
-
- `target_time_window`: Use the truncated time window to pivot into raw events to reconstruct the full sequence of resource access events, including exact timestamps and service targets.
46
-
- `azure.auditlogs` to check for device join or registration events around the same timeframe.
47
-
- `azure.identityprotection` to identify correlated risk detections, such as anonymized IP access or token replay.
48
-
- Any additional sign-ins from the `ips` involved, even outside the broker, to determine if tokens have been reused elsewhere.
41
+
### Response and remediation
49
42
50
-
### False Positive Analysis
51
-
52
-
- Developers or IT administrators working across environments may also produce similar behavior.
53
-
54
-
### Response and Remediation
55
-
56
-
- If confirmed unauthorized, revoke all refresh tokens for the affected user and remove any devices registered during this session.
57
-
- Notify the user and determine whether the device join or authentication activity was expected.
58
-
- Audit Conditional Access and broker permissions (`29d9ed98-a469-4536-ade2-f981bc1d605e`) to ensure policies enforce strict access controls.
59
-
- Consider blocking token-based reauthentication to Microsoft Graph and DRS from suspicious locations or user agents.
60
-
- Continue monitoring for follow-on activity like lateral movement or privilege escalation.
43
+
- If confirmed unauthorized, revoke all refresh tokens for the affected user.
44
+
- Remove any devices registered during this session.
45
+
- Notify the user and determine whether the authentication activity was expected.
46
+
- Implement Conditional Access policies to restrict OAuth flows from suspicious locations.
47
+
- Monitor for follow-on activity like lateral movement or privilege escalation.
0 commit comments