You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/fundamentals/service-accounts-principal.md
+43-39Lines changed: 43 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,85 +8,83 @@ ms.service: active-directory
8
8
ms.workload: identity
9
9
ms.subservice: fundamentals
10
10
ms.topic: conceptual
11
-
ms.date: 08/20/2022
11
+
ms.date: 11/28/2022
12
12
ms.author: jricketts
13
13
ms.reviewer: ajburnle
14
14
ms.custom: "it-pro, seodec18"
15
15
ms.collection: M365-identity-device-management
16
16
---
17
17
18
-
# Securing service principals
18
+
# Securing service principals
19
19
20
-
An Azure Active Directory (Azure AD) [service principal](../develop/app-objects-and-service-principals.md) is the local representation of an application object in a single tenant or directory. It functions as the identity of the application instance. Service principals define who can access the application, and what resources the application can access. A service principal is created in each tenant where the application is used and references the globally unique application object. The tenant secures the service principal’s signin and access to resources.
20
+
An Azure Active Directory (Azure AD) [service principal](../develop/app-objects-and-service-principals.md) is the local representation of an application object in a single tenant or directory. It functions as the identity of the application instance. Service principals define who can access the application, and what resources the application can access. A service principal is created in each tenant where the application is used, and references the globally unique application object. The tenant secures the service principal sign-in and access to resources.
21
21
22
22
### Tenant-service principal relationships
23
-
A single-tenant application has only one service principal in its home tenant. A multi-tenant web application or API requires a service principal in each tenant. A service principal is created when a user from that tenant has consented to the application's or API's use. This consent creates a one-to-many relationship between the multi-tenant application and its associated service principals.
24
23
25
-
A multi-tenant application is homed in a single tenant and is designed to have instances in other tenants. Most software-as-a-service (SaaS) applications are designed for multi-tenancy.
26
-
Use service principals to ensure the right security posture for the application and its users in both single tenant and multi-tenant use cases.
24
+
A single-tenant application has one service principal in its home tenant. A multi-tenant web application or API requires a service principal in each tenant. A service principal is created when a user from that tenant consents to use of the application or API. This consent creates a one-to-many relationship between the multi-tenant application and its associated service principals.
25
+
26
+
A multi-tenant application is homed in a single tenant and has instances in other tenants. Most software-as-a-service (SaaS) applications accommodate multi-tenancy. Use service principals to ensure the needed security posture for the application and its users in single-tenant and multi-tenant scenarios.
27
27
28
28
## ApplicationID and ObjectID
29
29
30
-
A given application instance has two distinct properties: the ApplicationID (also known as ClientID) and the ObjectID.
30
+
An application instance has two properties: the ApplicationID (also known as ClientID) and the ObjectID.
31
31
32
32
> [!NOTE]
33
-
> You may find that the terms application and service principal are used interchangeably when loosely referring to an application in the context of authenticationrelated tasks. However, they are two different representations of applications in Azure AD.
33
+
> It's possible the terms application and service principal are used interchangeably when referring to an application in the context of authentication-related tasks. However, they are two representations of applications in Azure AD.
34
34
35
+
The ApplicationID represents the global application and is the same for application instances across tenants. The ObjectID is a unique value for an application object. As with users, groups, and other resources, the ObjectID helps to identify an application instance in Azure AD.
35
36
36
-
The ApplicationID represents the global application and is the same for all the application instances across tenants. The ObjectID is a unique value for an application object. As with users, groups, and other resources, the ObjectID helps uniquely identify an application instance in Azure AD.
37
-
38
-
For more detailed information on this topic, see [Application and service principal relationship](../develop/app-objects-and-service-principals.md).
37
+
To learn more, see [Application and service principal relationship](../develop/app-objects-and-service-principals.md).
39
38
40
-
You can also create an application and its service principal object (ObjectID) in a tenant using Azure PowerShell, Azure CLI, Microsoft Graph, the Azure portal, and other tools.
39
+
You can create an application and its service principal object (ObjectID) in a tenant using Azure PowerShell, Azure CLI, Microsoft Graph, the Azure portal, and other tools.
41
40
42
41

