Enterprise Application Backdoor Persistence Checklist for Microsoft 365
To guarantee no Enterprise Application backdoor survives M365 breach containment, audit five Entra artifacts: newly created App Registrations ("Add application"), added secrets/certs on existing apps ("Add service principal credentials"), AppRoleAssignments (Mail.Read/RoleManagement.ReadWrite.Directory), OAuth2PermissionGrants, and Service Principal Sign-In logs.
Why This Artifact Matters in M365 Incident Response
Whenever an attacker touches an account holding Global Administrator, Application Administrator, or Cloud Application Administrator—even for three minutes—assume they inspected Enterprise Applications to establish a silent daemon backdoor.
Unlike compromised employee accounts, a malicious Enterprise Application holding Microsoft Graph Application Permissions (`Mail.Read`, `Files.Read.All`, `RoleManagement.ReadWrite.Directory`) authenticates purely with a client secret or X.509 certificate—completely bypassing user MFA, user Conditional Access policies, and user password resets.
Understanding Entra’s dual-object model is essential for thorough eradication: an **App Registration** (`Application`) is the global blueprint defined in the creator’s tenant, whereas an **Enterprise Application** (`ServicePrincipal`) is the local runtime instance inside your tenant that holds granted permissions.
When an attacker invites an external multi-tenant app hosted inside *their own* attacker tenant, there is NO App Registration in your tenant to inspect—only a `ServicePrincipal` with `AppRoleAssignments` or `OAuth2PermissionGrants`! Deleting only App Registrations misses external multi-tenant backdoors completely.
Real-World Incident Walkthrough
During a tenant breach, an attacker briefly captures an Application Admin’s AiTM session, registers an enterprise app named `TenantBackupSyncTool`, grants it the Graph Application Permission `Mail.Read`, and generates a client secret. Even after the Application Admin’s password and sessions are reset, the attacker continues polling executive mailboxes silently via Graph `client_credentials` calls.
Sweeping `Add application` and `Add app role assignment to service principal` inside AuditVane (`AV-005`) exposes `TenantBackupSyncTool`, and inspecting `Get-MgServicePrincipalAppRoleAssignment` allows instant removal.
Forensic Telemetry Fields & High-Signal Indicators
| Telemetry Field / Pattern | Meaning in M365 / Entra | High-Signal Threat Indicator |
|---|---|---|
Add application | New App Registration created inside tenant | Check owner, home tenant & credentials |
Add service principal | External multi-tenant app instantiated locally | Audit AppOwnerOrganizationId (external tenant!) |
Add app role assignment to SP | Daemon app-only permissions granted | Highest impact: Mail.Read, Files.Read.All, RoleManagement |
Add service principal credentials | Secret or cert injected onto existing app | Can backdoor legitimate vendor/IT integrations |
Add owner to application/SP | User granted control over app secrets | Enables self-service secret generation later |
Service Principal Sign-Ins | Actual daemon app token requests | Check source IPs against corporate servers/SaaS |
5-Point Enterprise App Persistence Audit Checklist
| Artifact to Check | PowerShell / Portal Location | What Signals a Backdoor |
|---|---|---|
| Recent Apps Created | Entra -> App Registrations & Enterprise Apps | Unverified publishers or suspicious names ("Sync", "PDF") |
| High-Risk App Role Assignments | Get-MgServicePrincipalAppRoleAssignment | Mail.Read, Mail.Send, Files.ReadWrite.All, RoleManagement.* |
| Delegated OAuth Grants | Get-MgOauth2PermissionGrant | AllPrincipals or single-user Mail/Files + offline_access |
| Multiple/Recent Secrets & Certs | Get-MgApplication & Get-MgServicePrincipal | >1 active secret or newly added 2-year key |
| Service Principal Sign-In IPs | Entra -> Monitoring -> Service principal sign-ins | App authenticating from Tor, VPS, or residential proxy |
Application Role Assignment Backdoor in Entra Audit JSON
{
"activityDateTime": "2026-12-02T14:25:11Z",
"activityDisplayName": "Add app role assignment to service principal",
"category": "ApplicationManagement",
"initiatedBy": { "user": { "userPrincipalName": "app.admin@contoso-demo.invalid", "ipAddress": "185.220.101.45" } },
"targetResources": [
{ "displayName": "Microsoft Graph", "type": "ServicePrincipal" },
{ "displayName": "TenantBackupSyncTool", "type": "ServicePrincipal" }
]
}
Notice the two targetResources: the resource (`Microsoft Graph`) and the client (`TenantBackupSyncTool`). Any unexpected `Add app role assignment to service principal` fires AuditVane AV-005 immediately.
Enumerate All Non-Microsoft Enterprise Apps Holding High-Risk Graph App Roles
Connect-MgGraph -Scopes "Application.Read.All","Directory.Read.All"
$graphSp = Get-MgServicePrincipal -Filter "appId eq '00000003-0000-0000-c000-000000000000'"
$highRiskRoles = $graphSp.AppRoles | Where-Object { $_.Value -match "Mail|Files|RoleManagement|Directory\.ReadWrite|Application\.ReadWrite" }
$highRiskMap = @{}; $highRiskRoles | ForEach-Object { $highRiskMap[$_.Id] = $_.Value }
Get-MgServicePrincipal -All | Where-Object { $_.AppOwnerOrganizationId -ne "f8cdef31-a31e-4b4a-93e4-5f571e91255a" } | ForEach-Object {
$sp = $_
Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $sp.Id -ErrorAction SilentlyContinue | ForEach-Object {
if ($highRiskMap.ContainsKey($_.AppRoleId)) {
[PSCustomObject]@{ AppName = $sp.DisplayName; AppId = $sp.AppId; Permission = $highRiskMap[$_.AppRoleId]; Created = $_.CreatedDateTime }
}
}
} | Format-Table -AutoSize
Sample High-Risk Graph App Role Inventory
AppName AppId Permission Created
------- ----- ---------- -------
TenantBackupSyncTool a8812f10-1122-3344-5566-778899aabbcc Mail.Read 12/02/2026 14:25:11
Step-by-Step Triage, Containment & Verification
- Drop Entra Directory Audit JSON and Purview UAL CSV (RecordType 8) into AuditVane and review all AV-005 alerts.
- Run the Graph App Role audit script above across the entire tenant to list every third-party Service Principal holding Mail, Files, RoleManagement, or Directory write permissions.
- Inspect `AppOwnerOrganizationId` to verify whether the app belongs to your home tenant, a verified SaaS vendor, or an unknown external tenant.
- Check `Get-MgApplication` AND `Get-MgServicePrincipal` for newly added secrets, certificates, or unexpected Owners.
- Disable (`Update-MgServicePrincipal -AccountEnabled:$false`) and remove unauthorized apps (`Remove-MgServicePrincipal` / `Remove-MgApplication`).
- Inspect `AADServicePrincipalSignInLogs` for the suspicious `AppId` to track every IP and timestamp when the backdoor executed.
How to Verify Containment Completed Cleanly
- 100% of third-party Enterprise Apps holding Mail.*, Files.*, or RoleManagement.* permissions verified with business owners.
- Unauthorized Service Principals disabled and deleted cleanly.
- Workload Identity Conditional Access (or Microsoft Entra Workload ID controls) evaluated for high-privilege apps.
Analyst Blind Spots, Licensing Quirks & False Positives
Remember Microsoft’s first-party tenant GUID (`f8cdef31-a31e-4b4a-93e4-5f571e91255a`) owns native Microsoft services—excluding it cleans out noisy Microsoft platform apps while exposing every custom and third-party multi-tenant app clearly.
Never leave single-developer accounts as permanent Owners on production high-privilege App Registrations; transfer ownership to dedicated privileged security teams.
Frequently Asked Questions
What is the difference between an App Registration and an Enterprise Application?
App Registration is the application definition created in its home tenant; Enterprise Application (ServicePrincipal) is the local instance granted permissions and consent inside your tenant.
Can an Enterprise App access mailboxes without any user logging in?
Yes! Once granted Application Permissions like Mail.Read via Add app role assignment, it fetches tokens directly using a client secret or certificate.
Does AuditVane detect App Role Assignment backdoors?
Yes, AuditVane AV-005 catches Add app role assignment to service principal, Add application, Consent to application, and Add service principal credentials.
Can Conditional Access protect Service Principal logins?
Yes—Microsoft Entra Workload Identities (with Workload ID Premium licensing) lets you apply Conditional Access IP restrictions directly to Service Principals!