#12783 Give ListBucket permission to CloudFront on fcos-builds bucket
Closed: Fixed by jlebon. Opened by jlebon.

Describe what you would like us to do:


AIUI, https://builds.coreos.fedoraproject.org/ is a CloudFront endpoint. That endpoint is backed by the fcos-builds S3 bucket. I'd like to have the CloudFront identity on the bucket have access to the ListBucket permission. Relevant link: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html

Background: this should make CloudFront return 404 instead of 403 when a client tries to GET a resource that doesn't exist in the bucket. This is technically information leak, but that bucket contains only public artifacts, and users themselves don't have an easy way to list the bucket. The reason for wanting a 404 instead of 403 is that we want to use that bucket to store container images' GPG signatures as understood by the podman/skopeo stack, and those work by fetching an undefined number of signatures from the server, starting from signature-1, then signature-2, etc... until it gets 404. A 403 is considered a hard error.

When do you need this to be done by? (YYYY/MM/DD)


Ideally soon. This is part of the switch to have FCOS be built using podman build (https://fedoraproject.org/wiki/Changes/BuildFCOSUsingContainerfile). We realized a bit late that we had more work to do on the signing side than expected.


Metadata Update from @zlopez:
- Issue priority set to: Waiting on Assignee (was: Needs Review)
- Issue tagged with: aws, medium-gain, medium-trouble, ops

OK, discussing this more, we think it's fine to just give ListBucket to everyone. The bucket is already public (i.e. GetObject is already effectively open), and we don't see a concern with allowing listing as well.

So the policy should be:

{
   "Statement": [
      {
         "Effect": "Allow",
         "Principal": "*",
         "Action": [
           "s3:GetObject",
           "s3:ListBucket"
         ],
         "Resource": [
            "arn:aws:s3:::fcos-builds",
            "arn:aws:s3:::fcos-builds/*"
         ]
      }
   ]
}

And the exact command is:

aws s3api put-bucket-policy --bucket fcos-builds --policy file://bucket-policy.json

sad trombone: An error occurred (AccessDenied) when calling the PutBucketPolicy operation: User: arn:aws:iam:::user/kevin is not authorized to perform: s3:PutBucketPolicy on resource: "arn:aws:s3:::fcos-builds" because public policies are blocked by the BlockPublicPolicy block public access setting.

these two are checked / on:

Block public access to buckets and objects granted through new public bucket or access point policies
S3 will block new bucket and access point policies that grant public access to buckets and objects. This setting doesn't change any existing policies that allow public access to S3 resources.

Block public and cross-account access to buckets and objects through any public bucket or access point policies
S3 will ignore public and cross-account access for buckets or access points with policies that grant public access to buckets and objects.
shall I uncheck them both and retry the policy?

Shall I uncheck those?

Metadata Update from @kevin:
- Issue assigned to kevin

I unchecked them, it allowed me to set the policy then.

Can you check that it's working as expected now?

Yes it does, thanks all!

$ curl -LI https://builds.coreos.fedoraproject.org/enoent | head -n1
HTTP/2 404

Metadata Update from @jlebon:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

Metadata