More Info:
Restrict container image pulls to an approved set of registries using firewall rules, admission controllers, or Azure Policy, and limit egress traffic to those registries.Risk Level
MediumAddress
SecurityCompliance Standards
- CIS AKS
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Inventory current image registries in use
- Run on any machine with kubectl access:
- Extract the registry hostnames (first path segment before
/) and compile a list of all registries currently used by workloads (including system namespaces likekube-systemandazure-*).
- Run on any machine with kubectl access:
-
Define and document the approved registry list
- Using your organization’s security policy, decide which registries are approved (for example, specific Azure Container Registries and any required Microsoft/AKS system registries).
- Document them as explicit FQDNs, e.g.:
mycorpprod.azurecr.iomycorptest.azurecr.io- Required Microsoft endpoints as per AKS / egress docs.
-
Restrict access at the registry and network level (Azure side)
- For each Azure Container Registry:
- In the Azure Portal: ACR → Networking → enable Selected networks and add only approved VNets/subnets or private endpoints as per:
https://learn.microsoft.com/azure/container-registry/container-registry-firewall-access-rules - Or via Azure CLI, run on any admin machine:
- In the Azure Portal: ACR → Networking → enable Selected networks and add only approved VNets/subnets or private endpoints as per:
- For cluster egress control:
- If you use a firewall/NVA/Azure Firewall: restrict outbound rules from AKS subnets to only the approved registry FQDNs/IPs according to:
https://learn.microsoft.com/azure/aks/limit-egress-traffic
- If you use a firewall/NVA/Azure Firewall: restrict outbound rules from AKS subnets to only the approved registry FQDNs/IPs according to:
- For each Azure Container Registry:
-
Enforce registry usage with Azure Policy / admission control
- In Azure Portal: Policy → Definitions and locate policies such as:
Kubernetes cluster containers should only use allowed images
- Assign to the AKS cluster’s scope and configure the list of allowed registries (FQDNs from step 2).
- If using Gatekeeper/another admission controller (via IaC), create/update a policy that rejects images whose registry host is not in the approved list. Example (conceptual) for Gatekeeper ConstraintTemplate/Constraint; apply via your existing GitOps/IaC pipeline.
- In Azure Portal: Policy → Definitions and locate policies such as:
-
Verify enforcement and impact
- Attempt to deploy a pod pulling from an unapproved registry, on any machine with kubectl access:
- Confirm that:
- The admission policy rejects the pod (check events):
- Or, if admitted, that image pull fails due to network/egress restrictions (image pull errors in events).
- The admission policy rejects the pod (check events):
- Attempt to deploy a pod pulling from an unapproved registry, on any machine with kubectl access:
-
Re-audit running workloads and system behavior
- Re-run the inventory command (step 1) to confirm that all new pods only use approved registries.
- Review AKS egress logs/firewall logs (Azure Firewall, NSG flow logs, etc.) to ensure no successful outbound connections from AKS subnets to non-approved registries.
Using kubectl
Using kubectl
kubectl cannot be used to restrict container image pulls to approved registries because this control is enforced at the cloud/provider configuration level (Azure Container Registry firewall rules, Azure Policy, and egress controls), not via Kubernetes API objects. Apply the remediation in the cloud console or IaC as described in the Manual Steps section.
Automation
Automation
/tmp/aks-registries-all.txtlists every registry/domain in use.- Any entry that is not on your formally approved list (for example, your ACR FQDNs) is a potential problem.
dockerhub_implicitindicates images likenginx:latestwith no explicit registry, typically Docker Hub. Treat this as unapproved unless your policy explicitly allows it.
- The “Non-approved registries in use:” section (when
approved-registries.txtis present) shows registries that:- Must be blocked via ACR firewall rules, Azure Policy/admission controls, or
- Must be reviewed and either added to the approved list or removed/migrated.
/tmp/aks-image-usage-by-pod.txtlets you trace unapproved registries back to the exact namespaces/workloads to drive remediation decisions.

