Unscoped iam:PassRole Grants Let Lambda Roles Escalate to Admin
Overview
A wildcard iam:PassRole grant lets an AWS Lambda deploy identity pass any role, including privileged ones, to a function it controls — a quiet path to full account escalation.
At a glance
- Symptom
- CloudTrail shows a deployment identity — one whose declared job is publishing AWS Lambda functions — performing actions well outside that scope, such as…
- Likely cause
- An unscoped iam:PassRole statement, combined with permission to create or update a compute resource such as a Lambda function, lets the deploy identity pass…
- Impact
- Any identity that can reach this combination of permissions can escalate to the privilege level of the most powerful role reachable through PassRole, up to full account administration.
- Verification signal
- Re-test the exact paths used during diagnosis and confirm they now fail closed rather than assuming the fix worked.Re-run aws iam simulate-principal-policy for iam:PassRole against the previously reachable…
- Safe correction
- Replace the wildcard grant with a statement naming the specific role ARNs the deploy identity is permitted to pass, and add an iam:PassedToService condition restricting the grant to…
- Rollback or recovery
- If the scoped policy blocks a legitimate deployment, restore the previous policy version rather than reintroducing the wildcard grant.Identify the prior version with aws iam list-policy-versions --policy-arn .Restore…
Symptom
CloudTrail shows actions well outside the job of a deployment identity that should only publish AWS Lambda functions: modifying S3 bucket policies, creating IAM users or reading secrets in other services. A privileged role session makes them, from a function that identity created or reconfigured. No policy directly attached to the deploy identity grants those permissions, so a review of its own attached policies finds nothing wrong.
The identity’s IAM policy still looks minimal and reasonable on paper: permission to manage Lambda functions, plus a broad iam:PassRole statement that the team added months earlier so deployments would not keep failing on role-assignment errors.
False Assumption
The review treats the wildcard iam:PassRole statement, scoped as Resource: "*", as low risk because it reasons that PassRole only lets the identity hand an existing role to a resource — it does not itself grant the permissions contained in that role. Since no broad managed policy such as AdministratorAccess is attached directly to the deploy identity, the wildcard grant is waved through as a convenience fix rather than a privilege boundary.
Root Cause
An unscoped iam:PassRole statement, combined with permission to create or update a compute resource such as a Lambda function, lets the deploy identity pass any role in the account — including roles with far greater privilege than the deploy identity itself — to that resource.
Once the function runs under the passed role, code invoked through it executes with that role’s permissions, not the deploy identity’s own permissions. The escalation path never touches the deploy identity’s attached policy, so a policy review that only inspects the suspect identity’s own statements will not surface it.
Impact
Any identity that can reach this combination of permissions can escalate to the privilege level of the most powerful role reachable through PassRole, up to full account administration.
Because the escalation happens through resource creation rather than a policy change, it produces CloudTrail events that look like ordinary deployment activity unless the reviewer specifically checks which role ARNs those calls pass.
Lambda is only one route: the same escalation works with any launch action that attaches a role, such as ec2:RunInstances with an instance profile, ECS task definitions or Glue jobs. iam:PassRole is a permission, not an API call, so CloudTrail records no separate PassRole event; the passed role appears only in the request parameters of calls such as CreateFunction.
Diagnosis
Confirm the exposure before changing anything.
- Export the account’s IAM policy set with
aws iam get-account-authorization-detailsand search foriam:PassRolestatements usingResource: "*"or omitting aniam:PassedToServicecondition. - Use
aws iam simulate-principal-policyto test, against the ARN of a specific highly privileged role, whether the deploy identity is currently permitted to pass it. - Review CloudTrail
CreateFunction,UpdateFunctionConfigurationorRunInstancesevents issued by the deploy identity and check the role or instance profile ARN in their request parameters against the identity’s intended scope. - Audit the Lambda execution roles themselves for
iam:PassRoleon*: code running in a compromised function could pass any role to EC2, ECS or Glue.
Correction
Replace the wildcard grant with a statement naming the specific role ARNs the deploy identity is permitted to pass, and add an iam:PassedToService condition restricting the grant to the intended service.
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::ACCOUNT_ID:role/lambda-deploy-execution-role",
"Condition": {
"StringEquals": { "iam:PassedToService": "lambda.amazonaws.com" }
}
}
Apply the scoped statement as a new managed-policy version rather than editing the existing version in place, so the previous version remains available if a legitimate deployment breaks.
Validation
Re-test the exact paths used during diagnosis and confirm they now fail closed rather than assuming the fix worked.
- Re-run
aws iam simulate-principal-policyforiam:PassRoleagainst the previously reachable privileged role ARN and confirm the result changes from allowed to denied. - In an isolated or non-production account, attempt to create a Lambda function passing the previously reachable role and confirm the call fails with
AccessDeniedreferencingiam:PassRole. - Review CloudTrail for the deploy role over the following 24 hours and confirm no
CreateFunctionorUpdateFunctionConfigurationrequest passes a role ARN outside the new allow-list.
Rollback
If the scoped policy blocks a legitimate deployment, restore the previous policy version rather than reintroducing the wildcard grant.
- Identify the prior version with
aws iam list-policy-versions --policy-arn <deploy-policy-arn>. - Restore it with
aws iam set-default-policy-version --policy-arn <deploy-policy-arn> --version-id <previous-version-id>. - Add the missing legitimate role ARN to the scoped allow-list and re-apply the fix rather than leaving the wildcard restored.
Prevention
Treat every iam:PassRole grant as carrying the risk of the most privileged role it can reach, and scope it during policy review rather than inspecting only the identity’s own attached permissions.
Pair scoped PassRole statements with a permission boundary on deploy roles and a periodic export via get-account-authorization-details so wildcard grants introduced as quick fixes are caught before the next incident rather than after it. Keep launch roles and administrative roles separate, so that no single PassRole grant can reach both.
AWS’s Well-Architected Security Pillar documents design principles and operational practices for protecting AWS workloads, including applying least-privilege access as a routine review discipline rather than a one-off remediation; incorporate PassRole scoping checks into that recurring review cycle.
Related reading
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Fix commands and configuration
iam:PassRoleResource: "*"PassRoleWhen to escalate
Validation and rollback are covered in the sections above.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Last updated
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
