How the attack works
An application signs in to Microsoft Entra ID as a service principal, with a client secret or a certificate instead of a password. Microsoft lists what makes these workload identities harder to protect than users: they cannot perform multifactor authentication, they often have no formal lifecycle process, and they need to store their credentials or secrets somewhere. That somewhere is often a configuration file, a script or a pipeline variable, and from there the credential ends up in a code repository or in stolen data.
A leaked secret is a complete credential. Whoever holds it requests tokens as the application and gets every permission the application was granted, from any network, without a prompt. Microsoft looks for such leaks on behalf of its customers. When its leaked credentials service acquires credentials from GitHub, the dark web, paste sites or other sources, it checks them against the current valid credentials in Microsoft Entra ID and raises the workload identity risk detection "Leaked Credentials" (leakedCredentials) for a valid match.
The detection says that the credential is exposed, not that it was used. Use shows in other workload identity detections. "Suspicious Sign-ins" (suspiciousSignins) reports sign-in properties or patterns that are unusual for the service principal, such as a new IP address, target resource or credential type. "Anomalous service principal activity" (anomalousServicePrincipalActivity) reports unusual administrative behaviour, such as suspicious changes to the directory, and "Suspicious API Traffic" (suspiciousAPITraffic) reports abnormal Graph traffic or directory enumeration. All of them are calculated offline and are written to the AADServicePrincipalRiskEvents table through the ServicePrincipalRiskEvents diagnostic setting. Managed identities are not in scope of these detections.
What an attacker needs
- A valid client secret or the private key of a certificate of an application in the tenant, taken from a code repository, a configuration file, a build log or stolen data.
- No Conditional Access policy for workload identities that blocks the service principal by location or by risk.
Impact
A session as the application with all of its permissions, for as long as the credential stays valid. For an application with privileged Microsoft Graph permissions or a directory role, that is control of large parts of the tenant. Nothing asks for a second factor, and the sign-ins are recorded in the service principal sign-in log, which is a separate log from the user sign-ins.
Detection rules
ID Protection Detected Leaked Credentials of a Service Principal
Detects the Microsoft Entra ID Protection workload identity risk detection "Leaked Credentials" (riskEventType leakedCredentials). Microsoft raises it when the valid credentials of the account leaked, for example when someone checks in the credentials in a public code artifact on GitHub or when they leak through a data breach. Credentials that the Microsoft leaked credentials service acquires from GitHub, the dark web, paste sites or other sources are checked against the current valid credentials in Microsoft Entra ID, so a detection is a valid match. It is calculated offline. A service principal cannot perform MFA, so the leaked credential is enough to sign in. Customers without Workload Identities Premium receive the detection with limited reporting details. The records reach a SIEM through the ServicePrincipalRiskEvents diagnostic setting of Microsoft Entra ID. The application is in ServicePrincipalDisplayName and AppId, and the key credential in KeyIds.
title: ID Protection Detected Leaked Credentials of a Service Principal
id: 7e7daef7-1364-4d72-89a8-9f55826b5a59
status: experimental
description: >-
Detects the Microsoft Entra ID Protection workload identity risk detection
"Leaked Credentials" (riskEventType leakedCredentials). Microsoft raises it
when the valid credentials of the account leaked, for example when someone
checks in the credentials in a public code artifact on GitHub or when they
leak through a data breach. Credentials that the Microsoft leaked
credentials service acquires from GitHub, the dark web, paste sites or other
sources are checked against the current valid credentials in Microsoft
Entra ID, so a detection is a valid match. It is calculated offline. A
service principal cannot perform MFA, so the leaked credential is enough to
sign in. Customers without Workload Identities Premium receive the
detection with limited reporting details. The records reach a SIEM through
the ServicePrincipalRiskEvents diagnostic setting of Microsoft Entra ID.
The application is in ServicePrincipalDisplayName and AppId, and the key
credential in KeyIds.
references:
- https://learn.microsoft.com/en-us/entra/id-protection/concept-workload-identity-risk
- https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/aadserviceprincipalriskevents
- https://learn.microsoft.com/en-us/entra/id-protection/howto-export-risk-data
- https://attack.mitre.org/techniques/T1589/001/
author: Forestall
date: 2026-11-18
tags:
- attack.reconnaissance
- attack.t1589.001
logsource:
product: azure
service: sp-riskdetection
detection:
selection:
RiskEventType: leakedCredentials
condition: selection
falsepositives:
- None expected. Microsoft checks the leaked credential against the current valid credentials of the application. A credential that was already removed closes the exposure, and the detection then only needs to be dismissed.
level: high
False positives
- None expected. Microsoft checks the leaked credential against the current valid credentials of the application. A credential that was already removed closes the exposure, and the detection then only needs to be dismissed.
ID Protection Flagged Unusual Sign-Ins or Activity of a Service Principal
Detects four Microsoft Entra ID Protection workload identity risk detections that point to a service principal being used by somebody else. "Suspicious Sign-ins" (suspiciousSignins) reports sign-in properties or patterns that are unusual for the service principal, such as an unfamiliar IP address or ASN, target resource, user agent, IP country or credential type, after a learning period of 2 to 60 days. "Anomalous service principal activity" (anomalousServicePrincipalActivity) reports anomalous patterns of administrative behaviour, like suspicious changes to the directory. "Suspicious API Traffic" (suspiciousAPITraffic) reports abnormal Graph API traffic or directory enumeration of a service principal. "Microsoft Entra threat intelligence" (investigationsThreatIntelligence) reports activity consistent with known attack patterns. All four are calculated offline, so they arrive after the activity, and for a suspicious sign-in Microsoft gives a timestamp instead of a specific sign-in event. The records reach a SIEM through the ServicePrincipalRiskEvents diagnostic setting.
title: ID Protection Flagged Unusual Sign-Ins or Activity of a Service Principal
id: 5b169e69-da24-45b4-a4ac-368ba22258da
status: experimental
description: >-
Detects four Microsoft Entra ID Protection workload identity risk
detections that point to a service principal being used by somebody else.
"Suspicious Sign-ins" (suspiciousSignins) reports sign-in properties or
patterns that are unusual for the service principal, such as an unfamiliar
IP address or ASN, target resource, user agent, IP country or credential
type, after a learning period of 2 to 60 days. "Anomalous service principal
activity" (anomalousServicePrincipalActivity) reports anomalous patterns of
administrative behaviour, like suspicious changes to the directory.
"Suspicious API Traffic" (suspiciousAPITraffic) reports abnormal Graph API
traffic or directory enumeration of a service principal. "Microsoft Entra
threat intelligence" (investigationsThreatIntelligence) reports activity
consistent with known attack patterns. All four are calculated offline, so
they arrive after the activity, and for a suspicious sign-in Microsoft gives
a timestamp instead of a specific sign-in event. The records reach a SIEM
through the ServicePrincipalRiskEvents diagnostic setting.
references:
- https://learn.microsoft.com/en-us/entra/id-protection/concept-workload-identity-risk
- https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/aadserviceprincipalriskevents
- https://learn.microsoft.com/en-us/entra/id-protection/howto-export-risk-data
- https://attack.mitre.org/techniques/T1078/004/
author: Forestall
date: 2026-11-18
tags:
- attack.initial-access
- attack.t1078.004
logsource:
product: azure
service: sp-riskdetection
detection:
selection:
RiskEventType:
- suspiciousSignins
- anomalousServicePrincipalActivity
- suspiciousAPITraffic
- investigationsThreatIntelligence
condition: selection
falsepositives:
- Authorized configuration changes. Microsoft notes that sign-ins initiated after an authorized configuration change might trigger the suspicious sign-ins detection, for example when an application moves to another hosting platform or gets a new credential.
- Applications that start a new kind of work, such as a first full inventory of the directory. Confirm the change with the owner of the application and dismiss the risk in ID Protection.
level: medium
False positives
- Authorized configuration changes. Microsoft notes that sign-ins initiated after an authorized configuration change might trigger the suspicious sign-ins detection, for example when an application moves to another hosting platform or gets a new credential.
- Applications that start a new kind of work, such as a first full inventory of the directory. Confirm the change with the owner of the application and dismiss the risk in ID Protection.
Detection logic
Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.
Sign-in with the leaked credential from an address the application does not use
The leak detection confirms exposure, not use. The service principal sign-in log records which credential each sign-in used. A sign-in with the leaked key from an address outside the application's usual set is the difference between a secret that lay in a repository and a secret that somebody picked up.
AADServicePrincipalRiskEvents: a detection withRiskEventTypeleakedCredentials. TakeServicePrincipalIdand the key identifier inKeyIds.AADServicePrincipalSignInLogs, 30 days before the detection: build the set ofIPAddressvalues for thatServicePrincipalId.- Same table, from the earliest plausible leak date onward: sign-ins of that
ServicePrincipalIdwhoseServicePrincipalCredentialKeyIdis the leaked key and whoseIPAddressis not in the set. - Alert on any such sign-in, successful or not.
EventsleakedCredentials
LimitsApplications that run on cloud platforms with changing egress addresses have no stable set, so every sign-in looks new. The service principal sign-in log has to be collected, which is a separate diagnostic category. The 30 days are a starting point.
New credential added to an application after its credentials leaked
An attacker who signs in with a leaked secret expects it to be rotated. The usual way to keep the access is to add a credential of their own to the application or its service principal while the leaked one still works. A credential added after the leak date by the application itself, or by nobody the owners know, is that step.
AADServicePrincipalRiskEvents: a detection withRiskEventTypeleakedCredentials or suspiciousSignins. TakeServicePrincipalIdandAppId.- Audit log, 14 days around the detection:
Add service principal credentialsorUpdate application - Certificates and secrets managementwhoseTargetResourcesname that application or service principal. - Alert when the actor in
InitiatedByis the service principal itself or an account that does not own the application.
EventsleakedCredentialssuspiciousSigninsAdd service principal credentialsUpdate application - Certificates and secrets management
LimitsThe rotation that answers the leak adds a credential too, so the responder's own change has to be excluded. Who owns an application is a list only you have. The 14 days are a starting point.
Triage
- Read the detection. ServicePrincipalDisplayName, AppId, RiskEventType, RiskLevel, IpAddress and Activity say which application is affected and what was seen. KeyIds holds the identifier of the key credential the detection refers to.
- List the credentials of the application and of the service principal, and find the one named in KeyIds. Check when it was added and whether it is still valid.
- Review the service principal sign-in log for sign-ins with that credential from addresses the application does not normally use.
- List the permissions and roles of the application to know what the credential opens.
- Search the audit log for changes the service principal made, and for credentials added to the application after the leak.
- Find where the credential leaked, for example a repository, so that the same mistake is not repeated with the replacement.
Response
Once the attack is confirmed:
- Add a new credential for the application, move the workload to it, and remove the leaked credential. Microsoft recommends removing all existing credentials when you believe the account is at risk.
- Disable the service principal in the meantime if the application can be stopped, so that the leaked credential cannot be used.
- Rotate the Azure Key Vault secrets and the other secrets the service principal had access to.
- Review and undo what was done with the application's identity while the credential was exposed, such as new credentials, role assignments, consent grants and data access.
- Confirm the service principal as compromised in ID Protection when the review shows use by somebody else, and dismiss the risk when it does not.
- Remove the credential from the place it leaked from, and from the history of the repository.
Mitigation
- Use managed identities or workload identity federation where the platform supports them, so that there is no secret to leak.
- Where a credential is needed, prefer certificates over client secrets, keep lifetimes short and store the credential in a secret store, never in code or configuration files.
- Turn on secret scanning and push protection in your code repositories.
- Remove permissions and directory roles that applications do not need, so that a leaked credential is worth less.
- With Workload Identities Premium, use Conditional Access for workload identities to block single-tenant service principals outside known locations or when ID Protection marks them at risk.
- Send the
ServicePrincipalRiskEventsdiagnostic category to your SIEM.
Frequently asked questions
Does a leaked credentials detection for a service principal mean the application was breached?
Not by itself. Microsoft raises it when credentials it acquired from GitHub, the dark web, paste sites or other sources match the current valid credentials of the application. That confirms the exposure. Whether somebody used the credential shows in the service principal sign-in log and in other workload identity detections, such as Suspicious Sign-ins.
Do workload identity risk detections need a Workload Identities Premium license?
Not to receive them. Microsoft states that customers without Workload Identities Premium licenses still receive all detections with limited reporting details. Full risk details and risk-based access controls, such as Conditional Access for workload identities, are available to Workload Identities Premium customers.
Are managed identities covered by these detections?
No. Microsoft states that ID Protection detects risk on single tenant, non-Microsoft SaaS and multitenant apps, and that managed identities are not currently in scope. A managed identity has no secret that an administrator handles, which is why it is the preferred way to avoid this attack.
Why do the rules convert for Microsoft Sentinel only?
Workload identity risk detections are exported through the ServicePrincipalRiskEvents diagnostic setting, which fills the AADServicePrincipalRiskEvents table in Log Analytics. The library has no documented Splunk or QRadar mapping for these records yet, so the page shows those two as not available instead of guessing field names.
References
- MITRE ATT&CK T1589.001: Gather Victim Identity Information, Credentials
- MITRE ATT&CK T1078.004: Valid Accounts, Cloud Accounts
- Securing workload identities (workload identity risk detections)
- AADServicePrincipalRiskEvents table reference
- How to export risk data (ServicePrincipalRiskEvents diagnostic setting)
- Microsoft Entra audit log activities (application credential activities)