Azure Storage Account public-access settings need review

Check network reachability and anonymous Blob access separately.

Description

Decide which networks can reach the account and which blobs, if any, may be read anonymously. Anonymous reads require access through the network and permission at both account and container level.

Potential impact

A public container can expose data. A broad network rule also increases the places from which a leaked credential can be used.

Remediation

Make containers private where public reads are unnecessary. Disable anonymous access on the account if none of its containers needs it. For a public endpoint, use Deny by default and allow the required public IPs or subnets. For private-only access, verify that clients resolve and connect to the private endpoint before disabling public access. Existing trusted-service exceptions and resource-instance rules still apply, so remove any you no longer need. Verify that authorized clients can read and unintended anonymous requests fail.

Examples

The AzureRM 2.99.0 examples narrow 0.0.0.0/0 to one address and add allow_blob_public_access = false. Use an approved public address and the anonymous-access attribute supported by your provider version.

Before

hcl
resource "azurerm_storage_account" "app_storage" {
  name                     = "storageaccountname"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"

  network_rules {
    default_action = "Deny"
    ip_rules       = ["0.0.0.0/0"]
  }
}

After

hcl
resource "azurerm_storage_account" "app_storage" {
  name                     = "storageaccountname"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
  allow_blob_public_access = false

  network_rules {
    default_action = "Deny"
    ip_rules       = ["100.0.0.1"]
  }
}

References