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

  1. Log in to the AWS Management Console at https://console.aws.amazon.com/.
  2. Open the Amazon SQS console.
  3. Click on the queue you want to modify.
  4. Click on the “Access Policy” tab within the queue’s details page.
  5. Click “edit” next to the displayed “Access Policy”.
  6. Identify any Action statements permitting actions access to all resources (“*”).
  7. Narrow the scope to necessary actions, for example sqs:SendMessage
  8. 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 } “`

ReLambda