Bylaw

Gallery › Kubernetes › Azure built-in policies

[Preview]: Sets Privilege escalation in the Pod spec in init containers to false.

Doesn't convert yet Policy Disabled Mode Microsoft.Kubernetes.Data Version 1.2.0-preview Preview

Setting Privilege escalation to false in init containers increases security by preventing containers from allowing privilege escalation such as via set-user-ID or set-group-ID file mode.

ConvertTo-Bylaw can't convert this policy yet:

Azure Policy JSONMutatePrivilegeEscalationInitContainers.json · 87 lines
{
  "properties": {
    "displayName": "[Preview]: Sets Privilege escalation in the Pod spec in init containers to false.",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "Setting Privilege escalation to false in init containers increases security by preventing containers from allowing privilege escalation such as via set-user-ID or set-group-ID file mode.",
    "metadata": {
      "version": "1.2.0-preview",
      "category": "Kubernetes",
      "preview": true
    },
    "version": "1.2.0-preview",
    "parameters": {
      "source": {
        "type": "String",
        "metadata": {
          "displayName": "Source",
          "description": "The source k8s object for constraint evaluation. 'Original' means only evaluate against the specific GroupVersionKind specified in the policy definition. 'Generated' means only evaluate against k8s objects generated by Gatekeeper ExpansionTemplates. 'All' means evaluate against both the original object and any generated ones."
        },
        "defaultValue": "Original",
        "allowedValues": [
          "All",
          "Generated",
          "Original"
        ]
      },
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "'Mutate' modifies a non-compliant resource to be compliant when creating or updating. 'Disabled' turns off the policy.",
          "portalReview": true
        },
        "allowedValues": [
          "Mutate",
          "Disabled"
        ],
        "defaultValue": "Mutate"
      },
      "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": []
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.ContainerService/managedClusters"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "source": "[parameters('source')]",
          "mutationInfo": {
            "sourceType": "PublicURL",
            "url": "https://store.policy.core.windows.net/kubernetes/mutate-privilege-escalation-init-containers/v1/mutation.yaml"
          },
          "namespaces": "[parameters('namespaces')]",
          "excludedNamespaces": "[parameters('excludedNamespaces')]"
        }
      }
    },
    "versions": [
      "1.2.0-PREVIEW",
      "1.1.0-PREVIEW",
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/4ee3ee6a-96ea-4d25-9c00-17f11d2e02c8",
  "name": "4ee3ee6a-96ea-4d25-9c00-17f11d2e02c8"
}

Source: built-in-policies/policyDefinitions/Kubernetes/MutatePrivilegeEscalationInitContainers.json in Azure/azure-policy, under the MIT licence.