Bylaw

Gallery › Security Center › Azure built-in policies

Secure Boot should be enabled on supported Windows virtual machines

Converted Policy Audit Disabled Mode Indexed Version 4.0.1

Enable Secure Boot on supported Windows virtual machines to mitigate against malicious and unauthorized changes to the boot chain. Once enabled, only trusted bootloaders, kernel and kernel drivers will be allowed to run. This assessment applies to Trusted Launch and Confidential Windows virtual machines.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONASC_EnableWindowsSB_Audit.json · 73 lines
{
  "properties": {
    "displayName": "Secure Boot should be enabled on supported Windows virtual machines",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Enable Secure Boot on supported Windows virtual machines to mitigate against malicious and unauthorized changes to the boot chain. Once enabled, only trusted bootloaders, kernel and kernel drivers will be allowed to run. This assessment applies to Trusted Launch and Confidential Windows virtual machines.",
    "metadata": {
      "category": "Security Center",
      "version": "4.0.1"
    },
    "version": "4.0.1",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Compute/virtualMachines"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Compute/virtualMachines/storageProfile.imageReference.offer",
                "like": "windows*"
              },
              {
                "field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType",
                "like": "Windows*"
              }
            ]
          },
          {
            "field": "Microsoft.Compute/virtualMachines/securityProfile.securityType",
            "in": [
              "TrustedLaunch",
              "ConfidentialVM"
            ]
          },
          {
            "field": "Microsoft.Compute/virtualMachines/securityProfile.uefiSettings",
            "exists": "true"
          },
          {
            "field": "Microsoft.Compute/virtualMachines/securityProfile.uefiSettings.secureBootEnabled",
            "notequals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "4.0.1",
      "4.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/97566dd7-78ae-4997-8b36-1c7bfe0d8121",
  "name": "97566dd7-78ae-4997-8b36-1c7bfe0d8121"
}
Bylaw97566dd7-78ae-4997-8b36-1c7bfe0d8121.bylaw.ps1 · 38 lines
# Converted from ASC_EnableWindowsSB_Audit.json by ConvertTo-Bylaw.
Policy '97566dd7-78ae-4997-8b36-1c7bfe0d8121' {

    Properties @{
        DisplayName   = 'Secure Boot should be enabled on supported Windows virtual machines'
        Description   = 'Enable Secure Boot on supported Windows virtual machines to mitigate against malicious and unauthorized changes to the boot chain. Once enabled, only trusted bootloaders, kernel and kernel drivers will be allowed to run. This assessment applies to Trusted Launch and Confidential Windows virtual machines.'
        Category      = 'Security Center'
        Version       = '4.0.1'
        PolicyVersion = '4.0.1'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Compute/virtualMachines' {

        When {
            AnyOf {
                Field storageProfile.imageReference.offer | Must -BeLike 'windows*'
                Field storageProfile.osDisk.osType | Must -BeLike 'Windows*'
            }
            Field securityProfile.securityType | Must -BeIn @('TrustedLaunch', 'ConfidentialVM')
            Field securityProfile.uefiSettings | Must -Exist
        }

        Require 'securityProfile.uefiSettings.secureBootEnabled is true' {
            Field securityProfile.uefiSettings.secureBootEnabled | Must -Be 'true'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Security Center/ASC_EnableWindowsSB_Audit.json in Azure/azure-policy, under the MIT licence.