Use the Conformity Knowledge Base AI to help improve your Cloud Posture

Use Managed Identities for Azure Container Registries

Trend Cloud One™ – Conformity is a continuous assurance tool that provides peace of mind for your cloud infrastructure, delivering over 1000 automated best practice checks.

Risk Level: Medium (should be achieved)

Ensure that your Microsoft Azure container registries are using system-assigned and/or user-assigned managed identities to allow secure access to other cloud protected resources such as Azure key vaults. Managed identities minimizes risks, simplifies management, and maintains compliance with evolving cloud services.

Security
Operational
excellence

Using system-assigned and/or user-assigned managed identities for Azure container registries enhances security by allowing the Azure Container Registry (ACR) service to authenticate and authorize with Azure services and resources without the need for explicit credentials. This reduces the risk associated with credential management, allows granular control over access permissions, and provides a seamless and more secure integration with other Azure cloud components.


Audit

To determine if your Azure container registries are configured to use system-assigned and/or user-assigned managed identities, perform the following operations:

Using Azure Console

01 Sign in to the Microsoft Azure Portal.

02 Navigate to All resources blade available at https://portal.azure.com/#browse/all to access all your Microsoft Azure cloud resources.

03 Choose the Azure subscription that you want to access from the Subscription equalls all filter box and choose Apply.

04 From the Type equalls all filter box, choose Equals, select Container registry, and choose Apply to list only the Microsoft Azure container registries available in the selected subscription.

05 Click on the name (link) of the Azure container registry that you want to examine.

06 In the resource navigation panel, under Settings, select Identity, and perform the following checks to determine if the selected container registry is using managed identities:

  1. Select the System assigned tab and check the configuration setting status available under Status. If Status is set to Off, the selected Microsoft Azure container registry is not using a system-assigned managed identity.
  2. Select the User assigned tab and check for any user-assigned managed identities associated with the selected resource. If there are no user identities listed on this page, instead the following message is displayed: No user assigned managed identities found on this resource, the selected Azure container registry is not using user-assigned managed identities.

07 Repeat steps no. 5 and 6 for each Azure container registry available in the selected Azure subscription.

08 Repeat steps no. 3 – 7 for each subscription created in your Microsoft Azure cloud account.

Using Azure CLI

01 Run account list command (Windows/macOS/Linux) with custom output filters to list the IDs of the cloud subscriptions available in your Azure cloud account:

az account list
  --query '[*].id'

02 The command output should return the requested subscription identifiers (IDs):

[
	"abcdabcd-1234-abcd-1234-abcdabcdabcd",
	"abcd1234-abcd-1234-abcd-abcd1234abcd"
]

03 Run account set command (Windows/macOS/Linux) with the ID of the Azure cloud subscription that you want to examine as the identifier parameter to set the selected subscription to be the current active subscription (the command does not produce an output):

az account set
  --subscription abcdabcd-1234-abcd-1234-abcdabcdabcd

04 Run acr list command (Windows/macOS/Linux) with custom output filters to list the name and the associated resource group for each Azure container registry available in the current subscription:

az acr list
  --output table
  --query '[*].{name:name, resourceGroup:resourceGroup}'

05 The command output should return the requested container registry identifiers:

Name                        ResourceGroup
-------------------------   ------------------------------
Project5ContainerRegistry   cloud-shell-storage-westeurope
DevAIContainerRegistry      cloud-shell-storage-westeurope

06 Run acr show command (Windows/macOS/Linux) with the name of the Azure container registry that you want to examine as the identifier parameter and custom output filters to determine the type of the managed identity (i.e. system-assigned and/or user-assigned) configured for the selected container registry:

az acr show
  --name Project5ContainerRegistry
  --resource-group cloud-shell-storage-westeurope
  --query '{"IdentityType":identity.type}'

07 The command output should return the identity type used by the selected container registry:

{
	"IdentityType": null
}

If the acr show command output returns null for the "IdentityType" attribute, as shown in the example above, the selected Microsoft Azure container registry is not using a system-assigned and/or user-assigned managed identity to authenticate to other Azure cloud services.

08 Repeat step no. 6 and 7 for each Azure container registry available in the selected Azure subscription.

09 Repeat steps no. 3 – 8 for each subscription created in your Microsoft Azure cloud account.

Remediation / Resolution

To ensure that your Microsoft Azure container registries are configured to use system-assigned and/or user-assigned managed identities, perform the following operations:

Using Azure Console

01 Sign in to the Microsoft Azure Portal.

02 Navigate to Managed Identities blade available at https://portal.azure.com/#browse/Microsoft.ManagedIdentity%2FuserAssignedIdentities.

03 Choose the Azure subscription that you want to access from the Subscription equalls all filter box and choose Apply.

