Exploiting IAM Misconfigurations
Privilege escalation in the cloud.
Exploiting IAM Misconfigurations is a free Cyber Security Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cyber Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
IAM as an Escalation Engine
In the cloud, privilege escalation usually means abusing IAM permissions rather than exploiting memory bugs. If a low-priv identity can modify policies, create keys, or assume roles, it can reach admin.
- Permissions that modify IAM are inherently dangerous.
- Escalation paths are policy logic, not vulnerabilities.
- The fix is least privilege, not a patch.
Dangerous Permissions
Certain IAM actions enable direct escalation. Watch for these on a principal you control:
iam:CreateAccessKeyon another user.iam:AttachUserPolicy/iam:PutUserPolicy(attach AdministratorAccess).iam:CreatePolicyVersion(rewrite an existing policy).iam:PassRole+ a compute service (run code as a privileged role).sts:AssumeRolewith a weak trust policy.
Policy Attachment Escalation
If your identity can attach policies to itself, escalation is one call away. You attach a managed admin policy and inherit full rights.
# Attach AdministratorAccess to yourself
aws iam attach-user-policy \
--user-name me \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccessPassRole Abuse
iam:PassRole lets you hand a role to a service. Combined with a service that runs your code (EC2, Lambda, Glue), you execute as that role, even if it is far more privileged than you.
# Launch a Lambda that assumes a privileged role you can pass
aws lambda create-function --function-name esc \
--role arn:aws:iam::111:role/AdminRole \
--runtime python3.12 --handler h.run --zip-file fileb://code.zipPolicy Version Rollback
iam:CreatePolicyVersion or SetDefaultPolicyVersion lets you replace a policy's active document or roll back to a more permissive past version, granting broad access without touching group membership.
# Make a new, permissive default version of an existing policy
aws iam create-policy-version \
--policy-arn arn:aws:iam::111:policy/devs \
--policy-document file://admin.json --set-as-defaultTrust Policy and AssumeRole Abuse
Role trust policies define who may assume them. Weak trust conditions enable takeover.
- A role trusting
*or a whole account can be assumed broadly. - If you can edit a role's trust policy, add yourself as a trusted principal.
- Confused-deputy: external IDs missing on third-party integration roles.
# Assume a poorly-scoped role
aws sts assume-role \
--role-arn arn:aws:iam::111:role/CrossAccountAdmin \
--role-session-name ptCross-Cloud Equivalents
The same patterns appear across providers.
- Azure: a User Access Administrator or Owner role assignment; Managed Identity abuse; adding credentials to a service principal.
- GCP:
iam.serviceAccounts.actAsplus a compute service;setIamPolicyon a project; service-account key creation.
# GCP: impersonate a privileged service account
gcloud compute instances create esc --service-account priv@proj.iam.gserviceaccount.com --scopes cloud-platformTooling for Path Discovery
Rather than guessing, use tooling to surface viable escalation paths from your current identity.
# Pacu (AWS exploitation framework) escalation module
pacu
run iam__privesc_scan
# PMapper query for escalation
pmapper query 'preset privesc me'Chaining to the Control Plane
Escalation often chains data-plane access into control-plane power.
- Compromise a VM, steal its instance-role credentials from metadata.
- The instance role has
PassRole+ Lambda, enabling admin role execution. - From admin, create persistent access keys for stealth.
Each link is a separate finding worth reporting.
Defending IAM
Prevention centers on least privilege and guardrails.
- Remove wildcards; scope actions and resources tightly.
- Use permission boundaries and SCPs to cap maximum privilege.
- Require external IDs on third-party roles; scope trust policies.
- Prefer short-lived role credentials over long-lived keys.
- Use access analyzers to flag risky and unused permissions.
Ethical Execution
IAM escalation can grant account-wide power. Stop at proof-of-concept: demonstrate the path without creating durable backdoors or modifying production policies you cannot revert. Always revert any policy or role changes and remove keys you create.
Coordinate disruptive steps (like rewriting a shared policy) with the client beforehand.
Quick Check
Confirm your IAM escalation knowledge.
Recap
You learned how IAM misconfigurations escalate privilege.
- Policy attachment, PassRole, version rollback, and AssumeRole are core paths.
- The same patterns recur across AWS, Azure, and GCP.
- Pacu and PMapper discover viable paths automatically.
- Least privilege, permission boundaries, and external IDs are the defenses.
Next: persistence and lateral movement across cloud accounts.
Frequently asked questions
Is the “Exploiting IAM Misconfigurations” lesson free?
Yes — the full text of “Exploiting IAM Misconfigurations” is free to read here on the web, and the Cyber Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cyber Security Academy course, upgrade to CoddyKit PRO.
What will I learn in “Exploiting IAM Misconfigurations”?
Privilege escalation in the cloud. You practise Cyber Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cyber Security Academy?
No prior experience is required. Cyber Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Exploiting IAM Misconfigurations” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cyber Security Academy lesson?
Yes. Every Cyber Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Cloud Attack Surface
- Enumerating Cloud Resources
- Exploiting IAM Misconfigurations
- Persistence and Lateral Movement