-
Notifications
You must be signed in to change notification settings - Fork 674
[Rule Tuning] Tuning Illicit Grant Consent Detections in Azure and M365 #4557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a29b14c
tuning Azure rule for illicit grant activity; creating new rule for M365
terrancedejesus 339c73b
Update rules/integrations/o365/initial_access_microsoft_365_illicit_c…
terrancedejesus d3a7ad7
Update rules/integrations/azure/initial_access_entra_illicit_consent_…
terrancedejesus 1624647
Merge branch 'main' into rule-tuning-illicit-grant-azure-m365
terrancedejesus e2a6a12
adjusted tags
terrancedejesus 2f99508
Merge branch 'main' into rule-tuning-illicit-grant-azure-m365
terrancedejesus 7cb5df3
Merge branch 'main' into rule-tuning-illicit-grant-azure-m365
terrancedejesus 34d0da6
Merge branch 'main' into rule-tuning-illicit-grant-azure-m365
terrancedejesus a8070d1
Update rules/integrations/azure/initial_access_entra_illicit_consent_…
terrancedejesus 092896d
Merge branch 'main' into rule-tuning-illicit-grant-azure-m365
terrancedejesus f509e9a
Merge branch 'main' into rule-tuning-illicit-grant-azure-m365
terrancedejesus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 0 additions & 126 deletions
126
...egrations/azure/initial_access_consent_grant_attack_via_azure_registered_application.toml
This file was deleted.
Oops, something went wrong.
145 changes: 145 additions & 0 deletions
145
...grations/azure/initial_access_entra_illicit_consent_grant_via_registered_application.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| [metadata] | ||
| creation_date = "2020/09/01" | ||
| integration = ["azure"] | ||
| maturity = "production" | ||
| updated_date = "2025/03/24" | ||
|
|
||
| [rule] | ||
| author = ["Elastic"] | ||
| description = """ | ||
| Identifies an illicit consent grant request on-behalf-of a registered Entra ID application. Adversaries may create and | ||
| register an application in Microsoft Entra ID for the purpose of requesting user consent to access resources. This is | ||
| accomplished by tricking a user into granting consent to the application, typically via a pre-made phishing URL. This | ||
| establishes an OAuth grant that allows the malicious client applocation to access resources on-behalf-of the user. | ||
| """ | ||
| from = "now-9m" | ||
| index = ["filebeat-*", "logs-azure*"] | ||
| language = "kuery" | ||
| license = "Elastic License v2" | ||
| name = "Microsoft Entra ID Illicit Consent Grant via Registered Application" | ||
| note = """## Triage and analysis | ||
|
|
||
| ### Investigating Microsoft Entra ID Illicit Consent Grant via Registered Application | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| #### Possible investigation steps | ||
|
|
||
| - 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. | ||
| - 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. | ||
| - 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. | ||
| - Review `azure.auditlogs.properties.target_resources.display_name` to evaluate whether the application name is familiar, expected, or potentially spoofing a known service. | ||
| - Review `azure.auditlogs.properties.target_resources.modified_properties.display_name` to inspect key indicators of elevated privilege or risk, including: | ||
| - ConsentContext.IsAdminConsent to determine if the application was granted tenant-wide admin access. | ||
| - ConsentContext.OnBehalfOfAll to identify whether the app was granted permissions on behalf of all users in the tenant. | ||
| - ConsentAction.Permissions to evaluate the specific scopes and data access the application requested. | ||
| - ConsentAction.Reason to understand if Microsoft flagged the activity or if any reason was recorded by the platform. | ||
| - TargetId.ServicePrincipalNames to confirm the service principal associated with the granted permissions. | ||
| - Review `azure.tenant_id` to confirm the activity originated from your tenant and is not related to a cross-tenant application. | ||
| - Review `@timestamp` and `azure.auditlogs.properties.correlation_id` to pivot into related sign-in, token usage, or application activity for further context. | ||
|
|
||
| ### False positive analysis | ||
|
|
||
| - 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. | ||
| - Review publisher verification, app ownership, and scope alignment with the intended business use case. | ||
|
|
||
| ### Response and remediation | ||
|
|
||
| - Revoke the application’s OAuth grant using Graph API or PowerShell. Use the Remove-AzureADOAuth2PermissionGrant cmdlet. | ||
| - Remove the associated service principal from Azure AD. | ||
| - Reset credentials or revoke tokens for affected users. | ||
| - Block the application via Conditional Access or Defender for Cloud Apps policies. | ||
| - Enable the Admin Consent Workflow in Azure AD to prevent unsanctioned user approvals in the future. | ||
| - Report any malicious applications to Microsoft to protect other tenants. | ||
| """ | ||
| references = [ | ||
| "https://www.wiz.io/blog/midnight-blizzard-microsoft-breach-analysis-and-best-practices", | ||
| "https://docs.microsoft.com/en-us/microsoft-365/security/office-365-security/detect-and-remediate-illicit-consent-grants?view=o365-worldwide", | ||
| "https://www.cloud-architekt.net/detection-and-mitigation-consent-grant-attacks-azuread/", | ||
| "https://docs.microsoft.com/en-us/defender-cloud-apps/investigate-risky-oauth#how-to-detect-risky-oauth-apps", | ||
| ] | ||
| risk_score = 47 | ||
| rule_id = "1c6a8c7a-5cb6-4a82-ba27-d5a5b8a40a38" | ||
| severity = "medium" | ||
| tags = [ | ||
| "Domain: Cloud", | ||
| "Data Source: Azure", | ||
| "Data Source: Microsoft Entra ID", | ||
| "Data Source: Microsoft Entra ID Audit Logs", | ||
| "Use Case: Identity and Access Audit", | ||
| "Resources: Investigation Guide", | ||
| "Tactic: Initial Access", | ||
| "Tactic: Credential Access", | ||
| ] | ||
| timestamp_override = "event.ingested" | ||
| type = "new_terms" | ||
|
|
||
| query = ''' | ||
| event.dataset: "azure.auditlogs" and | ||
| ( | ||
| azure.auditlogs.operation_name:"Consent to application" | ||
| or event.action:"Consent to application." | ||
|
terrancedejesus marked this conversation as resolved.
Outdated
|
||
| ) | ||
| and event.outcome: "success" | ||
| and azure.auditlogs.properties.additional_details.key: "AppId" | ||
| ''' | ||
|
|
||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
| [[rule.threat.technique]] | ||
| id = "T1566" | ||
| name = "Phishing" | ||
| reference = "https://attack.mitre.org/techniques/T1566/" | ||
| [[rule.threat.technique.subtechnique]] | ||
| id = "T1566.002" | ||
| name = "Spearphishing Link" | ||
| reference = "https://attack.mitre.org/techniques/T1566/002/" | ||
|
|
||
|
|
||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0001" | ||
| name = "Initial Access" | ||
| reference = "https://attack.mitre.org/tactics/TA0001/" | ||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
| [[rule.threat.technique]] | ||
| id = "T1528" | ||
| name = "Steal Application Access Token" | ||
| reference = "https://attack.mitre.org/techniques/T1528/" | ||
|
|
||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0006" | ||
| name = "Credential Access" | ||
| reference = "https://attack.mitre.org/tactics/TA0006/" | ||
|
|
||
| [rule.investigation_fields] | ||
| field_names = [ | ||
| "@timestamp", | ||
| "event.action", | ||
| "event.outcome", | ||
| "azure.auditlogs.properties.initiated_by.user.userPrincipalName", | ||
| "azure.auditlogs.properties.initiated_by.user.ipAddress", | ||
| "azure.auditlogs.properties.additional_details.value", | ||
| "azure.tenant_id", | ||
| "cloud.region", | ||
| "azure.auditlogs.properties.target_resources.0.display_name" | ||
| ] | ||
|
|
||
| [rule.new_terms] | ||
| field = "new_terms_fields" | ||
| value = [ | ||
| "azure.auditlogs.properties.initiated_by.user.userPrincipalName", | ||
| "azure.auditlogs.properties.additional_details.value", | ||
| ] | ||
| [[rule.new_terms.history_window_start]] | ||
| field = "history_window_start" | ||
| value = "now-14d" | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.