04 Choose Create and perform the following actions to create a new user-assigned managed identity:

  1. For Basics, choose the correct subscription and resource group, provide a unique name for the new managed identity, then select the Azure region where your cloud resources are deployed. Choose Next to continue the setup process.
  2. For Tags, use the Name and Value fields to create tags that will help organize the identity of the identity. Choose Review + create to validate the identity setup.
  3. For Review + create, review the resource configuration details, then choose Create to create your new user-assigned managed identity.

05 Navigate to All resources blade at https://portal.azure.com/#browse/all to access all your Microsoft Azure cloud resources.

06 Choose the Azure subscription that you want to access from the Subscription equalls all filter box and choose Apply.

07 From the Type equalls all filter box, choose Equals, select Container registry, and choose Apply to list only the Microsoft Azure container registries available in the selected subscription.

08 Click on the name (link) of the Azure container registry that you want to configure.

09 In the resource navigation panel, under Settings, select Identity, and perform the following actions to enable system-assigned and user-assigned managed identities for the selected container registry:

  1. Choose the System assigned tab and select On under Status to enable the system-assigned managed identity for the selected Azure container registry. Choose Save and select Yes to confirm the changes. Your container registry is now registered with Microsoft Entra ID, eliminating the need to store credentials in your code.
  2. Select the User assigned tab, choose + Add, select the appropriate Azure subscription from the Select a subscription dropdown list, and choose the user-assigned managed identity created earlier in the Remediation process, from the User assigned managed identities list. Choose Add to apply the configuration changes.

10 Repeat steps no. 8 and 9 for each Azure container registry that you want to configure, available in the selected Azure subscription.

11 Repeat steps no. 3 – 10 for each subscription created in your Microsoft Azure cloud account.

Using Azure CLI

01 Run account list command (Windows/macOS/Linux) with custom output filters to list the IDs of the cloud subscriptions available in your Azure cloud account:

az account list
  --query '[*].id'

02 The command output should return the requested subscription identifiers (IDs):

[
	"abcdabcd-1234-abcd-1234-abcdabcdabcd",
	"abcd1234-abcd-1234-abcd-abcd1234abcd"
]

03 Run account set command (Windows/macOS/Linux) with the ID of the Azure cloud subscription that you want to examine as the identifier parameter to set the selected subscription to be the current active subscription (the command does not produce an output):

az account set
  --subscription abcdabcd-1234-abcd-1234-abcdabcdabcd

04 Run acr identity assign command (OSX/Linux/UNIX) with the name of the Azure container registry that you want to configure as the identifier parameter, to enable the system-assigned managed identity for the function managed with the specified container registry:

az acr identity assign
  --name Project5ContainerRegistry
  --resource-group cloud-shell-storage-westeurope
  --identities [system]
  --query 'identity'

05 Once the assignment process is completed, the command output should return the information available for the managed identity:

{
	"principalId": "abcd1234-abcd-1234-abcd-1234abcd1234",
	"tenantId": "1234abcd-abcd-1234-abcd-abcd1234abcd",
	"type": "SystemAssigned",
	"userAssignedIdentities": null
}

06 Run identity create command (OSX/Linux/UNIX) to create a new user-assigned managed identity for the specified Azure container registry:

az identity create
  --name Project5ContainerRegistry
  --resource-group cloud-shell-storage-westeurope
  --location westeurope
  -query 'id'

07 The command output should return the full ID of the new user-assigned managed identity:

"/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourcegroups/cloud-shell-storage-westeurope/providers/Microsoft.ManagedIdentity/userAssignedIdentities/Project5ContainerRegistry"

08 Run acr identity assign command (OSX/Linux/UNIX) with the name of the Azure container registry that you want to configure as the identifier parameter to assign your new user-assigned managed identity to the selected container registry:

az acr identity assign
  --name Project5ContainerRegistry
  --resource-group cloud-shell-storage-westeurope
  --identities "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourcegroups/cloud-shell-storage-westeurope/providers/Microsoft.ManagedIdentity/userAssignedIdentities/Project5ContainerRegistry"
  --query 'identity'

09 Once the assignment process is completed, the command output should return the information available for the managed identity:

{
	"principalId": null,
	"tenantId": null,
	"type": "UserAssigned",
	"userAssignedIdentities": {
		"/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourcegroups/cloud-shell-storage-westeurope/providers/Microsoft.ManagedIdentity/userAssignedIdentities/Project5ContainerRegistry": {
			"clientId": "1234abcd-abcd-1234-abcd-abcd1234abcd",
			"principalId": "abcd1234-abcd-1234-abcd-1234abcd1234"
		}
	}
}

10 Repeat steps no. 4 - 9 for each Azure container registry that you want to configure, available within the current subscription.

11 Repeat steps no. 3 – 10 for each subscription created in your Microsoft Azure cloud account.

References

Publication date Oct 23, 2024