KMS key policy contains wildcard (*) principal

Description

A wildcard principal serves as a placeholder that grants access to all users or accounts, which can increase the risk of exposing your KMS keys to unauthorized access.

To mitigate this risk and enhance security, it is recommended to remove wildcard principals from your KMS key policies. By explicitly defining and restricting access to specific IAM users or accounts, you can enforce tighter access control, reducing the potential attack surface and minimizing the likelihood of unauthorized access to your cryptographic keys.

Fix - Buildtime

CloudFormation

  • Resource: AWS::KMS::Key
  • Argument: Properties.Statement.Principal
Type: AWS::KMS::Key
    Properties:
        ...
        Statement:
            - ...
        Principal:
-           "*"
-           AWS: "*"
+                   AWS: !Sub 'arn:aws:iam::${AWS::AccountId}:root'
ReLambda