For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-sqs-policy-with-public-access.md.
A documentation index is available at /llms.txt.
Allowing sensitive SQS management actions to wildcard principals lets any actor modify, delete, or change permissions on queues. This can enable resource takeover, data loss, or privilege escalation.
This rule inspects AWS::SQS::QueuePolicy resources and flags PolicyDocument.Statement entries where Effect: "Allow" and Action contains any of SQS:AddPermission, SQS:CreateQueue, SQS:DeleteQueue, SQS:RemovePermission, SQS:TagQueue, or SQS:UnTagQueue, if the Principal includes a wildcard (for example, * or patterns like arn:aws:iam::*). Statements that include a restrictive Condition are excluded from this flag.
To remediate, specify explicit principals (account ARNs or role ARNs) or add tight conditions (for example, aws:SourceAccount) to limit who can perform these actions.
Secure configuration example with an explicit principal:
#this code is a correct code for which the query should not find any resultResources:SampleSQSPolicy:Type:AWS::SQS::QueuePolicyProperties:Queues:- "https://sqs:us-east-2.amazonaws.com/444455556666/queue2"PolicyDocument:Statement:-Action:- "SQS:SendMessage"- "SQS:ReceiveMessage"Effect:"Allow"Resource:"arn:aws:sqs:us-east-2:444455556666:queue2"Principal:AWS:- "111122223333"- "*"