Embedding plaintext credentials in CloudFormation template metadata exposes secrets to anyone with access to the template or its repository and can lead to credential theft and unauthorized access to resources.
This rule flags AWS::EC2::Instance resources that include an AWS::CloudFormation::Authentication metadata block containing inline credentials:
For type: "S3", it flags accessKeyId or secretKey
For type: "basic", it flags password
Do not include credential keys in metadata. Instead, grant S3 access via an instance IAM role (IamInstanceProfile) and store sensitive values in AWS Secrets Manager or AWS Systems Manager Parameter Store, retrieving them at runtime.
Secure alternative without embedding credentials:
MyInstance:Type:AWS::EC2::InstanceProperties:IamInstanceProfile:my-ec2-instance-profile# no AWS::CloudFormation::Authentication metadata containing accessKeyId/secretKey/password