OAuth & Identity Persistence · T1528 / T1550.001

Investigating Illicit OAuth Consent Grants in Microsoft 365 & Entra Logs

Direct Answer (Key Forensic Takeaway)

Illicit OAuth consent phishing tricks employees into approving a malicious multi-tenant cloud app requesting delegated Graph API permissions like Mail.Read, Mail.Send, or Files.Read.All—generating "Consent to application" and "Add OAuth2PermissionGrant" in Entra and Purview logs. Because tokens belong to the application, resetting the user’s password or MFA does NOT revoke attacker access.

Why This Artifact Matters in M365 Incident Response

Illicit OAuth consent phishing—sometimes called "consent phishing" or "rogue app attacks"—is one of the most resilient access techniques against passwordless and MFA-hardened tenants. Instead of stealing passwords on a lookalike login domain, the attacker redirects the employee to Microsoft’s genuine consent prompt for an external app named something plausible like "Adobe Document Cloud Sync" or "DocuSign PDF Viewer".

When the employee clicks Accept, Entra ID grants the attacker’s external app an independent refresh token carrying permissions (`Mail.Read`, `Files.ReadWrite.All`, `offline_access`) to access emails and SharePoint continuously via Microsoft Graph—completely bypassing subsequent user password resets and MFA changes.

Whenever an OAuth consent completes, Microsoft Entra ID writes directory audit records across both the Entra Audit blade and Purview UAL (RecordType 8): `Add service principal` (registering the external app inside your tenant), `Consent to application` (logging the consenting user and IP), and `Add OAuth2PermissionGrant` (persisting the granted API scopes).

AuditVane rule `AV-005` automatically catches `Consent to application`, `Add OAuth2PermissionGrant`, `Add app role assignment to service principal`, and `Add service principal credentials`—surfacing both user-consented phishing apps and admin-consented backdoors inside one triage panel.

1. RAW TELEMETRY OAuth & Identity Persistence T1528 / T1550.001 2. CLIENT-SIDE PARSE AuditVane Engine illicit OAuth consent grant M365 l 0 Bytes Uploaded 3. SOC OUTCOME Scoped Containment IOCs · CSV · KQL
Local browser DFIR workflow for illicit OAuth consent grant M365 logs (T1528 / T1550.001)
AdSense-Ready In-Article Placement

Real-World Incident Walkthrough

During an AiTM compromise—or standalone consent phish—an HR Lead receives a shared-file link and clicks Accept on "DocuSign PDF Viewer Sync (Rogue App)" at 14:15 UTC. Even though no Inbox Rule is created, the attacker’s remote server immediately begins calling Graph `/me/messages` using `Mail.Read` and `offline_access`.

Two days later, IT resets the HR Lead’s password after spotting an unfamiliar sign-in, yet confidential resumes continue leaking until the SOC drops Entra Audit JSON into AuditVane, catches `AV-005 Consent to application`, and deletes both the `OAuth2PermissionGrant` and the malicious `ServicePrincipal`.

Forensic Telemetry Fields & High-Signal Indicators

Telemetry Field / Pattern Meaning in M365 / Entra High-Signal Threat Indicator
Consent to applicationUser or Admin clicked Accept on OAuth promptInspect IP & targetResources.displayName (AV-005)
Add OAuth2PermissionGrantDelegated OAuth grant written to Entra directoryCheck Scope string for Mail.*, Files.*, offline_access
Add service principalFirst time an external multi-tenant AppId enters tenantVerify Publisher Verification & AppId reputation
ConsentContext.IsAdminConsent = TruePrivileged admin granted tenant-wide consentApp can access ALL employees—not just one victim!
offline_access scopeIssues refresh token for long-lived background accessLets rogue app poll mailboxes continuously
AppAccessContext.ClientAppIdApp GUID appearing inside Purview MailItemsAccessedProves exact mailboxes read by the illicit app

Standard Password Compromise vs. Illicit OAuth Consent Compromise

Security AspectStolen Password / AiTM CookieIllicit OAuth App Consent
Credential Stolen?User password / ESTSAUTH cookieNone — victim approves official Microsoft consent screen
Stopped by Password Reset?Partially (with Revoke-MgUserSignInSession)NO — OAuth2PermissionGrant stays valid independently
Access ChannelOWA, Outlook, IMAP, Graph interactiveSilent Microsoft Graph REST API (`Mail.Read`, `Files.Read`)
Required Cleanup CommandReset Password + Revoke SessionsRemove-MgOauth2PermissionGrant + Remove-MgServicePrincipal

Illicit OAuth Consent Audit Record in Entra JSON

