Skip to content

Validate the deployment bucket region when HeadBucket is forbidden - #471

Merged
GrahamCampbell merged 1 commit into
4.xfrom
fix-forbidden-head-bucket
Oct 24, 2026
Merged

GrahamCampbell merged 1 commit into
4.xfrom
fix-forbidden-head-bucket

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Contributor

Since #113 the custom deployment bucket is checked with HeadBucket, which S3 authorizes as s3:ListBucket without an s3:prefix. A deploy role whose ListBucket permission is limited to its own prefix of a shared bucket therefore gets a 403 for a bucket it can deploy to, and the deploy fails with a misleading "Could not locate deployment bucket" error, as @danielnc diagnosed in #463.

S3 returns the x-amz-bucket-region header on a forbidden HeadBucket response, and the catch block already reads it, but then throws the not-found error even when the region matches. This change only throws not-found when the region is unknown, and leaves the existing comparison after the try to reject a bucket in another region. A missing bucket still fails with the not-found error, since a 404 carries no region header. The 3.x branch has the same problem and can be fixed the same way through the region the v2 SDK sets on the error.

This supersedes #463, which added a GetBucketLocation fallback that needs a second request and the s3:GetBucketLocation permission.

@GrahamCampbell
GrahamCampbell force-pushed the fix-forbidden-head-bucket branch from 56dbfa2 to 2221378 Compare October 24, 2026 21:50
@GrahamCampbell
GrahamCampbell merged commit 686bb64 into 4.x Oct 24, 2026
8 checks passed
@GrahamCampbell
GrahamCampbell deleted the fix-forbidden-head-bucket branch October 24, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant