More Info:
There should not be any publicly accessible SQS queues available in your AWS account in order to protect against unauthorized users. Unauthorized access can lead to unauthorized actions such as intercepting, deleting and sending queue messages.Risk Level
HighAddress
Reliability, SecurityCompliance Standards
PCIDSS, GDPR, APRA, MASTriage and Remediation
Remediation
Using Console
Using Console
Sure, here are the step-by-step instructions to remediate this misconfiguration:
- Log in to the AWS Management Console and open the Amazon SQS console at https://console.aws.amazon.com/sqs/.
- In the navigation pane, choose ‘Queues’.
- In the ‘Queue URLs’ list, choose the name of the queue that you want to change the permissions for.
- Choose the ‘Permissions’ tab.
- Here you can see all the permissions currently granted. If ‘Everyone’ (which means public access) is listed, you need to remove this permission.
- Select the ‘Everyone’ permission and then click on ‘Remove permissions’.
- In the ‘Remove permissions’ dialog box, confirm the removal by clicking ‘Remove’.
- The changes take effect immediately.
- Repeat these steps for all queues that are publicly accessible.
Using CLI
Using CLI
Sure, here are the step-by-step instructions to remediate this issue using AWS CLI:This command will list all the SQS queues in your AWS account.Replace Replace
- Identify the publicly exposed SQS queue: First, you need to identify the SQS queues that are publicly exposed. You can do this by using the following command:
- Get the SQS queue’s policy: Once you have identified the SQS queue, you need to check its policy. You can do this by using the following command:
<Your-Queue-URL>
with your actual SQS queue URL. This command will display the policy of the SQS queue.- Identify the issue in the policy: Check if the policy has “Principal”: ”*” with “Effect”: “Allow”. This means the SQS queue is publicly accessible.
- Modify the policy: You need to remove the public access from the policy. You can do this by removing the statement with “Principal”: ”*” and “Effect”: “Allow”. Make sure you do not remove other statements that are needed for your application to function properly.
- Set the new policy: Once you have modified the policy, you need to set it back to the SQS queue. You can do this by using the following command:
<Your-Queue-URL>
with your actual SQS queue URL, and <Your-New-Policy>
with your new policy.- Verify the changes: Finally, verify if the changes have been applied properly. You can do this by getting the SQS queue’s policy again and checking if the public access has been removed.
Using Python
Using Python
To remediate the misconfiguration of SQS Queues being publicly exposed, you can use Boto3, the Amazon Web Services (AWS) SDK for Python. Here are the step-by-step instructions:
-
First, make sure you have installed the AWS SDK for Python (Boto3). If not, install it using pip:
-
Import the necessary libraries:
-
Create a session using your AWS credentials. Replace ‘your_access_key’, ‘your_secret_key’, and ‘your_region’ with your AWS access key, secret key, and the region your SQS queue is in, respectively:
-
Create a client for SQS:
-
Get the URL of the SQS queue. Replace ‘your_queue_name’ with the name of your queue:
-
Get the current policy of the SQS queue:
-
Check if the policy allows everyone to send messages to the queue. If it does, modify the policy to only allow specific AWS accounts or IAM users to send messages to the queue. Here’s an example of a policy that only allows a specific AWS account to send messages:
-
Set the new policy:
-
Finally, handle any exceptions that may occur during the process: