Bylaw

Gallery › Storage › Azure Landing Zones Library

File Services with insecure SMB channel encryption should be denied

Converted Policy Audit Deny Disabled Mode All Version 1.1.0

This policy denies the use of insecure channel encryption (AES-128-CCM) when using File Services on a storage account.

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

Azure Policy JSONDeny-FileServices-InsecureSmbChannel.alz_policy_definition.json · 73 lines
{
  "name": "Deny-FileServices-InsecureSmbChannel",
  "properties": {
    "description": "This policy denies the use of insecure channel encryption (AES-128-CCM) when using File Services on a storage account.",
    "displayName": "File Services with insecure SMB channel encryption should be denied",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Storage",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.1.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "The effect determines what happens when the policy rule is evaluated to match",
          "displayName": "Effect"
        },
        "type": "String"
      },
      "notAllowedChannelEncryption": {
        "allowedValues": [
          "AES-128-CCM",
          "AES-128-GCM",
          "AES-256-GCM"
        ],
        "defaultValue": "AES-128-CCM",
        "metadata": {
          "description": "The list of channelEncryption not allowed.",
          "displayName": "SMB channel encryption supported by server. Valid values are AES-128-CCM, AES-128-GCM, AES-256-GCM."
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Storage/storageAccounts/fileServices",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "exists": false,
                "field": "Microsoft.Storage/storageAccounts/fileServices/protocolSettings.smb.channelEncryption"
              },
              {
                "contains": "[parameters('notAllowedChannelEncryption')]",
                "field": "Microsoft.Storage/storageAccounts/fileServices/protocolSettings.smb.channelEncryption"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-FileServices-InsecureSmbChannel.bylaw.ps1 · 38 lines
# Converted from Deny-FileServices-InsecureSmbChannel.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-FileServices-InsecureSmbChannel' {

    Properties @{
        DisplayName = 'File Services with insecure SMB channel encryption should be denied'
        Description = 'This policy denies the use of insecure channel encryption (AES-128-CCM) when using File Services on a storage account.'
        Category    = 'Storage'
        Version     = '1.1.0'
        Mode        = 'All'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }
    Parameter NotAllowedChannelEncryption @{
        AllowedValues = @('AES-128-CCM', 'AES-128-GCM', 'AES-256-GCM')
        Default       = 'AES-128-CCM'
        DisplayName   = 'SMB channel encryption supported by server. Valid values are AES-128-CCM, AES-128-GCM, AES-256-GCM.'
        Description   = 'The list of channelEncryption not allowed.'
    }

    Resource 'Microsoft.Storage/storageAccounts/fileServices' {

        Require 'protocolSettings.smb.channelEncryption exists' {
            Field protocolSettings.smb.channelEncryption | Must -Exist
        }

        Require 'protocolSettings.smb.channelEncryption does not contain the NotAllowedChannelEncryption parameter' {
            Field protocolSettings.smb.channelEncryption | Must -Not -ContainText (Param NotAllowedChannelEncryption) -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policy_definitions/Deny-FileServices-InsecureSmbChannel.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.