Review Azure Container Registry permission scope

Limit Azure Container Registry permissions for identities that only pull images.

Description

If AKS nodes only pull images, their kubelet identity needs read access. Use separate identities for publishing images and managing registry settings.

Potential impact

An identity that can write images can change images or tags used by other deployments. AcrPush grants image reads and writes. Registry configuration requires separate permissions.

Remediation

Check the registry’s permission mode. In RBAC Registry Permissions mode, grant the kubelet identity AcrPull. In ABAC-enabled mode, assign Container Registry Repository Reader with a condition limiting access to the required repositories. Verify that the nodes can pull their images and that other roles or credentials do not still permit publishing.

Examples

Both examples assign a role to the same kubelet identity at the same registry scope. Define the referenced AKS cluster and registry separately.

Before

hcl
resource "azurerm_role_assignment" "workload" {
  principal_id         = azurerm_kubernetes_cluster.example.kubelet_identity[0].object_id
  role_definition_name = "AcrPush"
  scope                = azurerm_container_registry.example.id
}

After

hcl
resource "azurerm_role_assignment" "workload" {
  principal_id         = azurerm_kubernetes_cluster.example.kubelet_identity[0].object_id
  role_definition_name = "AcrPull"
  scope                = azurerm_container_registry.example.id
}

References