How do you detect and stop an IAM privilege escalation via `iam:PassRole`?
AdvancedScenarioCloud IAM and Compliance
Answer
Situation read → A user who can pass a powerful role to EC2 or Lambda, then run code there, gains that role's permissions.
What I'd do →
- Scope
iam:PassRoleto specific role ARNs and use theiam:PassedToServicecondition (e.g. onlylambda.amazonaws.com). - Find risky combinations with tools like PMapper or Cloudsplaining.
- Alert on
PassRoleof admin roles in CloudTrail (it shows up on the service API call, such asRunInstancesorCreateFunction). - Keep admin roles not passable by default.
Why → PassRole is the most common path from limited to full access in AWS.
Interview tip → Name the pattern: "PassRole plus compute create equals escalation".
More on Cloud IAM and Compliance
You find an IAM policy with `"Action": "*", "Resource": "*"` attached to an application role. How do you right-size it?BeginnerYour company has 40 AWS accounts with no central controls. How do you set up preventive guardrails?IntermediateGuardDuty reports `UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS`. What happened and what do you do?AdvancedYour company must pass SOC 2 Type II in six months. What does DevOps own, and how do you automate evidence?IntermediateA partner needs access to one S3 bucket in your account. How do you set up cross-account access safely?IntermediateSomeone logged in with the AWS root user last night. How do you react, and how should you have known?Beginner