- Newest
- Most votes
- Most comments
aws_s3.query_export_to_s3
uses the AWS managed Key aws/s3
to encrypt the exported Data (rather than aws/rds
listed in the question). The policy for that Key is as follows:
{ "Version": "2012-10-17", "Id": "auto-s3-2", "Statement": [ { "Sid": "Allow access through S3 for all principals in the account that are authorized to use S3", "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": [ "kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:DescribeKey" ], "Resource": "*", "Condition": { "StringEquals": { "kms:CallerAccount": "123456789012", "kms:ViaService": "s3.eu-central-1.amazonaws.com" } } }, { "Sid": "Allow direct access to key metadata to the account", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:root" }, "Action": [ "kms:Describe*", "kms:Get*", "kms:List*" ], "Resource": "*" } ] }
According to this policy, any IAM principal of your account can use that key do Encrypt
, Decrypt
etc. via the S3 service (first policy statement), while direct usage is restricted to Metadata only operations (second policy statement). So if your IAM principal resides in the same account as the key and has access to the S3 objects via GetObject
, they should also be able to decrypt and download the exported data. Reasons I can think of that could prevent this are
- You try to access the objects from a principal in another Account (that has access to the data e.g. via a cross-account role or bucket policy) but cannot access the AWS managed key
aws/s3
to decrypt. - There is an explicit Deny for your IAM principal that prevents your IAM principal from accessing the key.
Notice that there is no need for explicit denies in that case, as an IAM principal has no means of directly using aws/s3
to Decrypt
without going through S3. There is also no possibility for any IAM principal (even root) to obtain this priviledges for that particular key, as
- the key policy of an AWS managed key such as
aws/s3
can not be altered and - the key policy of
aws/s3
does not allowCreateGrant
to delegate access to the key (even for the root user).
Relevant content
- Accepted Answerasked 3 years ago
- asked 2 months ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 7 months ago
I was able to debug this with CloudTrail. The log event there for the DECRYPT request was much more helpful than the error in S3 as it says
kms:Decrypt on resource: arn:aws:kms:eu-central-1:[account_id]:key/[key_id] with an explicit deny in an identity-based policy
. We have a policy which enforces that AWS API requests from user accounts must come from specific IPs. However, there was no exception added for internal calls coming from AWS services as described in https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_deny-ip.html Since S3 makes an internal request to KMS using the identity of the IAM principal that made the initial S3 Get request it was affected by the deny policy. Adding{"aws:ViaAWSService": "false"}
to the policy conditions solved the issue.I'm in a situation where I'm trying to access the exported data from a principal in another account as you described in your first point. Does this mean that it's not possible? Do you have any suggestions for workarounds?