Description
If account and network settings permit anonymous access, public_access: blob lets anyone read a blob by its URL. With public_access: container, they can also list the blobs in that container. Both levels grant read access only.
Potential impact
Anonymous readers can see private documents, logs or uploads. Listing also reveals filenames and how the data is organized. Applications that rely on anonymous reads need another way to authenticate before you disable access.
Remediation
- Identify which clients and files need public access. Keep private data separate, using a dedicated account for public distribution if needed.
- To create a private container with
azure.azcollection3.21.0, omitpublic_access. The module does not acceptprivate. To make an existing container private, change its access level in Azure and verify the result. - If none of the account’s blobs need anonymous reads, set
AllowBlobPublicAccesstofalse. Review any static website served from$webseparately because this setting does not cover its endpoint. - Grant authenticated clients only the read permissions they need. Check the scope and expiry of any SAS. Test from the relevant networks that anonymous reads fail and required clients can still read.
Examples
Anonymous read access
- name: Create container and upload a file
azure_rm_storageblob:
resource_group: myResourceGroup
storage_account_name: clh0002
container: foo
blob: graylog.png
src: ./files/graylog.png
public_access: blob
Private access for a new container
- name: Create container and upload a file
azure_rm_storageblob:
resource_group: myResourceGroup
storage_account_name: clh0002
container: foo
blob: graylog.png
src: ./files/graylog.png
content_type: application/image
Both tasks assume an existing storage account, permissions to run the task, and a local file. If they create foo, the first allows anonymous blob reads and the second leaves the container private. With module version 3.21.0, neither task changes an existing container’s access level. The content_type field describes the file and has no effect on permissions.
References
- CWE-284
- Ansible azure.azcollection.azure_rm_storageblob documentation
- Container creation and update implementation in azure.azcollection 3.21.0
- Azure anonymous reads and account settings
- Preventing anonymous access and assessing client impact
- Read and listing permissions at each container access level