Remediation
Restrict the Queue Policyβ
Review the queue policy and remove any statements that grant access to * or to overly broad external principals. Keep access limited to explicitly required AWS accounts, IAM roles, or AWS service principals. When the queue must accept messages from AWS services or trusted external producers or consumers, add restrictive conditions such as aws:SourceArn and aws:SourceAccount.
From Command Lineβ
-
Retrieve the current queue policy:
aws sqs get-queue-attributes \
--queue-url {{queue-url}} \
--attribute-names Policy \
--query 'Attributes.Policy' \
--output text > policy.json -
Update
policy.jsonand remove or narrow any statements that allow public access.Ensure that:
- the
Principalis a specific AWS account, IAM role, or service principal; - the
Actionlist contains only the minimum requiredsqs:permissions; - service integrations are constrained with conditions such as
aws:SourceArnandaws:SourceAccount.
- the
-
Apply the updated policy to the queue.
Replace
{{policy-json}}with the updated policy serialized as a compact JSON string:aws sqs set-queue-attributes \
--queue-url {{queue-url}} \
--attributes Policy='{{policy-json}}' -
Re-run the policy evaluation to confirm the queue is no longer publicly accessible.