AKS Cluster RBAC Disabled

  • Query id: 9307a2ed-35c2-413d-94de-a1a0682c2158
  • Query name: AKS Cluster RBAC Disabled
  • Platform: AzureResourceManager
  • Severity: Medium
  • Category: Access Control
  • URL: Github

Description

Microsoft.ContainerService/managedClusters should have enableRBAC set to true
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "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": {}
}
Positive test num. 2 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "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"
              }
            ]
          }
        },
        "enableRBAC": false,
        "servicePrincipalProfile": {
          "clientId": "servicePrincipalAppId",
          "secret": "servicePrincipalAppPassword"
        }
      }
    }
  ],
  "outputs": {}
}
Positive test num. 3 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "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"
}

Positive test num. 4 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "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"
                  }
                ]
              }
            },
            "enableRBAC": false,
            "servicePrincipalProfile": {
              "clientId": "servicePrincipalAppId",
              "secret": "servicePrincipalAppPassword"
            }
          }
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "storageTemplate"
}

Code samples without security vulnerabilities

Negative test num. 1 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "resources": [
    {
      "name": "aksCluster1",
      "type": "Microsoft.ContainerService/managedClusters",
      "apiVersion": "2020-02-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "enableRBAC": true,
        "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": {}
}
Negative test num. 2 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "resources": [
        {
          "name": "aksCluster1",
          "type": "Microsoft.ContainerService/managedClusters",
          "apiVersion": "2020-02-01",
          "location": "[resourceGroup().location]",
          "properties": {
            "enableRBAC": true,
            "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"
}