Description
Name the required callers in Principal and their operations in Action. s3:* matches all S3 actions, while s3:Get* matches names beginning with Get.
Potential impact
A grant that includes anonymous callers can expose object reads, writes or deletions, depending on its resources.
Remediation
Even for intentional public reads, grant only the needed actions on the intended objects. Check conditions, explicit denies, Block Public Access and other grants, then test both intended and denied requests.
Examples
The first example’s Resource identifies a different bucket from the task’s mys3bucket. An ARN ending in /* targets objects. Bucket-level operations require the bucket ARN.
Before
- name: Create s3 bucket
amazon.aws.s3_bucket:
name: mys3bucket
policy:
Id: "id113"
Version: "2012-10-17"
Statement:
- Action: "s3:*"
Effect: "Allow"
Resource: "arn:aws:s3:::S3B_181355/*"
Principal: "*"
After
- name: Create s3 bucket
amazon.aws.s3_bucket:
name: mys3bucket
policy:
Id: "id113"
Version: "2012-10-17"
Statement:
- Action:
- "s3:GetObject"
Effect: "Allow"
Resource: "arn:aws:s3:::mys3bucket/*"
Principal:
AWS: "arn:aws:iam::123456789012:role/read-only-bucket-role"
The second statement grants only s3:GetObject to read-only-bucket-role on the target bucket’s objects. Substitute the actual role and object ARNs.