Interview Prep/AWS/IAM Best Practices

What is the risk of `iam:PassRole` with `Resource: "*"` and how do you scope it?

IntermediateProductionIAM Best Practices
Answer

Anyone who can pass any role and launch compute (EC2, Lambda, ECS, Glue) can run code as the most powerful role in the account, which is a privilege escalation. Scope it to specific role ARNs or a path, and restrict which service the role can be passed to:

{
  "Effect": "Allow",
  "Action": "iam:PassRole",
  "Resource": "arn:aws:iam::111122223333:role/app/*",
  "Condition": {"StringEquals": {"iam:PassedToService": "ecs-tasks.amazonaws.com"}}
}
aws All AWS questions Roadmap: AWS core services

More on IAM Best Practices