This check looks for overly permissive Action statements and wildcards "Principal": "*" in AWS SQS queue policies, which may grant broad permissions to any user. If left unaddressed, this misconfiguration can allow unauthorized parties to perform any action on the queue, including viewing, deleting, or sending messages, which poses risks such as data leakage or denial of service. To reduce the attack surface, always scope the Principal attribute in policy documents to trusted AWS identities instead of using "*" or {"AWS": "*"}.
The following is an example of an insecure configuration:
# Plan-JSON counterpart of negative.tf for the module-input path: the
# policy's principal is a specific account root ARN, not a wildcard. See
# negative2.json and the second module-scoped rule body in query.rego.
module"sqs_queue_policy"{source="terraform-aws-modules/sqs/aws"version="~> 2.0"name="example"policy=<<POLICY{
"Version": "2012-10-17",
"Id": "sqspolicy",
"Statement": [
{
"Sid": "First",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:root"
},
"Action": "sqs:SendMessage",
"Resource": "arn:aws:sqs:eu-west-1:135367859851:queue1",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "arn:aws:events:eu-west-1:135367859851:rule/RunDailyTask"
}
}
}
]
}
POLICY # ... other configuration ...
}