
AWS IAM Privilege Escalation: Attack Paths, Detection, and Defense Strategies
Discover how excessive IAM permissions can create privilege escalation paths in AWS. Explore common misconfigurations involving PassRole, Lambda, EC2, and role trust policies, along with practical detection and defense strategies using IAM Access Analyzer, CloudTrail, GuardDuty, and AWS Security Hub.
AWS IAM Privilege Escalation: Attack Paths, Detection, and Defense Strategies
Introduction
In traditional infrastructure, attackers often attempt to escalate privileges by exploiting operating system vulnerabilities or misconfigured administrative accounts.
In AWS, privilege escalation can occur without exploiting a software vulnerability.
A cloud identity with excessive permissions may be able to modify policies, assume privileged roles, create resources with elevated permissions, or abuse service integrations.
These weaknesses are especially dangerous because they can arise from legitimate AWS functionality rather than application bugs.
In cloud environments, identity permissions are part of the attack surface.
This article examines common IAM privilege escalation patterns, explains how security teams can identify dangerous permission combinations, and presents practical defensive strategies using AWS-native security services.
1. Understanding IAM Privilege Escalation
AWS Identity and Access Management (IAM) controls authentication and authorization for supported AWS resources.
IAM policies define which actions an identity can perform, which resources those actions apply to, and under what conditions access is permitted.
Privilege escalation occurs when an identity gains capabilities beyond its intended authorization boundaries.
For example, a developer role intended to deploy applications might have permissions that indirectly allow it to operate a more privileged service role.
Common Risk Categories
- Excessive IAM permissions.
- Overly permissive role trust policies.
- Unrestricted
iam:PassRole.
- Dangerous policy modification permissions.
- Privileged service-role attachment.
- Misconfigured cross-account access.
- Unrestricted access to temporary credentials.
- Inadequate separation of duties.
The central problem is not necessarily a single dangerous permission.
Often, the risk emerges from a combination of permissions that enables an unintended authorization path.
2. The AWS Shared Responsibility Model
AWS secures the underlying cloud infrastructure, while customers remain responsible for configuring access to their cloud resources.
For IAM, customer responsibilities include:
- Defining appropriate permissions.
- Managing identity lifecycle.
- Configuring trust relationships.
- Reviewing access policies.
- Protecting credentials.
- Monitoring privileged operations.
- Enforcing least privilege.
AWS provides tools to help customers manage these responsibilities, but it does not automatically prevent every insecure authorization design.
A well-configured IAM environment requires both preventive and detective controls.
3. Common IAM Privilege Escalation Paths
3.1 Policy Modification
An identity with permission to modify IAM policies may be able to grant additional capabilities to itself or another principal.
Sensitive actions include:
-
iam:CreatePolicyVersion
-
iam:SetDefaultPolicyVersion
-
iam:PutUserPolicy
-
iam:PutRolePolicy
-
iam:AttachRolePolicy
These permissions require careful review because they can change the effective authorization of identities.
3.2 Unrestricted iam:PassRole
The
iam:PassRole permission allows an authorized identity to pass an IAM role to supported AWS services.It does not directly grant the caller the permissions of that role.
However, when combined with permissions to create or modify certain AWS resources, it can create an indirect privilege escalation path.
For example, a developer who can deploy a Lambda function and pass a highly privileged execution role may be able to cause code to execute with permissions beyond the developer's intended scope.
3.3 Role Trust Policy Misconfigurations
An IAM role trust policy specifies which principals may assume the role.
An overly broad trust relationship can unintentionally allow access from unauthorized identities or AWS accounts.
This is especially important in multi-account environments.
3.4 Temporary Credential Exposure
Temporary credentials are widely used by AWS workloads.
If an attacker compromises an application or compute resource, they may attempt to use the associated credentials.
The resulting impact depends on the permissions granted to the workload identity.
Temporary credentials reduce reliance on long-lived secrets, but they still require careful authorization and monitoring.
4. Example: Identifying Dangerous PassRole Permissions
Consider an IAM policy that grants the following permissions:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iam:PassRole", "lambda:CreateFunction", "lambda:UpdateFunctionCode" ], "Resource": "*" } ]}This policy is overly permissive.
The principal can pass roles without a resource restriction and has broad permissions to create or modify Lambda functions.
The actual escalation potential depends on the roles available, trust relationships, other authorization controls, and applicable service restrictions.
Safer Policy Design
A more restrictive approach limits which role may be passed and which service may receive it.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam::123456789012:role/AppLambdaExecutionRole", "Condition": { "StringEquals": { "iam:PassedToService": "lambda.amazonaws.com" } } } ]}This policy restricts the role that can be passed and limits the receiving service to AWS Lambda.
Additional controls should restrict which functions may be created or modified and what the execution role can access.
5. Detecting IAM Privilege Escalation with CloudTrail
AWS CloudTrail records supported AWS API activity.
For IAM security investigations, CloudTrail can help identify changes to policies, role trust relationships, and credentials.
Important events include:
-
CreatePolicyVersion
-
SetDefaultPolicyVersion
-
AttachRolePolicy
-
PutRolePolicy
-
UpdateAssumeRolePolicy
-
CreateAccessKey
-
AssumeRole
Example: Investigating IAM Policy Changes
aws cloudtrail lookup-events \ --lookup-attributes \ AttributeKey=EventName,AttributeValue=AttachRolePolicyThis command retrieves matching CloudTrail events available through the lookup API in the selected Region.
For broader investigations, use appropriately configured trails or CloudTrail Lake event data stores.
Investigation Questions
Security analysts should determine:
- Which identity performed the operation?
- Was the action expected?
- Which role or policy was affected?
- Did the change increase effective permissions?
- Was the operation followed by suspicious activity?
- Did the affected identity access sensitive resources?
A single policy change is not automatically malicious.
Context is essential for distinguishing legitimate administration from privilege escalation.
6. IAM Access Analyzer: Finding Excessive Permissions
IAM Access Analyzer helps organizations identify certain access risks and improve IAM policy design.
Relevant capabilities include:
- External access analysis.
- Unused access findings.
- IAM policy validation.
- Policy generation based on CloudTrail activity.
- Custom policy checks.
Availability and pricing depend on the analyzer type and supported capabilities.
Create an External Access Analyzer
aws accessanalyzer create-analyzer \ --analyzer-name OrganizationExternalAccess \ --type ORGANIZATIONAn organization-level analyzer requires the appropriate AWS Organizations configuration and permissions.
For an individual account, an account-level analyzer may be more suitable.
List Analyzer Findings
aws accessanalyzer list-findings-v2 \ --analyzer-arn arn:aws:access-analyzer:REGION:ACCOUNT_ID:analyzer/OrganizationExternalAccessReplace the placeholder values with the correct analyzer ARN.
Important Limitation
IAM Access Analyzer is valuable for policy analysis, but it does not automatically discover every possible multi-step privilege escalation chain.
Complex attack-path analysis may require additional tooling and manual security review.
7. Amazon GuardDuty: Detecting Suspicious IAM Activity
Amazon GuardDuty analyzes supported AWS telemetry to detect potentially malicious behavior.
It can identify certain indicators associated with:
- Compromised AWS credentials.
- Suspicious API calls.
- Unusual access patterns.
- Potential credential misuse.
- Malicious activity involving supported workloads.
Example Scenario
An attacker obtains credentials associated with a developer role.
The attacker begins invoking AWS APIs from an unusual environment and attempts to access resources that are not normally used by that identity.
GuardDuty may generate a finding if the activity matches supported detection patterns.
However, GuardDuty does not guarantee detection of every IAM privilege escalation technique.
Organizations should combine GuardDuty findings with CloudTrail analysis and IAM policy reviews.
8. AWS Security Hub: Centralized Security Findings
AWS Security Hub helps organizations centralize supported security findings and assess cloud security posture.
It can integrate information from services such as GuardDuty and IAM Access Analyzer, depending on the enabled integrations and capabilities.
Security teams can use Security Hub to:
- Review findings across accounts.
- Identify security control failures.
- Prioritize remediation.
- Track security posture.
- Integrate findings into incident response workflows.
For example, a suspicious IAM operation detected by GuardDuty may become more significant when combined with findings indicating overly permissive access.
Correlation helps analysts prioritize investigations more effectively.
9. AWS Organizations and Service Control Policies
AWS Organizations allows administrators to manage multiple AWS accounts.
Service Control Policies (SCPs) can establish permission guardrails for principals in member accounts.
SCPs do not grant permissions.
Instead, they define maximum available permissions within their scope.
Example: Denying IAM Policy Modification
{ "Version": "2012-10-17", "Statement": [ { "Sid": "DenyIAMPolicyModification", "Effect": "Deny", "Action": [ "iam:CreatePolicyVersion", "iam:SetDefaultPolicyVersion", "iam:AttachRolePolicy", "iam:PutRolePolicy" ], "Resource": "*" } ]}This is an illustrative deny statement.
In production, organizations should carefully evaluate the impact on administrators, deployment pipelines, emergency access, and automation.
SCPs also have scope limitations, including that they do not restrict principals in the AWS Organizations management account.
10. Building a Cloud IAM Detection Workflow
A security monitoring architecture can combine multiple AWS services.
Reference Architecture
AWS Accounts | v IAM API Activity | v CloudTrail | v EventBridge | v Security Evaluation | +-------+-------+ | | v v GuardDuty IAM Access Analyzer | | +-------+-------+ | v Security Hub | v Security Operations | v Investigation / ResponseThis diagram is conceptual.
GuardDuty and IAM Access Analyzer use their own supported data sources and detection mechanisms; they do not simply consume every CloudTrail event through EventBridge.
The workflow illustrates how organizations can combine AWS security services into a centralized investigation and response process.
11. Practical IAM Security Audit Checklist
A security assessment should include the following activities:
- [ ] Identify identities with administrative permissions.
- [ ] Review unrestricted
iam:PassRolepermissions.
- [ ] Inspect sensitive IAM policy modification actions.
- [ ] Review role trust policies.
- [ ] Identify unnecessary cross-account access.
- [ ] Check for unused permissions.
- [ ] Review long-lived access keys.
- [ ] Verify MFA requirements for human identities.
- [ ] Analyze sensitive CloudTrail events.
- [ ] Review GuardDuty findings.
- [ ] Validate IAM Access Analyzer findings.
- [ ] Evaluate SCP guardrails.
- [ ] Confirm separation of duties.
- [ ] Test incident response procedures.
12. Recommended Defensive Strategy
A mature IAM security program should combine prevention, detection, and response.
Prevention
- Enforce least privilege.
- Restrict
iam:PassRole.
- Limit policy modification permissions.
- Protect privileged roles.
- Use permissions boundaries where appropriate.
- Apply SCP guardrails.
- Require strong authentication for human users.
- Prefer temporary credentials.
Detection
- Enable appropriate CloudTrail logging.
- Monitor IAM policy changes.
- Investigate suspicious API activity.
- Use GuardDuty for supported threat detections.
- Review IAM Access Analyzer findings.
- Correlate findings through Security Hub.
Response
- Revoke or restrict compromised credentials.
- Remove unauthorized permissions.
- Review affected role trust relationships.
- Investigate actions performed using compromised identities.
- Preserve relevant audit logs.
- Validate that excessive access has been removed.
- Update security controls based on the root cause.
Conclusion
IAM privilege escalation is one of the most important risks in cloud security because attackers may exploit legitimate permissions rather than traditional software vulnerabilities.
Misconfigured policies, unrestricted role passing, overly broad trust relationships, and excessive administrative capabilities can create unintended paths to sensitive resources.
AWS provides powerful tools to reduce these risks.
IAM Access Analyzer helps evaluate access policies, CloudTrail supports investigation, GuardDuty detects certain suspicious activities, Security Hub centralizes findings, and AWS Organizations provides preventive guardrails.
However, no single service can identify or prevent every possible privilege escalation path.
Effective cloud identity security requires continuous permission analysis, least-privilege enforcement, behavioral monitoring, and well-tested incident response procedures.
References
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article