Bylaw

Gallery › Storage › Azure Community Policy

Storage accounts should prevent allowed copy scope outside AAD tenant

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Audit restriction of copy operations for your storage account. By default, users can copy from source storage account in one Azure AD tenant and a destination account in a different tenant. It is a security concern because customer's data can be replicated to a storage account that is owned by the customer. By setting allowedCopyScope to AAD, copy operations can be done only if both source and destination accounts are in the same Azure AD tenant.

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

Azure Policy JSONazurepolicy.json · 48 lines
{
  "name": "63dd3af3-11bb-4328-92d2-85ec87cbf923",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Storage accounts should prevent allowed copy scope outside AAD tenant",
    "description": "Audit restriction of copy operations for your storage account. By default, users can copy from source storage account in one Azure AD tenant and a destination account in a different tenant. It is a security concern because customer's data can be replicated to a storage account that is owned by the customer. By setting allowedCopyScope to AAD, copy operations can be done only if both source and destination accounts are in the same Azure AD tenant.",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/allowedCopyScope",
            "notIn": [
              "AAD",
              "PrivateLink"
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw63dd3af3-11bb-4328-92d2-85ec87cbf923.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '63dd3af3-11bb-4328-92d2-85ec87cbf923' {

    Properties @{
        DisplayName = 'Storage accounts should prevent allowed copy scope outside AAD tenant'
        Description = 'Audit restriction of copy operations for your storage account. By default, users can copy from source storage account in one Azure AD tenant and a destination account in a different tenant. It is a security concern because customer''s data can be replicated to a storage account that is owned by the customer. By setting allowedCopyScope to AAD, copy operations can be done only if both source and destination accounts are in the same Azure AD tenant.'
        Version     = '1.0.0'
        Category    = 'Storage'
        Mode        = 'All'
    }

    Parameter Effect @{
        AllowedValues = @('Deny', 'Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Deny, Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'allowedCopyScope is one of 2 values' {
            Field allowedCopyScope | Must -BeIn @('AAD', 'PrivateLink')
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Storage/storage-accounts-should-prevent-allowed-copy-scope-outside-aad-tenant/azurepolicy.json in Azure/Community-Policy, under the MIT licence.