Description
When an SQS queue policy uses Principal: "*", check Action, Resource, conditions and other policies to see which operations are allowed. Sending alone grants no read, delete or queue-administration access.
Potential impact
Unwanted messages can affect consumer processing. If reading or deletion is also allowed, messages may be disclosed or removed before processing. The impact depends on how the consumer validates messages.
Remediation
- Set
Principalto the required account, role or service,Actionto the needed operations andResourceto the queue ARN. Check other policies for conditions and denies. - Keep server-side encryption (SSE) enabled. Encrypted queues require HTTPS and Signature Version 4 and reject anonymous
SendMessageandReceiveMessage. Restrict authenticated senders and check the service’s required KMS permissions.
Examples
Set queue_arn to the ARN of my-queue in the target account and Region, and sns_topic_arn to the approved source topic. Create the SNS subscription separately.
Before
- name: example
community.aws.sqs_queue:
name: my-queue
region: ap-southeast-2
policy:
Version: "2012-10-17"
Statement:
Sid: First
Effect: Allow
Principal: "*"
Action: sqs:SendMessage
Resource: "{{ queue_arn }}"
The first statement grants sqs:SendMessage to wildcard principals.
After
- name: example
community.aws.sqs_queue:
name: my-queue
region: ap-southeast-2
policy:
Version: "2012-10-17"
Statement:
Sid: First
Effect: Allow
Principal:
Service: sns.amazonaws.com
Action: sqs:SendMessage
Resource: "{{ queue_arn }}"
Condition:
ArnEquals:
aws:SourceArn: "{{ sns_topic_arn }}"
The revised statement grants sending to sns.amazonaws.com only when aws:SourceArn matches the approved topic. For cross-Region delivery involving an opt-in Region, use the appropriate regional service principal. Test delivery from the approved topic and rejection from other sources.