- Home
- »
- AWS Documentation
- »
- IAM
- »
- Ensure SQS policy documents do not allow * (asterisk) as a statement’s action
SQS policy documents allow * (asterisk) as a statement's action
Description
The Action
element in an IAM policy specifies the individual actions that are either allowed or denied. Each policy statement must include either an Action
or NotAction
element. AWS services have predefined actions that represent specific operations that can be performed within the service. These actions are referenced by their service namespace (e.g., iam
, ec2
, sqs
, sns
, s3
), followed by the exact action name. The action name must correspond to a valid, supported action within the service.
It is strongly recommended to avoid using "*"
(wildcard) in the Action
element, as it grants unrestricted access to all actions within the specified service. This broad level of access could inadvertently expose resources to unauthorized or unregulated use. Instead, you should define policies with granular and precise actions that specify exactly what operations are permissible, ensuring access is limited to the minimum necessary for the policy holder to perform their required tasks. This approach promotes principle of least privilege and reduces the risk of accidental privilege escalation.
Fix - Runtime
AWS Console
- Log in to the AWS Management Console at https://console.aws.amazon.com/.
- Open the Amazon SQS console.
- Click on the queue you want to modify.
- Click on the “Access Policy” tab within the queue’s details page.
- Click “edit” next to the displayed “Access Policy”.
- Identify any Action statements permitting actions access to all resources (“*”).
- Narrow the scope to necessary actions, for example sqs:SendMessage
- Click Save.
Fix - Buildtime
Terraform
- Argument: statement
- Attribute: action
“`go aws_iam_policy resource “aws_sqs_queue_policy” “example” { queue_url = aws_sqs_queue.q.id
policy = <<POLICY { “Version”: “2012-10-17”, “Id”: “sqspolicy”, “Statement”: [ { “Sid”: “First”, “Effect”: “Allow”, “Principal”: “*”, “Action”: “sqs:SendMessage”, “Resource”: “${aws_sqs_queue.q.arn}”, “Condition”: { “ArnEquals”: { “aws:SourceArn”: “${aws_sns_topic.example.arn}” } } } ] } POLICY } “`