Skip to content

[aws-kms] Limit default KMS policy (allowAccountToAdmin) to ROOT only #8977

@OlivierPT

Description

@OlivierPT

[Not a Contribution]

Default KMS policy created with allowAccountToAdmin() function (trustAccountIdentities=false) is too large and allow all IAM entities to manage the Key.
At least, there should be an additionnal option to restrict it to ROOT only. Or restriction to ROOT only should be the default option.

Proposed solution is to add a condition in the statement as below:

{
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::AccountID:root"
            },
            "Action": [
                "kms:Create*",
                "kms:Describe*",
                "kms:Enable*",
                "kms:List*",
                "kms:Put*",
                "kms:Update*",
                "kms:Revoke*",
                "kms:Disable*",
                "kms:Get*",
                "kms:Delete*",
                "kms:ScheduleKeyDeletion",
                "kms:CancelKeyDeletion",
                "kms:GenerateDataKey",
                "kms:TagResource",
                "kms:UntagResource"
            ],
            "Resource": "*",
            "Condition": {
                "ArnLike": {
                    "aws:PrincipalArn": "arn:aws:iam::AccountID:root"
                }
            }
        }

Reproduction Steps

Create a KMS key with default policy:

new kms.Key(this, 'KmsKey', {
      alias: 'kms-key',
      enableKeyRotation: true
    });

Error Log

No error produced by CDK

Environment

  • CDK CLI Version: 1.49.1
  • Module Version: aws-kms
  • Node.js Version: v12.13.1
  • OS: All
  • Language: all

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-kmsRelated to AWS Key Managementeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.p2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions