Bylaw

Gallery › Storage › Azure Landing Zones Library

File Services with insecure SMB versions should be denied

Converted Policy Audit Deny Disabled Mode All Version 1.1.0

This policy denies the use of insecure versions of SMB (2.1 & 3.0) 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-InsecureSmbVersions.alz_policy_definition.json · 75 lines
{
  "name": "Deny-FileServices-InsecureSmbVersions",
  "properties": {
    "description": "This policy denies the use of insecure versions of SMB (2.1 \u0026 3.0) when using File Services on a storage account.",
    "displayName": "File Services with insecure SMB versions should be denied",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Storage",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.1.0"
    },
    "mode": "All",
    "parameters": {
      "allowedSmbVersion": {
        "allowedValues": [
          "SMB2.1",
          "SMB3.0",
          "SMB3.1.1"
        ],
        "defaultValue": "SMB3.1.1",
        "metadata": {
          "description": "The allowed SMB version for maximum security",
          "displayName": "Allowed SMB Version"
        },
        "type": "String"
      },
      "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"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Storage/storageAccounts/fileServices",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "exists": false,
                "field": "Microsoft.Storage/storageAccounts/fileServices/protocolSettings.smb.versions"
              },
              {
                "not": {
                  "contains": "[parameters('allowedSmbVersion')]",
                  "field": "Microsoft.Storage/storageAccounts/fileServices/protocolSettings.smb.versions"
                }
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-FileServices-InsecureSmbVersions.bylaw.ps1 · 38 lines
# Converted from Deny-FileServices-InsecureSmbVersions.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-FileServices-InsecureSmbVersions' {

    Properties @{
        DisplayName = 'File Services with insecure SMB versions should be denied'
        Description = 'This policy denies the use of insecure versions of SMB (2.1 & 3.0) 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 AllowedSmbVersion @{
        AllowedValues = @('SMB2.1', 'SMB3.0', 'SMB3.1.1')
        Default       = 'SMB3.1.1'
        DisplayName   = 'Allowed SMB Version'
        Description   = 'The allowed SMB version for maximum security'
    }
    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.Storage/storageAccounts/fileServices' {

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

        Require 'protocolSettings.smb.versions contains the AllowedSmbVersion parameter' {
            Field protocolSettings.smb.versions | Must -ContainText (Param AllowedSmbVersion)
        }
    }

    Effect (Param Effect)
}

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