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
+19-13Lines changed: 19 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -24,30 +24,36 @@ 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 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.
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 ID, target resource ID, and user principal within the last 14 days. When a user has never used a particular app+resource combination and it involves FOCI applications or legacy Azure AD, this may indicate OAuth phishing attacks like ConsentFix.
28
+
29
+
The rule is particularly effective at catching attacks where adversaries use stolen OAuth codes with first-party apps to access resources the victim has never accessed before. For example, if a non-developer suddenly uses Azure CLI to access legacy AAD for the first time, this is highly suspicious regardless of other factors.
28
30
29
31
### Possible investigation steps
30
32
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.
33
+
- Review `azure.signinlogs.properties.user_principal_name` to identify the affected user and determine if they are a developer who would legitimately use these tools.
34
+
- Check `azure.signinlogs.properties.app_display_name` to confirm which application was used. Azure CLI or PowerShell access by non-technical users is suspicious.
35
+
- Examine `azure.signinlogs.properties.resource_id` to identify the target resource. Legacy AAD (`00000002-0000-0000-c000-000000000000`) access is unusual for most users.
36
+
- Analyze `source.ip` and `source.geo.*` for geographic anomalies. ConsentFix attackers exchange codes from different IPs than the victim.
37
+
- Review `azure.signinlogs.properties.is_interactive` - if this is a non-interactive sign-in shortly after an interactive one from a different IP, it indicates token replay.
38
+
- Correlate with other sign-in events using `azure.signinlogs.properties.session_id` to identify the full OAuth flow sequence.
39
+
- Pivot to `azure.graphactivitylogs` to search for subsequent Graph API or AAD API activity from unusual locations.
40
+
- Check `azure.auditlogs` for device registration events around the same timeframe.
37
41
38
42
### False positive analysis
39
43
40
-
- Developers or IT administrators legitimately using these tools for the first time.
41
-
- Users onboarding to new development environments or tools.
44
+
- Developers or IT administrators legitimately using Azure CLI, PowerShell, or VS Code for the first time to access specific resources.
45
+
- Users onboarding to new development environments or receiving new tooling.
42
46
- Automation scripts that run with user-delegated permissions for the first time.
47
+
- Consider the user's role and typical activity patterns when evaluating alerts.
43
48
44
49
### Response and remediation
45
50
46
-
- Contact the user to confirm if they initiated the OAuth flow.
47
-
- If unauthorized, immediately revoke all refresh tokens for the user via Entra ID.
48
-
- Review recent activity from the same session for signs of data access or enumeration.
51
+
- Contact the user to confirm if they initiated the OAuth flow and used the detected application.
52
+
- If unauthorized, immediately revoke all refresh tokens for the user via Microsoft Entra ID.
53
+
- Review recent activity from the same `session_id` for signs of data access or enumeration.
49
54
- Block the source IP if confirmed malicious.
50
-
- Implement Conditional Access policies to restrict OAuth flows for these applications.
55
+
- Implement Conditional Access policies to restrict OAuth flows for these applications 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/azure/initial_access_entra_id_oauth_phishing_via_first_party_microsoft_application.toml
+20-17Lines changed: 20 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -25,35 +25,38 @@ note = """## Triage and analysis
25
25
26
26
### Investigating Entra ID OAuth Phishing via First-Party Microsoft Application
27
27
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.
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. Because first-party apps are pre-consented and cannot be blocked, attackers use them to bypass consent prompts and access user data without triggering typical OAuth alerts.
29
+
30
+
The rule uses split detection logic: developer tools (Azure CLI, VSCode, PowerShell) accessing either Graph or legacy AAD are flagged, while any FOCI app accessing legacy AAD is flagged since this deprecated API is rarely used legitimately and attackers target it for stealth.
29
31
30
32
### Possible investigation steps
31
33
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.
34
+
- 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).
35
+
- Analyze `source.ip` and `source.geo.*` for geographic anomalies. ConsentFix attackers exchange codes from different IPs than the victim's location.
36
+
- Check `azure.signinlogs.properties.app_display_name` to confirm which first-party application was used. Azure CLI or PowerShell access by non-developers is suspicious.
37
+
- Examine `azure.signinlogs.properties.resource_id` to identify the target resource. Legacy AAD (`00000002-0000-0000-c000-000000000000`) access is unusual for most users.
38
+
- Review `azure.signinlogs.properties.is_interactive` - non-interactive sign-ins shortly after interactive ones from different IPs indicate token replay.
39
+
- Correlate with other sign-in events using `azure.signinlogs.properties.session_id` to identify the full OAuth flow sequence.
40
+
- Pivot to `azure.graphactivitylogs` to search for subsequent Graph API activity from the same session or user from unusual locations.
41
+
- Check `azure.auditlogs` for device registration events around the same timeframe, which may indicate persistence attempts.
40
42
41
43
### False positive analysis
42
44
43
-
- Developers or IT administrators legitimately using Azure CLI, PowerShell, or VS Code.
45
+
- Developers or IT administrators legitimately using Azure CLI, PowerShell, or VS Code to access Microsoft Graph or Azure AD.
44
46
- Enterprise automation or CI/CD pipelines using these tools with user-delegated permissions.
45
47
- Users working from multiple locations (VPN, travel) may show different IPs.
46
-
- Consider excluding known developer machines or specific user groups that regularly use these tools.
48
+
- Consider excluding known developer machines, managed devices, or specific user groups that regularly use these tools.
49
+
- Maintain an allowlist of expected source IPs tied to corporate infrastructure or developer environments.
47
50
48
51
### Response and remediation
49
52
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.
53
+
- Contact the user immediately to confirm if they initiated the OAuth flow and used the detected application.
54
+
- If unauthorized, revoke all refresh tokens for the user via Microsoft Entra ID portal or PowerShell.
55
+
- Review the user's recent Microsoft Graph activity (email access, file downloads, Teams messages) for signs of data exfiltration.
53
56
- Block the source IP if confirmed malicious.
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.
57
+
- Check for any devices registered during this session via `azure.auditlogs` and remove unauthorized device registrations.
58
+
- Implement Conditional Access policies to restrict OAuth flows for these applications to compliant devices only.
59
+
- Educate users about OAuth phishing and the risks of pasting authorization codes into websites.
Copy file name to clipboardExpand all lines: rules/integrations/o365/defense_evasion_entra_id_susp_oauth2_authorization.toml
+21-13Lines changed: 21 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -23,28 +23,36 @@ 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 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.
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 30-minute window. This pattern is a strong indicator of OAuth code/token theft attacks like ConsentFix, where the victim completes the OAuth authorize flow on their device (first IP), and the attacker exchanges the stolen authorization code for tokens from their infrastructure (second IP).
27
+
28
+
The rule aggregates events by user, application, and resource, requiring both `OAuth2:Authorize` and `OAuth2:Token` requests from at least 2 different IPs to fire - this indicates the code was generated on one IP and exchanged on another.
27
29
28
30
### Possible investigation steps
29
31
30
-
- 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.
32
+
- Review `o365.audit.UserId` to identify the affected user and determine if they are a high-value target.
33
+
- Analyze `Esql.source_ip_values` to see all unique IP addresses used within the 30-minute window. Determine whether these originate from different geographic regions, cloud providers (AWS, Azure, GCP), or anonymizing infrastructure (Tor, VPNs).
34
+
- Use `Esql.time_window_date_trunc` to pivot into raw events and reconstruct the full sequence of resource access events with exact timestamps.
35
+
- Check `Esql.source_as_organization_name_values` for unfamiliar ASN organizations that may indicate attacker infrastructure.
36
+
- Review `Esql.o365_audit_ApplicationId_values` to confirm which first-party application was used.
37
+
- Pivot to `azure.auditlogs` to check for device join or registration events around the same timeframe, which may indicate persistence attempts.
38
+
- Correlate with `azure.identityprotection` to identify related risk detections such as anonymized IP access or token replay.
39
+
- Search for additional sign-ins from the IPs involved across other users to determine if this is part of a broader campaign.
35
40
36
41
### False positive analysis
37
42
38
-
- Developers or IT administrators working across environments may produce similar behavior.
39
-
- Users on VPN or traveling between networks may show multiple IPs.
43
+
- Developers or IT administrators working across environments (office, home, cloud VMs) may produce similar behavior.
44
+
- Users on VPN who switch servers or traveling between networks may show multiple IPs.
45
+
- Mobile users moving between cellular and WiFi networks during the time window.
46
+
- Consider correlating with device compliance status to distinguish managed vs. unmanaged access.
40
47
41
48
### Response and remediation
42
49
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.
50
+
- If confirmed unauthorized, immediately revoke all refresh tokens for the affected user via Entra ID.
51
+
- Remove any devices registered during this session by checking `azure.auditlogs` for `Add device` events.
52
+
- Notify the user and determine whether they may have shared an OAuth code via phishing.
53
+
- Block the attacker IPs at the perimeter and add to threat intel feeds.
54
+
- Implement Conditional Access policies to restrict OAuth flows for these applications to compliant devices and approved locations.
55
+
- Monitor for follow-on activity like lateral movement, privilege escalation, or data exfiltration via Graph API.
Copy file name to clipboardExpand all lines: rules/integrations/o365/initial_access_identity_oauth_phishing_via_first_party_microsoft_application.toml
+19-12Lines changed: 19 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -25,29 +25,36 @@ note = """## Triage and analysis
25
25
26
26
### Investigating M365 Identity OAuth Phishing via First-Party Microsoft Application
27
27
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.
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. The rule specifically looks for `OAuth2:Authorize` requests with `Redirect` status, which indicates the user was redirected after authorization and the OAuth code was exposed.
29
+
30
+
The rule uses split detection logic: developer tools (Azure CLI, VSCode, PowerShell) accessing either Graph or legacy AAD are flagged, while any FOCI app accessing legacy AAD is flagged since this deprecated API is rarely used legitimately and attackers target it for stealth.
29
31
30
32
### Possible investigation steps
31
33
32
-
- Identify the impacted account and validate whether the user expected to authorize the application.
33
-
- Check if the source IP is unexpected or outside corporate ranges, especially from proxy networks.
34
-
- Examine user agent and device properties for suspicious patterns (automation tools, headless browsers).
35
-
- Identify the target resource. Legacy AAD access is unusual for most users and indicates potential evasion.
36
-
- Check for follow-up access events or mailbox enumeration using the Graph API from unfamiliar locations.
37
-
- Look for subsequent non-interactive sign-ins from different IPs using the same session.
34
+
- Review `o365.audit.UserId` to identify the impacted account and validate whether the user expected to authorize the application.
35
+
- Check `o365.audit.ActorIpAddress` for unexpected IPs, especially outside corporate ranges or from proxy/VPN networks.
36
+
- Examine `user_agent.original` and `o365.audit.DeviceProperties` for suspicious patterns (automation tools, headless browsers, unusual browser/OS combinations).
37
+
- Confirm `o365.audit.Target.ID` to identify the resource being accessed. Legacy AAD (`00000002-0000-0000-c000-000000000000`) access is unusual for most users.
38
+
- Review `o365.audit.ExtendedProperties.RequestType` and `ResultStatusDetail` - `OAuth2:Authorize` with `Redirect` indicates the OAuth code was exposed to the user.
39
+
- Look for subsequent `OAuth2:Token` events from different IPs using the same `o365.audit.UserId`, which indicates token exchange from attacker infrastructure.
40
+
- Pivot to `azure.graphactivitylogs` to check for follow-up Graph API activity (mailbox enumeration, file access) from unfamiliar locations.
41
+
- Correlate with `azure.signinlogs` for additional sign-in context and device details.
38
42
39
43
### False positive analysis
40
44
41
-
- Developers or IT users intentionally using Azure CLI, VS Code, or PowerShell.
45
+
- Developers or IT users intentionally using Visual Studio Code, Azure CLI, or Azure PowerShell to connect to Microsoft 365.
46
+
- Legitimate VS Code extensions that sync or query Graph API data (calendars, tasks, cloud-hosted notebooks).
42
47
- Enterprise automation or CI/CD pipelines using these tools with user-delegated permissions.
43
-
- Consider excluding known developer machines or specific user groups that regularly use these tools.
48
+
- Exclude known user agents and hosts that regularly use these applications against Graph.
49
+
- Whitelist specific source IPs or devices tied to developer machines.
44
50
45
51
### Response and remediation
46
52
47
-
- Contact the user to confirm if they expected this login or may have shared an OAuth code.
48
-
- If unauthorized, revoke all refresh tokens and reset credentials.
49
-
- Review recent Microsoft Graph activity for signs of data exfiltration.
53
+
- Contact the user to confirm if they expected this login or may have shared an OAuth code via phishing page, Signal, or WhatsApp.
54
+
- If unauthorized, revoke all refresh tokens for the user and reset credentials.
55
+
- Review recent Microsoft Graph activity (email, file access, Teams) for signs of data exfiltration.
50
56
- Block or restrict future use of OAuth tokens from unknown apps or IPs via Conditional Access.
57
+
- Check `azure.auditlogs` for device registration events and remove any unauthorized registrations.
51
58
- Educate users about OAuth phishing techniques and the risks of sharing authorization codes.
0 commit comments