iam:PassRole is one of the easiest ways to end up with more power than anyone intended. It doesn't do anything on its own, which is exactly why it's easy to grant too broadly.
What PassRole is
To configure many AWS services, you pass them an IAM role, which the service later assumes to act on your behalf: an instance profile for an EC2 instance, an execution role for a Lambda function, a service role for CloudFormation. To pass a role, the caller needs the iam:PassRole permission for that role (AWS: Grant a user permissions to pass a role to an AWS service).
AWS's own guidance spells out the risk: make sure a user can't pass a role that has more permissions than you want the user to have, because the service will then act with that role's permissions (same page).
How it becomes escalation
PassRole is dangerous in combination. A principal that can pass any role, and can also create something that runs with a role, can effectively become that role. Rhino Security Labs' AWS IAM privilege escalation research documents several of these, for example:
| Combination | What it allows |
|---|---|
iam:PassRole + ec2:RunInstances | Launch an instance with a privileged instance profile and use its credentials from the instance metadata. |
iam:PassRole + lambda:CreateFunction + lambda:InvokeFunction | Create a function that runs as a privileged role, then invoke it. |
iam:PassRole + cloudformation:CreateStack | Create a stack that runs with a privileged service role. |
If an admin role exists in the account and its trust policy allows the service, iam:PassRole on * turns "can launch instances" into "can act as admin".
Find broad PassRole grants with the AWS CLI
get-account-authorization-details returns every user, group, role and policy in an account, with policy documents (AWS CLI reference). This lists customer-managed policies whose default version allows iam:PassRole (or iam:*, or *) on every resource:
aws iam get-account-authorization-details --filter LocalManagedPolicy --output json \
| jq -r '
def arr: if type == "array" then . else [.] end;
.Policies[] | .PolicyName as $name
| .PolicyVersionList[] | select(.IsDefaultVersion)
| .Document.Statement | arr[]
| select(.Effect == "Allow")
| select(.Action | arr | any(. == "*" or . == "iam:*" or ascii_downcase == "iam:passrole"))
| select(.Resource | arr | any(. == "*"))
| $name' | sort -u
It's a starting point, not a full evaluation: it ignores inline policies, wildcards such as iam:Pass*, NotAction, conditions, permissions boundaries and SCPs. To check one specific question, ask IAM's policy simulator, which does evaluate the principal's policies (SimulatePrincipalPolicy):
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/ci-deploy \
--action-names iam:PassRole \
--resource-arns arn:aws:iam::111122223333:role/platform-admin \
--query 'EvaluationResults[].[EvalActionName,EvalDecision]' --output text
Scope it
Grant iam:PassRole only on the roles a principal actually needs to pass, and only to the service that needs them, using the iam:PassedToService condition key (AWS: iam:PassedToService):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::111122223333:role/app-lambda-*",
"Condition": {
"StringEquals": { "iam:PassedToService": "lambda.amazonaws.com" }
}
}
]
}
AWS also warns against trying to control PassRole with tags and the ResourceTag condition key, because it doesn't give reliable results (AWS).
Watching for it
PassRole is a permission, not an API call, so it never appears in CloudTrail by itself. To see which role was passed, look at the event that created or changed the resource, such as CreateFunction or RunInstances (AWS).
Doing this in AccessLens
AccessLens checks this for every principal in every account you add:
PASSROLE_ALL_RESOURCESflags principals that can pass any role.PRIVILEGE_ESCALATION_PATHchecks effective permissions against 27 escalation methods, nine of which involveiam:PassRole. The evaluation is simplified: it accounts for allows, unconditional denies and permissions boundaries, but it isn't a full policy simulator.- The trust graph draws passes role to edges, so you can see which principals can hand which service roles to AWS services.