select_object_content gives access denied when SSECustomerAlgorithm is enabled #3268
-
Hi, i am having couple of objcts in s3 out of which some of them are encrypted using customerKey and some are not. When i use select_object_content api on normal files which are not encrypted, it works like a charm, however when i use the api on encrypted file, i get access denied. I was under the impression that my ekey would have been wrong, Not sure if this there are some additional paramaters that i am missing here. but according to the documentation i am using all the required paramaters. tested it on boto3 - 1.9.18 and 1.21.21 code is as follows-
running above code gives me error as follows-
when the api works fine on files that are not encrypted, it should adhere to same behaviour on encrypted files when passed SSECustomerAlgorithm and SSECustomerKey paramaters. Let me know if my understanding is wrong. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Hi @HassanAhamed24 here is the If you have the |
Beta Was this translation helpful? Give feedback.
-
Hi @HassanAhamed24, this appears to be an issue with handler registration specifically for SSE in S3. You can see here we have a customization that runs on certain operations such as PutObject to auto-encode your encryption key for you. The key MUST be a base64-encoded string as noted in the API docs for S3. The customization is a courtesy function to reduce complexity but doesn't appear to be applied consistently. We're going to need to do some testing, but we should be able to ship this in a future version of Boto3 to add this to the subset of APIs auto-encoding the SSE key. |
Beta Was this translation helpful? Give feedback.
-
For anyone looking for the hack, please do as follows- `key_as_bytes = ekey.encode('utf-8') key_b64_encoded = base64.b64encode(key_as_bytes).decode('utf-8')` now pass the key_b64_encoded in SSECustomerKey. This should work for now. |
Beta Was this translation helpful? Give feedback.
Hi @HassanAhamed24, this appears to be an issue with handler registration specifically for SSE in S3. You can see here we have a customization that runs on certain operations such as PutObject to auto-encode your encryption key for you. The key MUST be a base64-encoded string as noted in the API docs for S3. The customization is a courtesy function to reduce complexity but doesn't appear to be applied consistently.
We're going to need to do some testing, but we should be able to ship this in a future version of Boto3 to add this to the subset of APIs auto-encoding the SSE key.