From cf4bc65570babb8734a4fff7e047ed859b106a96 Mon Sep 17 00:00:00 2001 From: Sebastien Tardif Date: Tue, 9 Jun 2026 19:49:07 -0700 Subject: [PATCH] fix: prevent index-out-of-range panic in s3proxy GetBucketOwnershipControls Add nil and length checks before accessing resp.OwnershipControls.Rules[0]. If the upstream S3 backend returns a response with nil OwnershipControls or empty Rules, the server panics with an index-out-of-range error. Return OwnershipControlsNotFoundError instead, matching the behavior of the posix and azure backends. This bug was introduced in commit 7545e623 (2024-06-28) when bucket ownership controls were first implemented for the s3proxy backend. Signed-off-by: Sebastien Tardif --- backend/s3proxy/s3.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/s3proxy/s3.go b/backend/s3proxy/s3.go index 715ad959..85a7b84e 100644 --- a/backend/s3proxy/s3.go +++ b/backend/s3proxy/s3.go @@ -258,6 +258,9 @@ func (s *S3Proxy) GetBucketOwnershipControls(ctx context.Context, bucket string) if err != nil { return ownship, handleError(err) } + if resp.OwnershipControls == nil || len(resp.OwnershipControls.Rules) == 0 { + return ownship, s3err.GetBucketErr(s3err.ErrOwnershipControlsNotFound, bucket) + } return resp.OwnershipControls.Rules[0].ObjectOwnership, nil } func (s *S3Proxy) DeleteBucketOwnershipControls(ctx context.Context, bucket string) error {