Legacy aws_s3 task specifies a public ACL

Public S3 ACLs can let unintended users list objects, read their contents, or upload objects. Restrict public access according to the permissions that apply.

Description

An effective public-read bucket ACL lets anyone list objects, including anonymous callers. public-read-write also permits new uploads. Reading an object’s contents requires separate permission.

Potential impact

Public listings can disclose names, and unwanted uploads can increase storage and request costs. A user who owns neither the bucket nor an existing object cannot overwrite or delete that object with the bucket’s WRITE grant alone.

Remediation

Use amazon.aws.s3_bucket to manage buckets. Check Object Ownership, Block Public Access, bucket policies and object ACLs. Move necessary grants into policies before disabling ACLs. If ACLs must remain, limit grants to the required accounts. For intentionally public data allow only the required reads, then verify both expected and denied access.

Examples

These tasks use the legacy amazon.aws.aws_s3, now redirected to amazon.aws.s3_object. Collection 6.0.0 removed bucket creation and deletion from that module. Use the examples to inspect old configurations.

Before

yaml
- name: Create an empty bucket
  amazon.aws.aws_s3:
    bucket: mybucket
    mode: create
    permission: public-read

- name: Create an empty bucket
  amazon.aws.aws_s3:
    bucket: mybucket-logs
    mode: create
    permission: public-read-write

After

yaml
- name: Create an empty bucket
  amazon.aws.aws_s3:
    bucket: mybucket
    mode: create
    permission: private

Explanation:

  • First example: The ACLs on mybucket and mybucket-logs request public listing. The second also requests upload access. Block Public Access can reject or ignore those grants, and BucketOwnerEnforced disables ACLs.
  • Second example: In amazon.aws 1.5.0, rerunning mode: create leaves the ACL on an existing mybucket unchanged. Update that bucket’s ACL explicitly and check mybucket-logs separately. This task does not touch it.

References