Bylaw

Gallery › Storage › Azure Landing Zones Library

Network ACL bypass option should be restricted for Storage Accounts

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Azure Storage accounts should restrict the bypass option for service-level network ACLs. Enforce this for increased data exfiltration protection.

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

Azure Policy JSONDeny-Storage-NetworkAclsBypass.alz_policy_definition.json · 88 lines
{
  "name": "Deny-Storage-NetworkAclsBypass",
  "properties": {
    "description": "Azure Storage accounts should restrict the bypass option for service-level network ACLs. Enforce this for increased data exfiltration protection.",
    "displayName": "Network ACL bypass option should be restricted for Storage Accounts",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Storage",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "allowedBypassOptions": {
        "allowedValues": [
          "None",
          "Logging",
          "Metrics",
          "AzureServices",
          "Logging, Metrics",
          "Logging, AzureServices",
          "Metrics, AzureServices",
          "Logging, Metrics, AzureServices",
          "Logging, Metrics, AzureServices"
        ],
        "defaultValue": [
          "Logging",
          "Metrics",
          "AzureServices",
          "Logging, Metrics",
          "Logging, AzureServices",
          "Metrics, AzureServices",
          "Logging, Metrics, AzureServices",
          "Logging, Metrics, AzureServices"
        ],
        "metadata": {
          "description": "Specifies which options are allowed to bypass the vnet configuration",
          "displayName": "Allowed Bypass Options"
        },
        "type": "Array"
      },
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Storage/storageAccounts",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "exists": "false",
                "field": "Microsoft.Storage/storageAccounts/networkAcls.bypass"
              },
              {
                "field": "Microsoft.Storage/storageAccounts/networkAcls.bypass",
                "notIn": "[parameters('allowedBypassOptions')]"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-Storage-NetworkAclsBypass.bylaw.ps1 · 39 lines
# Converted from Deny-Storage-NetworkAclsBypass.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-Storage-NetworkAclsBypass' {

    Properties @{
        DisplayName = 'Network ACL bypass option should be restricted for Storage Accounts'
        Description = 'Azure Storage accounts should restrict the bypass option for service-level network ACLs. Enforce this for increased data exfiltration protection.'
        Category    = 'Storage'
        Version     = '1.0.0'
        Mode        = 'All'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

    Parameter AllowedBypassOptions @{
        Type          = 'Array'
        AllowedValues = @('None', 'Logging', 'Metrics', 'AzureServices', 'Logging, Metrics', 'Logging, AzureServices', 'Metrics, AzureServices', 'Logging, Metrics, AzureServices', 'Logging, Metrics, AzureServices')
        Default       = @('Logging', 'Metrics', 'AzureServices', 'Logging, Metrics', 'Logging, AzureServices', 'Metrics, AzureServices', 'Logging, Metrics, AzureServices', 'Logging, Metrics, AzureServices')
        DisplayName   = 'Allowed Bypass Options'
        Description   = 'Specifies which options are allowed to bypass the vnet configuration'
    }
    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'networkAcls.bypass exists' {
            Field networkAcls.bypass | Must -Exist
        }

        Require 'networkAcls.bypass is one of the AllowedBypassOptions parameter' {
            Field networkAcls.bypass | Must -BeIn (Param AllowedBypassOptions)
        }
    }

    Effect (Param Effect)
}

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