Aws iam privilege escalation

From xalgorix/xalgorix · View interactive version

Aws iam privilege escalation is an AI agent skill from the GitHub repository xalgorix/xalgorix. AWS IAM privilege escalation — CreatePolicyVersion, AttachUserPolicy, PutRolePolicy, PassRole with Lambda/EC2/Glue/SageMaker/CloudFormation/SSM, role assumption, trust-policy and resource-policy abuse, resolving boundaries/SCPs before proving the formerly denied action

How to use this skill

Skill file

AWS IAM Privilege Escalation

Purpose

Prove privilege escalation in AWS: from the current principal's permissions to a higher-privilege identity, resolving permission boundaries, SCPs, and conditions before claiming the path — then demonstrating the formerly denied action.

Entry Conditions

Attack Model

baseline: denied action A
→ escalation primitive (policy modify / pass role / assume / service exec)
→ changed identity or effective permission
→ action A now SUCCEEDS
→ report (restore modified state)

Tool output (Pacu iam__privesc_scan, PMapper edge, CloudFox) is a HYPOTHESIS. Resolve it into proof.

Methodology

Priority Order (depth-first on strong signals)

  1. Direct policy modification
  2. Role assumption
  3. PassRole + service execution
  4. Credential creation
  5. Data access (if the goal is data, not admin)
  6. Indirect/service-specific escalation

Family 1 — Direct Policy Modification

# iam:CreatePolicyVersion (managed policies cap at 5 versions)
aws iam create-policy-version --policy-arn <arn> --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}' --set-as-default
# iam:SetDefaultPolicyVersion (flip to an old permissive version that already exists)
aws iam set-default-policy-version --policy-arn <arn> --version-id v3
# iam:AttachUserPolicy / AttachRolePolicy / AttachGroupPolicy
aws iam attach-user-policy --user-name <u> --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
# iam:PutUserPolicy / PutRolePolicy / PutGroupPolicy (inline)
aws iam put-user-policy --user-name <u> --policy-name xalgorix-test --policy-document '{...}'
# PROOF: previously denied action now succeeds; record and RESTORE original state
aws iam list-users   # example: was AccessDenied before escalation

Family 2 — PassRole + Service Execution

iam:PassRole + lambda:CreateFunction        → function with admin role, invoke
iam:PassRole + ec2:RunInstances            → instance with admin instance profile
iam:PassRole + glue:CreateDevEndpoint      → dev endpoint, SSH creds
iam:PassRole + sagemaker:CreateNotebookInstance
iam:PassRole + cloudformation:CreateStack  → stack with admin-capable role
iam:PassRole + ssm:SendCommand / ecs:RunTask / databrew etc.

Scoped PassRole is the usual gate: enumerate exactly which role ARNs are passable (read the policy Resource element and conditions) before claiming the vector. Then execute the path and prove the resulting identity.

Family 3 — Role Assumption

aws sts assume-role --role-arn <arn> --role-session-name xalgorix-test
# Requires: identity-side sts:AssumeRole AND the target trust policy allowing your principal
# AND every condition (ExternalId, MFA, SourceOrgID) satisfied

See cloud-cross-account-tenant-trust for the full trust-edge model.

Family 4 — Credential Creation

iam:CreateAccessKey on a more privileged user, iam:CreateLoginProfile (console access), sts:GetFederationToken/sts:GetSessionToken context checks, service-specific credential issuance (CodeBuild tokens, etc.).

Family 5 — Service-Specific Escapes

Resolving the Hypothesis (where tool output dies)

For every candidate path, resolve BEFORE claiming:

Evidence Contract

escalation candidate (permission held / tool edge)
→ constraint resolution (boundaries/SCPs/conditions checked)
→ escalation operation performed (within runtime policy)
→ new identity/credentials obtained (get-caller-identity recorded)
→ previously denied action now succeeds (the proof)
→ state restored where modified (delete created key/policy/function, restore default version)
→ report

NOT evidence: Pacu/PMapper output alone, iam:PassRole held without a usable target-role + execution service, a trust policy read but no successful assumption, CreateFunction returning 200 without invoking the function under the admin role

Eventual Consistency Rule

Do NOT blind-retry every AccessDenied. Retry-on-denial is justified only in the seconds after a relevant state change (new policy version, modified trust, new role/credential you just created or observed). A static denial after enumeration-complete is a real negative.

Common Misses

False Positives / Non-Findings

Xalgorix Tool Strategy

Specialist Handoffs

Stopping Rule

Prioritize direct policy modification > role assumption > PassRole/service execution > credential creation; go depth-first. Stop when admin-equivalent access is proven OR the top 3 families are constraint-resolved and blocked. Do not enumerate every theoretical escalation indefinitely.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.