{
  "id": "audit-9005",
  "activityDateTime": "2026-12-02T14:15:09Z",
  "activityDisplayName": "Consent to application",
  "category": "ApplicationManagement",
  "result": "success",
  "initiatedBy": { "user": { "userPrincipalName": "hr.lead@contoso-demo.invalid", "ipAddress": "194.26.135.210" } },
  "targetResources": [{
    "displayName": "DocuSign PDF Viewer Sync (Rogue App)",
    "modifiedProperties": [{ "displayName": "ConsentContext.Scope", "newValue": "Mail.Read Mail.Send offline_access" }]
  }]
}

Notice the dangerous combination inside `ConsentContext.Scope`: `Mail.Read`, `Mail.Send`, and `offline_access`—allowing the rogue app to both read every email AND send internal phishing indefinitely without ever logging in as the user interactively again.

Audit, Scope & Purge Illicit OAuth Grants via Microsoft Graph

Connect-MgGraph -Scopes "DelegatedPermissionGrant.ReadWrite.All","Application.ReadWrite.All"
# 1. List all delegated OAuth grants containing Mail, Files, or offline_access:
Get-MgOauth2PermissionGrant -All | Where-Object { $_.Scope -match "Mail|Files|ReadWrite|offline_access" } |
  Select-Object Id, ClientId, ConsentType, PrincipalId, Scope

# 2. Remove malicious grant AND enterprise service principal:
Remove-MgOauth2PermissionGrant -OAuth2PermissionGrantId "<GrantId>"
Remove-MgServicePrincipal -ServicePrincipalId "<ClientId>"

Sample Delegated Grant Discovery Output

Id                        ClientId                             ConsentType PrincipalId   Scope
--                        --------                             ----------- -----------   -----
xyz987654321              sp-rogue-app-object-id               Principal   hr-lead-guid  Mail.Read Mail.Send offline_access

Step-by-Step Triage, Containment & Verification

  1. Drop Entra Directory Audit JSON or Purview UAL CSV (RecordType 8) into AuditVane and click AV-005 findings.
  2. Inspect `ConsentContext.Scope` and `Target` AppId inside AuditVane’s Event Inspector.
  3. Check `ConsentContext.IsAdminConsent` (`AllPrincipals`): if True, treat the entire tenant—not just one user—as exposed.
  4. Run `Get-MgOauth2PermissionGrant` and delete the rogue grant via `Remove-MgOauth2PermissionGrant`.
  5. Delete or disable (`AccountEnabled = $false`) the Enterprise Application ServicePrincipal so no user can re-consent silently.
  6. Pivot on the rogue `ClientAppId` inside Purview `MailItemsAccessed` and `FileDownloaded` logs to scope every email and document fetched by the app.
  7. Lock down Entra Enterprise Applications -> Consent and permissions -> set User Consent to **Do not allow user consent** (or **Allow user consent for apps from verified publishers, for selected permissions** with Mail/Files excluded) and enable **Admin Consent Workflow**.

How to Verify Containment Completed Cleanly

  • Malicious OAuth2PermissionGrant and ServicePrincipal completely removed from Entra ID.
  • Purview MailItemsAccessed swept for AppAccessContext.ClientAppId matching the rogue app.
  • Tenant-wide User OAuth Consent locked down so regular employees cannot approve Mail.Read or Files.Read.

Analyst Blind Spots, Licensing Quirks & False Positives

Disabling a user account temporarily or resetting their password leaves an approved OAuth2PermissionGrant untouched—the app will resume calling Graph API the instant the account is re-enabled unless you delete the OAuth grant explicitly.

Watch out for `AllPrincipals` grants: if a compromised Global Admin or Cloud App Admin consented to an app, it gains permissions across ALL mailboxes simultaneously.

Frequently Asked Questions

Does Revoke-MgUserSignInSession revoke an approved third-party OAuth app?

It revokes user refresh tokens, yet if the app holds Admin Consent, application permissions, or can silently re-request tokens, the grant persists until explicitly removed with Remove-MgOauth2PermissionGrant.

Why do OAuth phishing kits request Mail.Read + offline_access?

Mail.Read grants full email retrieval while offline_access supplies a long-lived refresh token for continuous background access.

Does AuditVane catch OAuth consent grants automatically?

Yes! Rule AV-005 triggers High severity on Consent to application, Add OAuth2PermissionGrant, Add app role assignment, and Add service principal credentials.

How do I stop employees from falling for OAuth consent phishing?

Restrict User Consent in Entra ID to Admin-Consent-Only (or low-risk verified apps excluding Mail/Files scopes) so consent requests route to IT review.

Related Forensics Guides