43
42
44
43
## Service principal authentication
45
44
46
-
There are two mechanisms for authentication using service principals—client certificates and client secrets.
45
+
When using service principals—client certificates and client secrets, there are two mechanisms for authentication.
47
46
48
47

49
48
50
-
Certificates are more secure: use client certificates if possible. Unlike client secrets, client certificates cannot accidentally be embedded in code. Use Azure Key Vault for certificate and secrets management when possible to encrypt the following assets by using keys protected by hardware security modules:
49
+
Certificates are more secure, therefore use them, if possible. Unlike client secrets, client certificates can't be embedded in code, accidentally. When possible, use Azure Key Vault for certificate and secrets management to encrypt the following assets with keys protected by hardware security modules:
51
50
52
-
*authentication keys
51
+
*Authentication keys
53
52
54
-
*storage account keys
53
+
*Storage account keys
55
54
56
-
*data encryption keys
55
+
*Data encryption keys
57
56
58
57
* .pfx files
59
58
60
-
*passwords
59
+
*Passwords
61
60
62
61
For more information on Azure Key Vault and how to use it for certificate and secret management, see
63
62
[About Azure Key Vault](../../key-vault/general/overview.md) and [Assign a Key Vault access policy using the Azure portal](../../key-vault/general/assign-access-policy-portal.md).
64
63
65
64
### Challenges and mitigations
66
-
The following table presents mitigations to challenges you may encounter when using service principals.
67
-
65
+
66
+
Use the following table to match challenges and mitigations, when using service principals.
68
67
69
68
| Challenges| Mitigations |
70
69
| - | - |
71
-
| Access reviews for service principals assigned to privileged roles.| This functionality is in preview, and not yet widely available.|
72
-
| Reviews service principals’ access| Manual check of resource’s access control list using the Azure portal.|
73
-
| Overpermissioned service principals| When you create automation service accounts or or service principals, provide only the permissions that are required for the task. Evaluate existing service principals to see if you can reduce privileges.|
74
-
|Identify modifications to service principals' credentials or authentication methods |Use the Sensitive Operations Report workbook, which can help mitigate this issue. [See the explanation in this blog post](https://techcommunity.microsoft.com/t5/azure-active-directory-identity/azure-ad-workbook-to-help-you-assess-solorigate-risk/ba-p/2010718).|
70
+
| Access reviews for service principals assigned to privileged roles| This functionality is in preview, and not widely available |
71
+
| Reviews service principal access| Manual check of resource access control list using the Azure portal |
72
+
| Over-permissioned service principals| When you create automation service accounts or or service principals, provide permissions required for the task. Evaluate service principals to reduce privileges |
73
+
|Identify modifications to service principal credentials or authentication methods |Use the Sensitive Operations Report workbook to mitigate. See also the Tech Community blog post[Azure AD workbook to help you assess Solorigate risk](https://techcommunity.microsoft.com/t5/azure-active-directory-identity/azure-ad-workbook-to-help-you-assess-solorigate-risk/ba-p/2010718).|
75
74
76
75
## Find accounts using service principals
77
-
Run the following commands to find accounts using service principals.
78
76
79
-
Using Azure CLI
77
+
Run the following commands to find accounts using service principals with Azure CLI or PowerShell.
80
78
79
+
Azure CLI:
81
80
82
81
`az ad sp list`
83
82
84
-
Using PowerShell
83
+
PowerShell:
85
84
86
85
`Get-AzureADServicePrincipal -All:$true`
87
86
88
-
89
-
For more information see [Get-AzureADServicePrincipal](/powershell/module/azuread/get-azureadserviceprincipal)
87
+
For more information see [Get-AzureADServicePrincipal](/powershell/module/azuread/get-azureadserviceprincipal).
90
88
91
89
## Assess service principal security
92
90
@@ -96,26 +94,27 @@ Mitigate potential challenges using the following information.
96
94
97
95
|Challenges | Mitigations|
98
96
| - | - |
99
-
| Detect the user that consented to a multi-tenant app, and detect illicit consent grants to a multi-tenant app | Run the following PowerShell to find multi-tenant apps.<br>`Get-AzureADServicePrincipal -All:$true ? {$_.Tags -eq WindowsAzureActiveDirectoryIntegratedApp"}`<br>Disable user consent. <br>Allow user consent from verified publishers, for selected permissions (recommended) <br> Configure them under the user context, and their tokens should be used to trigger the service principal.|
100
-
|Use of a hard-coded shared secret in a script using a service principal.|Use a certificate or Azure Key Vault.|
101
-
|Tracking who is using the certificate or the secret| Monitor the service principal's sign-ins using the Azure AD sign-in logs.|
102
-
Can't manage service principals' sign-in with Conditional Access.| Monitor the sign-ins using the Azure AD sign-in logs
103
-
|The default Azure RBAC role is Contributor. |Evaluate the needs and apply the role with the least possible permissions to meet that need.|
97
+
| Detect the user who consented to a multi-tenant app, and detect illicit consent grants to a multi-tenant app | Run the following PowerShell to find multi-tenant apps.<br>`Get-AzureADServicePrincipal -All:$true ? {$_.Tags -eq WindowsAzureActiveDirectoryIntegratedApp"}`<br>Disable user consent. <br>Allow user consent from verified publishers, for selected permissions (recommended) <br> Configure them in the user context. Use their tokens to trigger the service principal.|
98
+
|Use of a hard-coded shared secret in a script using a service principal|Use a certificate|
99
+
|Tracking who uses the certificate or the secret| Monitor the service principal sign-ins using the Azure AD sign-in logs|
100
+
Can't manage service principal sign-in with Conditional Access| Monitor the sign-ins using the Azure AD sign-in logs
101
+
|Contributor is the default Azure role-based access control (RBAC) role|Evaluate needs and apply the role with the least possible permissions|
104
102
105
103
## Move from a user account to a service principal
106
-
If you are using an Azure user account as a service principal, evaluate if you can move to a [Managed Identity](../../app-service/overview-managed-identity.md?tabs=dotnet) or a service principal. If you cannot use a managed identity, provision a service principal that has just enough permissions and scope to run the required tasks. You can create a service principal by [registering an application](../develop/howto-create-service-principal-portal.md), or with [PowerShell](../develop/howto-authenticate-service-principal-powershell.md).
107
104
108
-
When using Microsoft Graph, check the documentation of the specific API, [like in this example](/powershell/azure/create-azure-service-principal-azureps), and make sure the permission type for application is showing as supported.
105
+
If you're using an Azure user account as a service principal, evaluate if you can move to a [Managed Identity](../../app-service/overview-managed-identity.md?tabs=dotnet) or a service principal. If you can't use a managed identity, provision a service principal with enough permissions and scope to run the required tasks. You can create a service principal by [registering an application](../develop/howto-create-service-principal-portal.md), or with [PowerShell](../develop/howto-authenticate-service-principal-powershell.md).
106
+
107
+
When using Microsoft Graph, check the API documentation. See, [Create an Azure service principal](/powershell/azure/create-azure-service-principal-azureps). Ensure the permission type for application is supported.
109
108
110
109
## Next steps
111
110
112
-
**To learn more about service principals:**
111
+
Learn more about service principals:
113
112
114
113
[Create a service principal](../develop/howto-create-service-principal-portal.md)
115
114
116
-
[Monitor service principal sign-ins](../reports-monitoring/concept-sign-ins.md)
115
+
[Monitor service principal sign-ins](../reports-monitoring/concept-sign-ins.md)
117
116
118
-
**To learn more about securing service accounts:**
117
+
Learn more about securing service accounts:
119
118
120
119
[Introduction to Azure service accounts](service-accounts-introduction-azure.md)
121
120
@@ -124,3 +123,8 @@ When using Microsoft Graph, check the documentation of the specific API, [like i
124
123
[Governing Azure service accounts](service-accounts-governing-azure.md)
125
124
126
125
[Introduction to on-premises service accounts](service-accounts-on-premises.md)
126
+
127
+
Conditional Access:
128
+
129
+
Use Conditional Access to block service principals from untrusted locations. See, [Create a location-based Conditional Access policy](/azure/active-directory/conditional-access/workload-identity#create-a-location-based-conditional-access-policy).
0 commit comments