AKS cluster has Microsoft Defender security profile enabled
AKS clusters are evaluated for the Microsoft Defender security profile (securityProfile.defender.securityMonitoring.enabled=true). Defender for Containers extends security monitoring, threat detection, vulnerability assessment, and security posture insights to Azure Kubernetes Service workloads.
Risk
Without the Microsoft Defender security profile, AKS runtime threats such as cryptomining, suspicious Kubernetes API activity, vulnerable container images, and malicious workload behavior may go undetected. Compromised containers can pivot to cluster resources and cloud APIs, impacting confidentiality, integrity, and availability.
Run this check with Prowler
Run in Prowler Cloudprowler azure --checks aks_cluster_defender_enabledRecommendation
Enable the Microsoft Defender security profile for AKS clusters and ensure the subscription has Defender for Containers enabled. Route security monitoring data to the appropriate workspace and review Defender alerts and recommendations as part of the cluster operations process.
Remediation
CLI
az aks update --resource-group <RESOURCE_GROUP> --name <CLUSTER_NAME> --enable-defenderTerraform
resource "azurerm_log_analytics_workspace" "example" {
name = "<workspace-name>"
location = "<location>"
resource_group_name = "<resource-group>"
sku = "PerGB2018"
}
resource "azurerm_kubernetes_cluster" "example" {
name = "<cluster-name>"
location = "<location>"
resource_group_name = "<resource-group>"
dns_prefix = "<dns-prefix>"
default_node_pool {
name = "system"
node_count = 1
vm_size = "Standard_DS2_v2"
}
identity {
type = "SystemAssigned"
}
microsoft_defender {
log_analytics_workspace_id = azurerm_log_analytics_workspace.example.id
}
}NativeIaC
// AKS cluster with Microsoft Defender security monitoring enabled
resource aks 'Microsoft.ContainerService/managedClusters@2024-05-01' = {
name: '<CLUSTER_NAME>'
location: '<LOCATION>'
identity: {
type: 'SystemAssigned'
}
properties: {
dnsPrefix: '<DNS_PREFIX>'
securityProfile: {
defender: {
logAnalyticsWorkspaceResourceId: '<LOG_ANALYTICS_WORKSPACE_RESOURCE_ID>'
securityMonitoring: {
enabled: true // Critical: enables Defender security monitoring for AKS
}
}
}
agentPoolProfiles: [
{
name: 'system'
count: 1
vmSize: 'Standard_DS2_v2'
mode: 'System'
}
]
}
}Other
Check Code
from prowler.lib.check.models import Check, Check_Report_Azure
from prowler.providers.azure.services.aks.aks_client import aks_client
class aks_cluster_defender_enabled(Check):
def execute(self) -> list[Check_Report_Azure]:
findings = []
for subscription_name, clusters in aks_client.clusters.items():
for cluster in clusters.values():
report = Check_Report_Azure(metadata=self.metadata(), resource=cluster)
report.subscription = subscription_name
if cluster.defender_enabled is True:
report.status = "PASS"
report.status_extended = (
f"Cluster '{cluster.name}' has Defender for Containers "
"enabled."
)
else:
report.status = "FAIL"
report.status_extended = (
f"Cluster '{cluster.name}' does not have Defender for "
"Containers enabled."
)
findings.append(report)
return findings