last sync: 2021-Oct-22 15:42:38 UTC

Azure Policy definition

Kubernetes cluster pods and containers should only run with approved user and group IDs

Name Kubernetes cluster pods and containers should only run with approved user and group IDs
Azure Portal
Id f06ddb64-5fa3-4b77-b166-acb36f7f6042
Version 4.0.2
details on versioning
Category Kubernetes
Microsoft docs
Description Control the user, primary group, supplemental group and file system group IDs that pods and containers can use to run in a Kubernetes Cluster. This recommendation is part of Pod Security Policies which are intended to improve the security of your Kubernetes environments. This policy is generally available for Kubernetes Service (AKS), and preview for AKS Engine and Azure Arc enabled Kubernetes. For more information, see https://aka.ms/kubepolicydoc.
Mode Microsoft.Kubernetes.Data
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Default: audit
Allowed: (audit, deny, disabled)
Used RBAC Role none
History
Date/Time (UTC ymd) (i) Change type Change detail
2021-09-21 16:12:09 change Patch (4.0.1 > 4.0.2) *changes on text case sensitivity are not tracked
2021-09-08 15:39:57 change Patch (4.0.0 > 4.0.1) *changes on text case sensitivity are not tracked
2021-08-30 14:27:30 change Major (3.0.0 > 4.0.0)
2021-03-02 15:11:40 change Major (2.0.1 > 3.0.0)
2020-12-11 15:42:52 change Major (1.0.1 > 2.0.1)
2020-09-15 14:06:41 change Previous DisplayName: [Preview]: Kubernetes cluster pods and containers should only run with approved user and group IDs
2020-07-08 14:28:08 add f06ddb64-5fa3-4b77-b166-acb36f7f6042
Used in Initiatives
Initiative DisplayName Initiative Id Initiative Category State
[Deprecated]: Azure Security Benchmark v2 bb522ac1-bc39-4957-b194-429bcd3bcb0b Regulatory Compliance Deprecated
[Preview]: NIST SP 800-53 Rev. 5 179d1daa-458f-4e47-8086-2a68d0d6c38f Regulatory Compliance Preview
Azure Security Benchmark 1f3afdf9-d0c9-4c3d-847f-89da613e70a8 Security Center GA
FedRAMP High d5264498-16f4-418a-b659-fa7ef418175f Regulatory Compliance GA
FedRAMP Moderate e95f5a9f-57ad-4d03-bb0b-b1d16db93693 Regulatory Compliance GA
Kubernetes cluster pod security restricted standards for Linux-based workloads 42b8ef37-b724-4e24-bbc8-7a7708edfe00 Kubernetes GA
NIST SP 800-53 Rev. 4 cf25b9c1-bd23-4eb6-bd2c-f4f3ac644a5f Regulatory Compliance GA
JSON Changes

