A service principal flagged as risky in Microsoft Entra is an unattended identity that may already be in an attacker's hands, and nobody gets an MFA prompt to warn them. Service principals authenticate with secrets, certificates or federated credentials, often hold application permissions across Microsoft Graph or Azure subscriptions, and rarely have an owner watching their sign-ins. This guide walks an identity security analyst or Entra administrator through one incident: confirming the risk signal, reviewing credentials and permissions, reading the sign-in and audit trail, containing the identity with a clear view of business impact, and hardening it so the same path cannot be reused. For how service principals relate to app registrations and Azure RBAC, see the Azure RBAC and Service Principals Guide; this page does not repeat it.
This is an independent guide from NHI Mgmt Group, based on Microsoft's public Entra documentation as of November 2026. It is not sponsored or reviewed by Microsoft. Product features change, so confirm settings against Microsoft's current documentation.
Key takeaways
- Treat the risk flag as a lead, not a verdict. All workload identity detections are offline, so the compromise may be hours old by the time you see it; work back from the detection timestamp.
- Check both objects. Credentials can sit on the application object and on the service principal object; an attacker who adds a secret to either has a working key.
- Disable before you delete. Setting the service principal to disabled stops new token issuance and buys time to assess impact; deletion and key rolling come after.
- Revocation is more than one step. Removing credentials, revoking consent grants and app role assignments, and rotating secrets the identity could read are separate actions, and skipping any one leaves a path open.
- Fix the root cause. Containment does not explain how the attacker got in; find whether a compromised admin, a leaked secret or a consent grant created the access before closing the case.
What makes a service principal risky
Microsoft Entra ID Protection evaluates service principals separately from users. A risky workload identity appears under ID Protection > Risky workload identities, and individual detections appear on the Workload identity detections tab of the Risk detections report. Microsoft documents every current workload identity detection as offline (calculated after the event), which matters for timeline work.
| Detection | riskEventType | What it indicates | First question to ask |
|---|---|---|---|
| Leaked credentials | leakedCredentials | A valid credential for the identity was found in a public code artefact or a data breach | Which credential (key ID) leaked, and has it been used since? |
| Suspicious sign-ins | suspiciousSignins | Sign-in properties unusual for this identity: IP or ASN, target resource, user agent, hosting versus non-hosting IP, country, credential type | Did an approved change (new region, new pipeline runner) cause it? |
| Anomalous service principal activity | anomalousServicePrincipalActivity | Unusual administrative changes to the directory made by, or made to, the service principal | What objects changed, and who approved it? |
| Suspicious API traffic | suspiciousAPITraffic | Abnormal Microsoft Graph traffic or directory enumeration | What data could the identity read with its current permissions? |
| Microsoft Entra threat intelligence | investigationsThreatIntelligence | Activity consistent with known attack patterns | Is the same infrastructure seen against other identities in the tenant? |
| Suspicious application | suspiciousApplication | The app may violate terms of service but has not been disabled by Microsoft | Is this a multitenant app you consented to, and who uses it? |
| Malicious application | maliciousApplication | Microsoft disabled the app for a terms of service violation | Which users and data did it touch before it was disabled? |
| Admin confirmed service principal compromised | adminConfirmedServicePrincipalCompromised | An administrator selected Confirm compromised | Which admin, and was the case already opened? |
Risk is not the only trigger. Treat these signals as equivalent leads even when ID Protection is quiet: a new secret or certificate added outside change management, a new owner on the application, a new high-privilege app role assignment such as Directory.ReadWrite.All or Mail.* on Microsoft Graph, and sign-ins from an IP range the workload has never used.
Coverage: detections cover single-tenant apps, multitenant apps and non-Microsoft SaaS apps in your tenant. Managed identities are not currently in scope for workload identity risk detections, so a suspicious managed identity is investigated from logs and Azure RBAC alone.
Availability: Microsoft states that all tenants receive the detections, while full risk details and risk-based Conditional Access for workload identities need Microsoft Entra Workload ID Premium. Viewing the reports needs at least Security Reader; the compromised application playbook expects investigators to hold Security Administrator; creating Conditional Access policies needs Conditional Access Administrator; revoking app permissions needs Cloud Application Administrator or Application Administrator.
Triage: confirm the signal
Aim to reach a decision (benign, suspicious, confirmed compromised) within the first hour. Work through these steps in order:
- Record the facts: service principal object ID (from Enterprise applications, not App registrations), application (client) ID, detection type, risk level, detection timestamp and risk state.
- Identify the type: single-tenant (you own the code and credentials), multitenant from a vendor (the vendor owns credentials; you own the consent), or a Microsoft first-party app.
- Find the owner: list owners on the application object and in Enterprise applications. Contact them to confirm whether any recent credential, location or permission change was planned.
- Check for planned change: match the detection against change tickets and deployment logs. Suspicious sign-ins can fire after an authorised move to a new hosting provider or region; Microsoft notes that baselines take between 2 and 60 days to learn.
- Size the blast radius: list Graph application permissions, delegated grants, Entra directory roles and Azure RBAC role assignments held by the identity.
- Decide: if the change is explained and documented, dismiss the risk with a note. If any credential, permission or sign-in is unexplained, move to containment in parallel with the deeper review below.
Review credentials, permissions and owners
Inventory everything that lets the identity authenticate or act. The table lists where each item lives and the audit activity that records a change, using the activity names in Microsoft's documentation.
| Item | Where to look | Audit activity to search | Red flag |
|---|---|---|---|
| Client secrets and certificates | passwordCredentials and keyCredentials on the application object and on the service principal object | Update application - Certificates and secrets management; Update Service principal | A credential added recently, outside working hours, or with a lifetime beyond policy; any password credential on a service principal object |
| Federated identity credentials | Certificates and secrets > Federated credentials on the app registration | Update application (check modified properties) | An issuer or subject you do not recognise, such as an unknown repository or Kubernetes cluster |
| Microsoft Graph and API application permissions | Enterprise application > Permissions > Admin consent; appRoleAssignments | Add app role assignment to service principal | High-privilege roles such as *.All, Directory.ReadWrite.All, RoleManagement.ReadWrite.Directory or Mail.* |
| Delegated grants | oauth2PermissionGrants for the service principal | Add delegated permission grant; Consent to application | ConsentType of AllPrincipals with sensitive scopes; consent by a privileged user |
| Entra directory roles | Roles and administrators, filtered to service principals | Add member to role; Add eligible member to role; Add scoped member to role | Any privileged role assigned outside change management |
| Azure RBAC roles | Access control (IAM) at management group, subscription and resource group scope | Azure Activity log: role assignment write operations | Owner, Contributor or User Access Administrator at broad scope |
| Owners | Owners on the application and the enterprise application | Add owner to application | A user added as owner who can now add credentials without an admin role |
Record each credential's keyId, display name, start and end date. The key ID is how you link a credential to the sign-ins it produced. For a structured review of federated trust relationships, see How to audit Entra workload identity federated credentials. For finding long-lived or forgotten secrets across the tenant once the incident is closed, see How to find expiring app secrets and certificates in Entra ID.
Analyse sign-ins and activity
For detection rule design on these logs, see the Entra ID Audit Log Detection Guide.
Entra keeps four sign-in log types: interactive user, non-interactive user, service principal and managed identity. A service principal authenticating with its own secret or certificate appears only in Service principal sign-ins; managed identity sign-ins appear only in the managed identity log. Reading these logs in the admin center needs at least Reports Reader. For investigations longer than the portal retention window, send sign-in and audit categories to a Log Analytics workspace through diagnostic settings, where they land in the AADServicePrincipalSignInLogs, AADManagedIdentitySignInLogs and AuditLogs tables.
Build the timeline around four questions Microsoft gives for workload identity investigations: suspicious sign-in activity, unauthorised credential changes, suspicious configuration changes, and unauthorised application roles.
- Sign-in baseline: compare the last 30 days of IP addresses, ASNs, countries and target resources with the period before the detection.
- Credential to sign-in link: check which credential key ID each sign-in used. Sign-ins using a credential added during the suspicious window are strong evidence of attacker use.
- Resource activity: follow the identity into the resources it reached. For Graph, review mailbox, file and directory reads where audit data exists; for Azure, review the Activity log for writes made by the service principal's object ID, especially role assignments, Key Vault secret reads and new resources.
- Changes the identity made: search AuditLogs where the initiating actor is the service principal. A compromised identity holding
Application.ReadWrite.Allcan add credentials to other applications, which turns one incident into several. - Who changed the identity: search AuditLogs where the target is the application or service principal. If an admin account added the credential, that account is in scope too: see How to Investigate a Compromised Entra ID Account.
Contain and remediate
Containment actions differ in speed, reversibility and impact. Choose by the identity's privilege and the confidence of the finding, and coordinate with the application owner so that a production outage is a decision, not a surprise.
| Action | How | Effect | Impact and caveats |
|---|---|---|---|
| Disable the service principal | Enterprise application > Properties > Enabled for users to sign in = No, or set accountEnabled to false through Microsoft Graph; also available from the Risky workload identities report | Blocks new token issuance for the identity | Breaks every process using it; fully reversible; tokens already issued remain valid until they expire |
| Confirm compromised | Risky workload identities > Confirm compromised | Raises risk to high and feeds risk-based Conditional Access | Recorded in risk history with the confirming admin |
| Remove credentials | removePassword and removeKey on the application and on each service principal, after adding a replacement | Invalidates leaked or attacker-added keys | Microsoft advises removing all existing credentials if the account is at risk; workloads fail until they hold the new credential |
| Revoke app permissions | Enterprise application > Permissions > Revoke permission (admin consent); Graph or PowerShell to remove oauth2PermissionGrants and appRoleAssignments | Stops new tokens carrying those permissions | User consent grants cannot be revoked in the portal; users can consent again unless consent settings are restricted; revoked permissions can be restored |
| Rotate reachable secrets | Rotate Key Vault secrets, keys and certificates the identity could read, starting with those it actually read | Closes the second-stage exposure | Often the slowest step; prioritise secrets confirmed read in Key Vault logs |
| Delete the application | Delete the app registration or enterprise application | Removes the identity | Soft-deleted apps can be restored for 30 days; monitor for "Add Service Principal" and for "Update Service Principal" re-enabling the account |
A safe order for a confirmed compromise of a single-tenant identity:
- Disable the service principal and confirm compromised. If an admin account may also be compromised, time this with the admin eviction so the attacker loses every route at once.
- Remove attacker-added credentials, roles, grants, owners and federated credentials found in the review.
- Add a new certificate credential (Microsoft recommends X.509 certificates), deploy it to the legitimate workload, then remove all remaining old credentials. The Entra secret rotation guide covers overlap rotation.
- Rotate Key Vault and other secrets the identity could reach.
- Re-enable the service principal only after the owner confirms the workload uses the new credential and the permissions match its documented need.
- For a multitenant vendor app, you cannot rotate the vendor's credentials: revoke consent, disable the enterprise application in your tenant, and contact the vendor. Apps that Microsoft disabled for a terms of service violation show
DisabledDueToViolationOfServicesAgreementand cannot be deleted, which stops them being re-created in your tenant.
Credential removal cannot be rolled back, which is why the replacement goes in first. Preserve evidence before you remove anything: export the application manifest, owners, credentials list (key IDs, not secret values), permission grants, role assignments and the relevant sign-in and audit rows.
Harden to prevent recurrence
- Replace secrets where possible: move Azure-hosted workloads to managed identities so there is no credential to leak, and external workloads such as CI pipelines to workload identity federation. See the Azure Managed Identities Security Guide.
- Use certificates over client secrets: where a credential must exist, prefer an X.509 certificate held in a hardware-backed or managed store, with a short lifetime and an owner who receives expiry alerts. The Azure Entra Client Secrets Security Guide covers credential policy.
- Apply Conditional Access for workload identities: block single-tenant service principals from outside named locations and block them at medium or high service principal risk. Policies must target the service principal directly (group targeting is not enforced), target All resources, and support Block only. Start in report-only mode and review the Service principal sign-ins Conditional Access tab before enforcing. See Conditional Access for Workload Identities.
- Restrict consent: limit user consent, enable the admin consent workflow and keep risk-based step-up consent on. See How to restrict user consent to apps in Entra ID.
- Alert on the change, not only on risk: create detections for credential additions, owner additions and privileged app role assignments, since these precede most service principal abuse and work for managed identities and unlicensed tenants too.
Detection, framework mapping and metrics
| Framework | Reference | Relevance |
|---|---|---|
| MITRE ATT&CK | T1098.001 Additional Cloud Credentials | Attacker adds a secret or certificate to an application or service principal |
| MITRE ATT&CK | T1098.003 Additional Cloud Roles | Attacker grants new directory roles or app role assignments |
| MITRE ATT&CK | T1078.004 Cloud Accounts | Use of a valid service principal credential |
| NIST SP 800-53 Rev 5 | IR-4, IA-5, AC-2, AC-6, AU-6 | Incident handling, authenticator management, account management, least privilege, log review |
| NIST CSF 2.0 | RS.MI-01, PR.AA-05 | Incidents are contained; access permissions are managed and reviewed |
Metrics that show the process is working:
- Time to triage: median time from detection timestamp to a benign or compromised decision.
- Time to contain: median time from decision to service principal disabled or credentials removed.
- Unowned risky identities: share of risky service principals with no reachable owner at the time of detection (target zero).
- Secret-based identities: share of service principals still authenticating with client secrets, tracked down over time.
- Conditional Access coverage: share of single-tenant service principals covered by a location or risk policy.
Common failure patterns
- Rotating only the application object: the team removes secrets on the app registration but misses a password credential added directly to the service principal, which keeps working.
- Revoking consent but leaving consent open: grants are removed, user consent settings stay permissive, and the same app is consented to again days later.
- Ignoring the second stage: the identity is cleaned up but the Key Vault secrets and storage keys it read are not rotated, so the attacker keeps access through other credentials.
- Stopping at the identity: the admin account or consent grant that created the access is never investigated, and the attacker creates a new service principal.
Practitioner checklist
- Inventory secrets, certificates and federated credentials on both the application and service principal objects, with key IDs.
- List Graph permissions, delegated grants, directory roles and Azure RBAC assignments, and flag any added in the incident window.
- Correlate service principal sign-ins by credential key ID, IP, ASN and resource against a pre-incident baseline.
- Search audit logs for changes made by and to the identity, and widen scope to any admin who made them.
- Export evidence, then disable the service principal and confirm compromised.
- Add a certificate credential, deploy it, then remove all old credentials; revoke unneeded grants and roles.
- Rotate Key Vault and other secrets the identity could read.
- Apply Conditional Access for workload identities, restrict consent and move the workload to a managed identity or federation where possible.
Standards and references
- Microsoft Learn: Securing workload identities with Microsoft Entra ID Protection
- Microsoft Learn: Compromised and malicious applications investigation
- Microsoft Learn: Microsoft Entra security operations guide for applications
- Microsoft Learn: Review and revoke permissions granted to an enterprise application
- Microsoft Learn: Conditional Access for workload identities
- Microsoft Learn: Service principal sign-in logs
- MITRE ATT&CK: T1098.001 Additional Cloud Credentials
- NIST: SP 800-53 Rev 5 Security and Privacy Controls
Related NHI Mgmt Group resources: Azure RBAC and Service Principals Guide · Microsoft Entra ID Protection · Entra ID Applications and Consent Guide · Cloud Workload Identity Guide