Skip to content

Verify S3 bucket ownership before using the derived bucket - #37

Merged
aebothra-amz merged 3 commits into
aws:mainfrom
mkovelam:fix/s3-expected-bucket-owner
Nov 12, 2026
Merged

aebothra-amz merged 3 commits into
aws:mainfrom
mkovelam:fix/s3-expected-bucket-owner

Conversation

@mkovelam

Copy link
Copy Markdown
Collaborator

The default bucket name codeguru-reviewer-cli-{account}-{region} is predictable, so another account could pre-create it. Uploads already pin ExpectedBucketOwner, but HeadBucket did not, so the CLI would adopt a foreign bucket and associate the repository with it.

  • Pin ExpectedBucketOwner to the caller's account on HeadBucket and fail with BUCKET_ACCESS_DENIED on a 403 instead of using the bucket.
  • Pin ExpectedBucketOwner on the DeleteObject cleanup calls.
  • Add tests for the owner pin and the fail-closed path.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The default bucket name codeguru-reviewer-cli-{account}-{region} is
predictable, so another account could pre-create it. Uploads already
pin ExpectedBucketOwner, but HeadBucket did not, so the CLI would adopt
a foreign bucket and associate the repository with it.

- Pin ExpectedBucketOwner to the caller's account on HeadBucket and
  fail with BUCKET_ACCESS_DENIED on a 403 instead of using the bucket.
- Pin ExpectedBucketOwner on the DeleteObject cleanup calls.
- Add tests for the owner pin and the fail-closed path.

@aebothra-amz aebothra-amz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. headBucket and deleteObject now pin expectedBucketOwner, and a 403 fails closed before createBucket/associateRepository, which matches CloudSec P560887515.

@aebothra-amz
aebothra-amz merged commit f8be44d into aws:main Nov 12, 2026
6 checks passed
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.

3 participants