Language:
First-Party Service Principals (Enterprise Applications) come from applications (Application Registrations) belonging to Microsoft. Most of them have sensitive permissions in Microsoft Entra ID that you often overlook during security reviews. This allows attackers to add credentials to them to stealthily benefit from their privileges.
This technique offers persistence capabilities as well as privilege escalation, because principals with the Application Administrator role can add credentials to applications including those that have higher privileges.
First-party service principals should not have any credentials, except in rare cases (see Recommendations).
The APT29 threat group abused this method in the infamous December 2020 attack against SolarWinds called "Solorigate", as documented by Microsoft and by Mandiant.
Disabled service principals are ignored by default (parameter can be changed) because they cannot be immediately used by attackers.
Begin by evaluating the legitimacy of the observed credentials. You may consider these credentials to be legitimate if they associate with one of the following service principals: Exchange Online / Skype for Business / AAD Password Protection Proxy.
In other cases where you suspect that the credentials are not legitimate:
You cannot list service principal credentials using the Azure portal, unlike credentials attached to applications. Use the Get-MgServicePrincipal cmdlet of Microsoft Graph PowerShell to list service principal credentials:
Get-MgServicePrincipal -ServicePrincipalId <objectid> -Property keyCredentials | select -ExpandProperty keyCredentials
Get-MgServicePrincipal -ServicePrincipalId <objectid> -Property passwordCredentials | select -ExpandProperty passwordCredentials
To delete these credentials, use:
$keycredentials = (Get-MgServicePrincipal -ServicePrincipalId <objectid>).KeyCredentials
, then removing the undesired one(s) from $keycredentials
, and finally by applying this new array with Update-MgServicePrincipal -ServicePrincipalId <objectid> -KeyCredentials $keycredentials
. To clear all you can use simply: Update-MgServicePrincipal -ServicePrincipalId <objectid> -KeyCredentials @()
.Or alternatively using the now deprecated AzureAD PowerShell Module:
Get-AzureADServicePrincipalKeyCredential
and Remove-AzureADServicePrincipalKeyCredential
Get-AzureADServicePrincipalPasswordCredential
and Remove-AzureADServicePrincipalPasswordCredential
Name: First-Party Service Principal With Credentials
Codename: FIRST-PARTY-SERVICE-PRINCIPAL-WITH-CREDENTIALS
Severity: High