Skip to content

[3.x] Validate the deployment bucket region when HeadBucket is forbidden - #472

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

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

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Contributor

This is the 3.x port of #471. Since #113 the custom deployment bucket is checked with HeadBucket, which S3 authorizes as s3:ListBucket without an s3:prefix, so a deploy role whose ListBucket permission is limited to its own prefix of a shared bucket 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 v2 SDK exposes it as the region property of the error. This change uses that region when the request fails, only throws the not-found error when no region is known, and leaves the existing comparison to reject a bucket in another region. A missing bucket still fails with the not-found error, since a 404 carries no region header.

@GrahamCampbell
GrahamCampbell force-pushed the fix-forbidden-head-bucket-3x branch from 2c44536 to f31115b Compare October 24, 2026 22:45
@GrahamCampbell
GrahamCampbell merged commit eb52339 into 3.x Oct 24, 2026
8 checks passed
@GrahamCampbell
GrahamCampbell deleted the fix-forbidden-head-bucket-3x 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