AWS - KMS Privesc
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
For more info about KMS check:
AWS - KMS Enumkms:ListKeys
,kms:PutKeyPolicy
, (kms:ListKeyPolicies
, kms:GetKeyPolicy
)With these permissions it's possible to modify the access permissions to the key so it can be used by other accounts or even anyone:
policy.json:
kms:CreateGrant
It allows a principal to use a KMS key:
A grant can only allow certain types of operations: https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations
Note that it might take a couple of minutes for KMS to allow the user to use the key after the grant has been generated. Once that time has passed, the principal can use the KMS key without needing to specify anything. However, if it's needed to use the grant right away use a grant token (check the following code). For more info read this.
Note that it's possible to list grant of keys with:
kms:CreateKey
, kms:ReplicateKey
With these permissions it's possible to replicate a multi-region enabled KMS key in a different region with a different policy.
So, an attacker could abuse this to obtain privesc his access to the key and use it
kms:Decrypt
This permission allows to use a key to decrypt some information. For more information check:
AWS - KMS Post ExploitationLearn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)