Using Console
Using CLI
Using Python
aws kms list-keys
to get a list of all the KMS keys and then using the aws kms describe-key
command to get the key policy for each key.
"AWS"
field in the Principal
element of the policy. If the "AWS"
field is set to "*"
or does not include a specific account ID, then the key allows unknown cross-account access.
aws kms put-key-policy
command to update the key policy. You will need to specify the key ID, the policy name, and the new policy document that removes the "AWS"
field or replaces it with a specific account ID.
aws kms encrypt
command to encrypt a test message using the modified key. If the encryption is successful, then the key policy has been remediated.
123456789012
with your own account ID.