Description
Cloud Storage’s allUsers includes anonymous clients. allAuthenticatedUsers includes accounts outside your organization. When you create an ACL-enabled bucket without specifying its ACL, the bucket gets projectPrivate. IAM can grant additional access.
Potential impact
A bucket READER can list objects. Reading file contents requires object access. Bucket write access can allow object creation, replacement or deletion. Uploads without an explicit ACL inherit the bucket’s current default object ACL. Changing that default leaves existing objects’ ACLs intact.
Remediation
Inspect IAM, bucket and object ACLs, and default object ACLs. Remove unnecessary public grants and authorize only the required users, groups and service accounts. With uniform bucket-level access, manage permissions in IAM because ACLs are disabled. Check any services that depend on public access before applying public access prevention, then test access to an existing object and a new upload.
ACL configuration examples
In google.cloud 1.14.0 the ACL fields take lists of dictionaries, and each ACL’s bucket takes a dictionary reference. Correct the mappings, string references, mismatched bucket names and missing role fields before use. Replace /tmp/auth.pem with the path to your service account JSON credential file.
Public principals
- name: create a bucket1
google.cloud.gcp_storage_bucket:
name: ansible-storage-module1
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
default_object_acl:
bucket: bucketName1
entity: allUsers
role: READER
- name: create a bucket2
google.cloud.gcp_storage_bucket:
name: ansible-storage-module2
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
acl:
bucket: bucketName2
entity: allAuthenticatedUsers
Group principal
- name: create a bucket
google.cloud.gcp_storage_bucket:
name: ansible-storage-module
project: test_project
auth_kind: serviceaccount
service_account_file: /tmp/auth.pem
state: present
acl:
bucket: bucketName
entity: group-example@googlegroups.com
Explanation:
- Public principals: The first task specifies
READERforallUserson new objects. The second namesallAuthenticatedUserson the bucket but leaves its role unspecified. - Group principal: The final task names
group-example@googlegroups.comwithout a role. Check its membership and assign only the role it needs. Other ACL and IAM grants still apply.