Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copyObject throws Access Denied if source key is not present #6523

Open
3 of 4 tasks
marcindyelp opened this issue Sep 26, 2024 · 1 comment
Open
3 of 4 tasks

copyObject throws Access Denied if source key is not present #6523

marcindyelp opened this issue Sep 26, 2024 · 1 comment
Assignees
Labels
bug This issue is a bug. p3 This is a minor priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@marcindyelp
Copy link

Checkboxes for prior research

Describe the bug

To perform copyObject according to aws docs, you need s3:GetObject and s3:PutObject permissions. That works fine with only those permissions.
Problem: If source key (file) does not exist in the bucket, API throws misleading error:
AccessDenied: User: arn:aws:sts:#########r is not authorized to perform: s3:ListBucket on resource: "arn:aws:s3:::my_bucket because no identity-based policy allows the s3:ListBucket action
Obviously s3:ListBucket is not needed. Error thrown should be 'key not present, check source...' or anything like that.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected], CopyObjectCommand

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

node 18.19.0

Reproduction Steps

delete the source file

Observed Behavior

AccessDenied: User: arn:aws:sts:#########r is not authorized to perform: s3:ListBucket on resource: "arn:aws:s3:::my_bucket because no identity-based policy allows the s3:ListBucket action

Expected Behavior

Obviously s3:ListBucket is not needed. Error thrown should be 'key not present, check source...' or anything like that.

Possible Solution

change the error/response from API to user

Additional Information/Context

No response

@marcindyelp marcindyelp added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 26, 2024
@aBurmeseDev aBurmeseDev self-assigned this Sep 27, 2024
@aBurmeseDev
Copy link
Member

Hi @marcindyelp - thanks for reaching out.

This is something I need to confirm with S3 team but in one S3 docs, it's mentioned that you need s3:ListAllMyBuckets permission to perform CopyObject operation. See here: https://docs.aws.amazon.com/AmazonS3/latest/userguide/copy-object.html#CopyingObjectsExamples

When you initiate a CopyObject operation, S3 needs to verify the existence of the source object in the source bucket. To do this, it needs to list the contents of the source bucket, which requires the s3:ListBucket permission. If the source object doesn't exist, S3 still needs to perform this listing operation to determine that the object doesn't exist and it will return an error if the necessary permission (s3:ListBucket) is not granted.

Best,
John

@aBurmeseDev aBurmeseDev added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. service-api This issue is due to a problem in a service API, not the SDK implementation. p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p3 This is a minor priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants