KMS key policy permissions need review

Limit KMS use and administration permissions while preserving a path to manage the key policy.

Description

This AWS::KMS::Key is an RSA signing and verification key. Review its key policy, IAM policies and KMS grants to see who can sign or administer it. Resource: "*" in the key policy refers to this key.

Potential impact

Unnecessary signing rights can allow unauthorized signatures. Excessive administration rights can interrupt services that depend on the key.

Remediation

Grant the signing role only the operations it needs. Keep a separate administrator able to call kms:PutKeyPolicy and keep the lockout safety check enabled. Verify that required operations work and unwanted requests are denied.

Examples

Set SigningRoleArn to the actual signing role ARN. Owner-account delegation allows that account to grant the deployment and administration identities their required IAM permissions.

Before

yaml
Resources:
  RSASigningKey:
    Type: AWS::KMS::Key
    Properties:
      Description: RSA-3072 asymmetric CMK for signing and verification
      KeySpec: RSA_3072
      KeyUsage: SIGN_VERIFY
      KeyPolicy:
        Version: "2012-10-17"
        Id: key-default-1
        Statement:
          - Sid: Enable IAM User Permissions
            Effect: Allow
            Principal:
              AWS: "*"
            Action: kms:*
            Resource: "*"

The first policy grants kms:* to a wildcard principal.

After

yaml
Parameters:
  SigningRoleArn:
    Type: String
Resources:
  RSASigningKey:
    Type: AWS::KMS::Key
    Properties:
      Description: RSA-3072 asymmetric CMK for signing and verification
      KeySpec: RSA_3072
      KeyUsage: SIGN_VERIFY
      KeyPolicy:
        Version: "2012-10-17"
        Id: key-default-1
        Statement:
          - Sid: EnableIAMUserPermissions
            Effect: Allow
            Principal:
              AWS: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:root'
            Action: kms:*
            Resource: "*"
          - Sid: Allow use of the key
            Effect: Allow
            Principal:
              AWS: !Ref SigningRoleArn
            Action:
              - kms:Sign
              - kms:Verify
              - kms:DescribeKey
            Resource: "*"

The second retains account delegation and grants the named role kms:Sign, kms:Verify and kms:DescribeKey.

References