T The Triage ManualTechnical Guides for IT Emergencies
P3 · Cyber Incident Response

Persistent OAuth Tokens from SaaS/AI Integrations Create Unmonitored Backdoors in Microsoft 365 and Google Workspace

Third-party AI tools, automation platforms, and productivity apps connected to Microsoft 365 or Google Workspace via OAuth leave behind long-lived refresh tokens that bypass MFA and perimeter controls. These tokens are rarely inventoried or revoked, providing a stealthy backdoor if the SaaS vendor is compromised or a user falls for consent phishing. Resolution requires inventorying, revoking, and actively governing OAuth consent grants in both tenants.

Indicators

Likely causes

Diagnostic steps

  1. In Microsoft Entra ID, open Enterprise applications > All applications, filter by user-consented apps, and export the list of service principals with their delegated and application permissions.
  2. In Google Workspace Admin Console, go to Security > Access and data control > API controls > App access control > Manage Third-Party App Access to inventory all connected OAuth apps and scopes.
  3. Use Microsoft Graph PowerShell (Get-MgServicePrincipal, Get-MgOauth2PermissionGrant) to enumerate consent grants and identify high-risk scopes such as Mail.ReadWrite, Files.ReadWrite.All, and offline_access.
  4. Audit Entra sign-in and audit logs for 'Consent to application' events; correlate with unusual user agents, IPs, or bulk consent activity indicating phishing.
  5. In Google Workspace, review the Security Investigation Tool for OAuth grant events and unusual API token usage patterns.
  6. Identify tokens with unverified publishers, unknown redirect URIs, or scopes disproportionate to stated app purpose.
  7. Check Microsoft Defender for Cloud Apps (App Governance) and Google Alert Center for OAuth abuse detections and investigate flagged apps.

Resolution path

Prevention

Tools

References

OAuthidentity-securityMicrosoft-365Google-WorkspaceSaaS-securityconsent-phishingtoken-abuseapp-governance