Bylaw

Gallery › Storage › Azure Landing Zones Library

Resource Access Rules Tenants should be restricted for Storage Accounts

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Azure Storage accounts should restrict the resource access rule for service-level network ACLs to service from the same AAD tenant. 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-ResourceAccessRulesTenantId.alz_policy_definition.json · 58 lines
{
  "name": "Deny-Storage-ResourceAccessRulesTenantId",
  "properties": {
    "description": "Azure Storage accounts should restrict the resource access rule for service-level network ACLs to service from the same AAD tenant. Enforce this for increased data exfiltration protection.",
    "displayName": "Resource Access Rules Tenants 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": {
      "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"
          },
          {
            "count": {
              "field": "Microsoft.Storage/storageAccounts/networkAcls.resourceAccessRules[*]"
            },
            "greater": 0
          },
          {
            "field": "Microsoft.Storage/storageAccounts/networkAcls.resourceAccessRules[*].tenantId",
            "notEquals": "[subscription().tenantId]"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-Storage-ResourceAccessRulesTenantId.bylaw.ps1 · 34 lines
# Converted from Deny-Storage-ResourceAccessRulesTenantId.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-Storage-ResourceAccessRulesTenantId' {

    Properties @{
        DisplayName = 'Resource Access Rules Tenants should be restricted for Storage Accounts'
        Description = 'Azure Storage accounts should restrict the resource access rule for service-level network ACLs to service from the same AAD tenant. 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 Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Storage/storageAccounts' {

        When {
            Count 'networkAcls.resourceAccessRules[*]' | Must -BeGreaterThan 0
        }

        Require 'networkAcls.resourceAccessRules and tenantId are as required' {
            Count 'networkAcls.resourceAccessRules[*]' -Where {
                Field tenantId | Must -Be (Arm '[subscription().tenantId]')
            } | Must -Not -Be 0
        }
    }

    Effect (Param Effect)
}

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