Wildcard principals in S3 object-read policies

Allowing S3 Get actions for all principals can expose object data or configuration information, depending on the action, resource and effective access controls.

Description

s3:GetObject reads an object’s contents. Granting it to a wildcard principal can allow anonymous requests to read files.

Potential impact

Other Get actions can return bucket or object settings. What is exposed depends on the action and resource.

Remediation

Limit reads to the required object ARNs and trusted role. Check conditions, explicit denies and Block Public Access, then verify that only the intended reader can retrieve a private object.

Examples

The second example grants S3Reader read access to objects in mys3bucket. Substitute the actual bucket name and role ARN.

Before

yaml
- name: Bucket
  amazon.aws.s3_bucket:
    name: mys3bucket
    state: present
    policy:
      Version: "2012-10-17"
      Statement:
        - Effect: Allow
          Action: s3:GetObject
          Resource: "arn:aws:s3:::mys3bucket/*"
          Principal: "*"

After

yaml
- name: Bucket
  amazon.aws.s3_bucket:
    name: mys3bucket
    state: present
    policy:
      Version: "2012-10-17"
      Statement:
        - Effect: Allow
          Action: s3:GetObject
          Resource: "arn:aws:s3:::mys3bucket/*"
          Principal:
            AWS: "arn:aws:iam::123456789012:role/S3Reader"

References