JSON
{
  "displayName": "Kubernetes cluster pods and containers should only run with approved user and group IDs",
  "policyType": "BuiltIn",
  "mode": "Microsoft.Kubernetes.Data",
  "description": "Control the user, primary group, supplemental group and file system group IDs that pods and containers can use to run in a Kubernetes Cluster. This recommendation is part of Pod Security Policies which are intended to improve the security of your Kubernetes environments. This policy is generally available for Kubernetes Service (AKS), and preview for AKS Engine and Azure Arc enabled Kubernetes. For more information, see https://aka.ms/kubepolicydoc.",
  "metadata": {
    "version": "4.0.2",
    "category": "Kubernetes"
  },
  "parameters": {
    "effect": {
      "type": "String",
      "metadata": {
        "displayName": "Effect",
        "description": "'audit' allows a non-compliant resource to be created or updated, but flags it as non-compliant. 'deny' blocks the non-compliant resource creation or update. 'disabled' turns off the policy."
      },
      "allowedValues": [
        "audit",
        "deny",
        "disabled"
      ],
      "defaultValue": "audit"
    },
    "excludedNamespaces": {
      "type": "Array",
      "metadata": {
        "displayName": "Namespace exclusions",
        "description": "List of Kubernetes namespaces to exclude from policy evaluation."
      },
      "defaultValue": [
        "kube-system",
        "gatekeeper-system",
        "azure-arc"
      ]
    },
    "namespaces": {
      "type": "Array",
      "metadata": {
        "displayName": "Namespace inclusions",
        "description": "List of Kubernetes namespaces to only include in policy evaluation. An empty list means the policy is applied to all resources in all namespaces."
      },
      "defaultValue": []
    },
    "labelSelector": {
      "type": "Object",
      "metadata": {
        "displayName": "Kubernetes label selector",
        "description": "Label query to select Kubernetes resources for policy evaluation. An empty label selector matches all Kubernetes resources."
      },
      "defaultValue": {}
    },
    "runAsUserRule": {
      "type": "String",
      "metadata": {
        "displayName": "Run as user rule",
        "description": "The 'RunAsUser' rule that containers are allowed to run with. MustRunAs requires at least one range to be specified. MustRunAsNonRoot requires the pod be submitted with non-zero runAsUser or have USER directive defined (using a numeric UID) in the image. RunAsAny allows any runAsUser to be specified"
      },
      "allowedValues": [
        "MustRunAs",
        "MustRunAsNonRoot",
        "RunAsAny"
      ],
      "defaultValue": "MustRunAsNonRoot"
    },
    "runAsUserRanges": {
      "type": "Object",
      "metadata": {
        "displayName": "Allowed user ID ranges",
        "description": "The user ID ranges that are allowed for containers to use."
      },
      "defaultValue": {
        "ranges": []
      }
    },
    "runAsGroupRule": {
      "type": "String",
      "metadata": {
        "displayName": "Run as group rule",
        "description": "The 'RunAsGroup' rule that containers are allowed to run with. MustRunAs requires at least one range to be specified. MayRunAs does not require that 'RunAsGroup' be specified. RunAsAny allows any"
      },
      "allowedValues": [
        "MustRunAs",
        "MayRunAs",
        "RunAsAny"
      ],
      "defaultValue": "RunAsAny"
    },
    "runAsGroupRanges": {
      "type": "Object",
      "metadata": {
        "displayName": "Allowed group ID ranges",
        "description": "The group ID ranges that are allowed for containers to use."
      },
      "defaultValue": {
        "ranges": []
      }
    },
    "supplementalGroupsRule": {
      "type": "String",
      "metadata": {
        "displayName": "Supplemental group rule",
        "description": "The 'SupplementalGroups' rule that containers are allowed to run with. MustRunAs requires at least one range to be specified. MayRunAs does not require that 'SupplementalGroups' be specified. RunAsAny allows any"
      },
      "allowedValues": [
        "MustRunAs",
        "MayRunAs",
        "RunAsAny"
      ],
      "defaultValue": "RunAsAny"
    },
    "supplementalGroupsRanges": {
      "type": "Object",
      "metadata": {
        "displayName": "Allowed supplemental group ID ranges",
        "description": "The supplemental group ID ranges that are allowed for containers to use."
      },
      "defaultValue": {
        "ranges": []
      }
    },
    "fsGroupRule": {
      "type": "String",
      "metadata": {
        "displayName": "File system group rule",
        "description": "The 'FSGroup' rule that containers are allowed to run with. MustRunAs requires at least one range to be specified. MayRunAs does not require that 'FSGroup' be specified. RunAsAny allows any"
      },
      "allowedValues": [
        "MustRunAs",
        "MayRunAs",
        "RunAsAny"
      ],
      "defaultValue": "RunAsAny"
    },
    "fsGroupRanges": {
      "type": "Object",
      "metadata": {
        "displayName": "Allowed file system group ID ranges",
        "description": "The file system group ranges that are allowed for pods to use."
      },
      "defaultValue": {
        "ranges": []
      }
    },
    "excludedContainers": {
      "type": "Array",
      "metadata": {
        "displayName": "Containers exclusions",
        "description": "The list of InitContainers and Containers to exclude from policy evaluation. The identify is the name of container. Use an empty list to apply this policy to all containers in all namespaces."
      },
      "defaultValue": []
    }
  },
  "policyRule": {
    "if": {
      "field": "type",
      "in": [
        "AKS Engine",
        "Microsoft.Kubernetes/connectedClusters",
        "Microsoft.ContainerService/managedClusters"
      ]
    },
    "then": {
      "effect": "[parameters('effect')]",
      "details": {
        "constraintTemplate": "https://store.policy.core.windows.net/kubernetes/allowed-users-groups/v2/template.yaml",
        "constraint": "https://store.policy.core.windows.net/kubernetes/allowed-users-groups/v2/constraint.yaml",
        "excludedNamespaces": "[parameters('excludedNamespaces')]",
        "namespaces": "[parameters('namespaces')]",
        "labelSelector": "[parameters('labelSelector')]",
        "values": {
          "runAsUser": {
            "rule": "[parameters('runAsUserRule')]",
            "ranges": "[parameters('runAsUserRanges').ranges]"
          },
          "runAsGroup": {
            "rule": "[parameters('runAsGroupRule')]",
            "ranges": "[parameters('runAsGroupRanges').ranges]"
          },
          "supplementalGroups": {
            "rule": "[parameters('supplementalGroupsRule')]",
            "ranges": "[parameters('supplementalGroupsRanges').ranges]"
          },
          "fsGroup": {
            "rule": "[parameters('fsGroupRule')]",
            "ranges": "[parameters('fsGroupRanges').ranges]"
          },
          "excludedContainers": "[parameters('excludedContainers')]"
        }
      }
    }
  }
}