Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bc-aws-iam-46.adoc #1018

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
| bfe88196-dc6b-4c34-bda7-ef4b90942544

|Checkov ID
| https://github.com/bridgecrewio/checkov/tree/master/checkov/terraform/checks/resource/aws/SQSPolicy.py[CKV_AWS_72]
| https://github.com/bridgecrewio/checkov/tree/main/checkov/terraform/checks/resource/aws/SQSPolicy.py[CKV_AWS_72]

|Severity
|INFO

|Subtype
|Build
//, Run
|Build, Run

|Frameworks
|Terraform,TerraformPlan
Expand All @@ -28,75 +27,39 @@

=== Description

This policy ensures that AWS SQS policies are configured to limit permissions to specific actions, avoiding the use of unrestricted wildcards like (*), in adherence to the principle of least privilege. By restricting actions to only those necessary for your application, you mitigate the risk of unauthorized access and potential misuse of your SQS queue.

The Action element describes the specific action or actions that will be allowed or denied.
Statements must include either an Action or NotAction element.
Each AWS service has its own set of actions that describe tasks that can be performed with that service.
Specify a value using a namespace that identifies a service, for example, iam, ec2 sqs, sns, s3, followed by the name of the action to be allowed or denied.
The name must match an action that is supported by the service.
We recommend you do not allow "*" (all resource) statements as part of action elements.
This level of access could potentially grant unwanted and unregulated access to anyone given this policy document setting.
We recommend you to write a refined policy describing the specific action allowed or required by the specific policy holder.

////
=== Fix - Runtime


* AWS Console*



. Log in to the AWS Management Console at https://console.aws.amazon.com/.

. Open the https://console.aws.amazon.com/sqs/v2/home [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*


* *Arguments:* statement
* *Attribute*: action
* *Arguments:* aws_sqs_queue_policy
* *Attribute*: policy.Statement.Action

In the following example, the IAM policy is configured to allow only the `sqs:SendMessage` action, restricting access to the SQS queue. This helps prevent unauthorized actions and enhances security.


tsmithv11 marked this conversation as resolved.
Show resolved Hide resolved
[source,go]
----
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}"
}
}
}
]
}
{
...
"Statement": [
{
"Sid": "Example",
"Effect": "Allow",
- "Action" = "*",
+ "Action": ["sqs:SendMessage"],
...
}
]
}
POLICY
}
}
----
Loading