Container Registry admin user is enabled

Prefer individual user and workload authentication with least privilege over shared administrator credentials.

Description

The Azure Container Registry admin account uses a shared username and passwords to pull and push images across the registry.

Potential impact

Sharing the account makes it difficult to identify who changed an image or revoke just one user’s access. An exposed password can affect images used by other deployments.

Remediation

Use individual Microsoft Entra identities for people and a supported managed identity or service principal for each workload. Test the required pulls or pushes with those identities, then set admin_enabled = false. If an integration still needs the admin account, restrict its use and protect and rotate its passwords. Regenerate an exposed password and retest dependent connections.

Examples

The examples disable the admin account on the same Premium registry. Choose an available, globally unique registry name. Configure the replacement identities and roles separately.

Before

hcl
resource "azurerm_resource_group" "example" {
  name     = "resourceGroup1"
  location = "West US"
}

resource "azurerm_container_registry" "example" {
  name                     = "containerRegistry1"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  sku                      = "Premium"
  admin_enabled            = true
  georeplications {
    location = "East US"
  }
  georeplications {
    location = "West Europe"
  }
}

After

hcl
resource "azurerm_resource_group" "example" {
  name     = "resourceGroup1"
  location = "West US"
}

resource "azurerm_container_registry" "example" {
  name                     = "containerRegistry1"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  sku                      = "Premium"
  admin_enabled            = false
  georeplications {
    location = "East US"
  }
  georeplications {
    location = "West Europe"
  }
}

References