IAM role policy passrole allows all
This product is not supported for your selected
Datadog site. (
).
Id: e39bee8c-fe54-4a3f-824d-e5e2d1cca40a
Cloud Provider: aws
Framework: Terraform
Severity: Medium
Category: Access Control
Learn More
Description
Granting the iam:passrole
action with a resource value of "*"
in Terraform ("Resource": "*"
) is overly permissive, as it allows the user or role to pass any IAM role in the account to AWS services. This broad permission can lead to privilege escalation, enabling attackers or unauthorized users to assume highly-privileged roles they should not have access to. To mitigate this risk, the resource should be scoped to specific role ARNs (for example, "Resource": "arn:aws:iam::account-id:role/RoleName"
) to enforce the principle of least privilege.
Compliant Code Examples
resource "aws_iam_role_policy" "test_policy" {
name = "test_policy"
role = aws_iam_role.test_role.id
policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"iam:passrole"
],
"Effect": "Allow",
"Resource": "arn:aws:sqs:us-east-2:account-ID-without-hyphens:queue1"
}
]
}
EOF
}
Non-Compliant Code Examples
resource "aws_iam_role_policy" "test_policy" {
name = "test_policy"
role = aws_iam_role.test_role.id
policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"iam:passrole"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
}