AKS Cluster Network Policy Not Configured
- Query id: 25c0228e-4444-459b-a2df-93c7df40b7ed
- Query name: AKS Cluster Network Policy Not Configured
- Platform: AzureResourceManager
- Severity: Medium
- Category: Insecure Configurations
- URL: Github
Description¶
Azure Kubernetes Service must have a network policy defined.
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Postitive test num. 1 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "aksCluster1",
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2020-02-01",
"location": "[resourceGroup().location]",
"properties": {
"kubernetesVersion": "1.15.7",
"dnsPrefix": "dnsprefix",
"agentPoolProfiles": [
{
"name": "agentpool",
"count": 2,
"vmSize": "Standard_A1",
"osType": "Linux",
"storageProfile": "ManagedDisks"
}
],
"linuxProfile": {
"adminUsername": "adminUserName",
"ssh": {
"publicKeys": [
{
"keyData": "keyData"
}
]
}
},
"servicePrincipalProfile": {
"clientId": "servicePrincipalAppId",
"secret": "servicePrincipalAppPassword"
}
}
}
]
}
Postitive test num. 2 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "aksCluster1",
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2020-02-01",
"location": "[resourceGroup().location]",
"properties": {
"kubernetesVersion": "1.15.7",
"dnsPrefix": "dnsprefix",
"agentPoolProfiles": [
{
"name": "agentpool",
"count": 2,
"vmSize": "Standard_A1",
"osType": "Linux",
"storageProfile": "ManagedDisks"
}
],
"linuxProfile": {
"adminUsername": "adminUserName",
"ssh": {
"publicKeys": [
{
"keyData": "keyData"
}
]
}
},
"servicePrincipalProfile": {
"clientId": "servicePrincipalAppId",
"secret": "servicePrincipalAppPassword"
},
"networkProfile": {
"networkPolicy": ""
}
}
}
]
}
Postitive test num. 3 - json file
{
"properties": {
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "aksCluster1",
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2020-02-01",
"location": "[resourceGroup().location]",
"properties": {
"kubernetesVersion": "1.15.7",
"dnsPrefix": "dnsprefix",
"agentPoolProfiles": [
{
"name": "agentpool",
"count": 2,
"vmSize": "Standard_A1",
"osType": "Linux",
"storageProfile": "ManagedDisks"
}
],
"linuxProfile": {
"adminUsername": "adminUserName",
"ssh": {
"publicKeys": [
{
"keyData": "keyData"
}
]
}
},
"servicePrincipalProfile": {
"clientId": "servicePrincipalAppId",
"secret": "servicePrincipalAppPassword"
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Postitive test num. 4 - json file
{
"properties": {
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "aksCluster1",
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2020-02-01",
"location": "[resourceGroup().location]",
"properties": {
"kubernetesVersion": "1.15.7",
"dnsPrefix": "dnsprefix",
"agentPoolProfiles": [
{
"name": "agentpool",
"count": 2,
"vmSize": "Standard_A1",
"osType": "Linux",
"storageProfile": "ManagedDisks"
}
],
"linuxProfile": {
"adminUsername": "adminUserName",
"ssh": {
"publicKeys": [
{
"keyData": "keyData"
}
]
}
},
"servicePrincipalProfile": {
"clientId": "servicePrincipalAppId",
"secret": "servicePrincipalAppPassword"
},
"networkProfile": {
"networkPolicy": ""
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "aksCluster1",
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2020-02-01",
"location": "[resourceGroup().location]",
"properties": {
"kubernetesVersion": "1.15.7",
"dnsPrefix": "dnsprefix",
"agentPoolProfiles": [
{
"name": "agentpool",
"count": 2,
"vmSize": "Standard_A1",
"osType": "Linux",
"storageProfile": "ManagedDisks"
}
],
"linuxProfile": {
"adminUsername": "adminUserName",
"ssh": {
"publicKeys": [
{
"keyData": "keyData"
}
]
}
},
"servicePrincipalProfile": {
"clientId": "servicePrincipalAppId",
"secret": "servicePrincipalAppPassword"
},
"networkProfile": {
"networkPolicy": "azure"
}
}
}
]
}
Negative test num. 2 - json file
{
"properties": {
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "aksCluster1",
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2020-02-01",
"location": "[resourceGroup().location]",
"properties": {
"kubernetesVersion": "1.15.7",
"dnsPrefix": "dnsprefix",
"agentPoolProfiles": [
{
"name": "agentpool",
"count": 2,
"vmSize": "Standard_A1",
"osType": "Linux",
"storageProfile": "ManagedDisks"
}
],
"linuxProfile": {
"adminUsername": "adminUserName",
"ssh": {
"publicKeys": [
{
"keyData": "keyData"
}
]
}
},
"servicePrincipalProfile": {
"clientId": "servicePrincipalAppId",
"secret": "servicePrincipalAppPassword"
},
"networkProfile": {
"networkPolicy": "azure"
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}