Azure blob container allows anonymous reads

Anonymous read access to an Azure blob container can expose private files. Review container and account settings and limit reads to the clients that need them.

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

  1. Identify which clients and files need public access. Keep private data separate, using a dedicated account for public distribution if needed.
  2. To create a private container with azure.azcollection 3.21.0, omit public_access. The module does not accept private. To make an existing container private, change its access level in Azure and verify the result.
  3. If none of the account’s blobs need anonymous reads, set AllowBlobPublicAccess to false. Review any static website served from $web separately because this setting does not cover its endpoint.
  4. 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

yaml
- 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

yaml
- 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