Description
When an Azure Storage public endpoint is enabled, network_acls.default_action: Allow accepts connections from any network. With Deny, address rules and service exceptions determine who can still connect. The account's public_network_access setting takes precedence over the firewall default.
Potential impact
Broad network access can let someone use leaked credentials or excessive permissions from outside the intended network. Whether they can read or write data depends on separate access settings, including anonymous access.
Remediation
- If you need the public endpoint, set
network_acls.default_actiontoDeny. Allow only the required public IPv4 addresses or virtual networks, and limit resource-instance rules andbypassexceptions. - Use the public source address Azure sees for each client. IP rules do not apply to requests from the same Azure region. Use virtual network rules there when needed.
- For private access only, configure private endpoints and DNS for the storage services in use, then set
public_network_access: Disabled. Check which service and resource-instance exceptions remain. Test allowed and blocked connections and review data permissions after the change.
Examples
The account name changes from clh0003 to clh0002 in these examples. To update an existing account, use its name in both tasks. Supply a real resource group and authentication settings, and choose an available name for a new account.
Before
- name: configure firewall and more virtual networks
azure_rm_storageaccount:
resource_group: myResourceGroup
name: clh0003
type: Standard_RAGRS
network_acls:
bypass: AzureServices,Metrics
default_action: Allow
After
- name: configure firewall and virtual networks
azure_rm_storageaccount:
resource_group: myResourceGroup
name: clh0002
type: Standard_RAGRS
network_acls:
bypass: AzureServices,Metrics
default_action: Deny
ip_rules:
- value: 1.2.3.4
action: Allow
The second task changes the default from Allow to Deny. Replace 1.2.3.4 with the approved client’s public address. The exceptions in bypass: AzureServices,Metrics still apply.
References
- CWE-284
- Ansible azure.azcollection.azure_rm_storageaccount documentation
- Ansible azure.azcollection 3.21.0 storage-account module implementation
- Azure Storage firewall and data access requirements
- Public access precedence, exceptions and IP-rule limitations
- Applying default network restrictions
- Storage private endpoints