IAM002 · IAM003 · IAM004 · IAM009 · SOC 2 CC6.1 · CIS 1.16

Fix AWS IAM iam:PassRole & CreatePolicyVersion Privilege Escalation

Eliminate silent AWS admin takeover paths from unscoped iam:PassRole (IAM003), iam:CreatePolicyVersion (IAM004), iam:* wildcards (IAM002), and AdministratorAccess attachments (IAM009)—audited 100% locally with 0 bytes uploaded.

Scan IAM / TF (0 Upload) Pro CLI Pack $49 →

0 bytes uploaded · 0 AWS keys · One-time local CLI, SARIF 2.1.0 & SOC 2 CC6.1 dossier via Polar.sh.

IAM002 · IAM003 · IAM004 · IAM009 0 Network Requests During Scan SOC 2 CC6.1 / CC6.3 · CIS AWS v5.0 1.16 Least-Privilege Diff Generator
1. Load an IAM Escalation Sample or Drop Local .tf / .json Files
Drag & drop local IAM .json or Terraform .tf files — processed strictly in browser memory.

Vulnerable vs. Hardened Terraform IAM Role (Before & After)

CI/CD deploy roles frequently accumulate iam:*, unscoped iam:PassRole, iam:CreatePolicyVersion, or direct AdministratorAccess attachments. Scope iam:PassRole to the exact execution role ARN with iam:PassedToService, attach a permissions_boundary, and enforce exact OIDC repository claims.

Vulnerable · IAM002 · IAM003 · IAM004 · IAM009
resource "aws_iam_role_policy" "ci_escalate" {
  name = "ci-deployer-inline"
  role = aws_iam_role.ci_deployer.id

  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = [
        "iam:*",
        "iam:PassRole",
        "iam:CreatePolicyVersion",
        "lambda:UpdateFunctionCode"
      ]
      Resource = "*"
    }]
  })
}

resource "aws_iam_role_policy_attachment" "admin_attach" {
  role       = aws_iam_role.ci_deployer.name
  policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
}
Hardened · 100/100 (Grade A · 0 Findings)
resource "aws_iam_role" "ci_deployer" {
  name                 = "ci-deployer-prod"
  permissions_boundary = "arn:aws:iam::123456789012:policy/AppBoundary"
  max_session_duration = 3600
  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Allow"
      Principal = { Federated = "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com" }
      Action    = "sts:AssumeRoleWithWebIdentity"
      Condition = {
        StringEquals = {
          "token.actions.githubusercontent.com:aud" = "sts.amazonaws.com"
          "token.actions.githubusercontent.com:sub" = "repo:acme/app:ref:refs/heads/main"
        }
      }
    }]
  })
}

resource "aws_iam_role_policy" "ci_scoped_passrole" {
  name = "ci-deployer-scoped-passrole"
  role = aws_iam_role.ci_deployer.id
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = ["iam:PassRole"]
      Resource = "arn:aws:iam::123456789012:role/app-lambda-exec"
      Condition = {
        StringEquals = {
          "iam:PassedToService" = "lambda.amazonaws.com"
        }
      }
    }]
  })
}

Privilege Escalation Rules Checked Automatically

Rule Severity Escalation Vector Caught Exact Fix
IAM002 CRITICAL Dangerous service wildcards (iam:*, sts:*, kms:*, ec2:*, organizations:*) on * Replace with explicit minimal actions scoped to target ARNs.
IAM003 CRITICAL Unscoped iam:PassRole missing target role ARN or iam:PassedToService Pin exact role ARN and add Condition.StringEquals["iam:PassedToService"].
IAM004 CRITICAL iam:CreatePolicyVersion, AttachRolePolicy, PutRolePolicy, or lambda:UpdateFunctionCode on * Remove direct IAM write actions from workload/CI roles or constrain via permissions boundary.
IAM009 HIGH Direct attachment of AdministratorAccess, PowerUserAccess, or IAMFullAccess Replace managed admin policies with task-specific least-privilege policies.

Block IAM Escalation on Every Terraform PR (Zero Subscription)

Scan entire multi-module AWS repositories locally with leastproof-cli (68 KB Node.js binary, 0 npm deps) and export SARIF 2.1.0 + SHA-256 sealed SOC 2 CC6.1 auditor evidence.

Frequently Asked Questions

How can an attacker escalate privileges with unscoped iam:PassRole?

With iam:PassRole on * plus compute creation permissions (Lambda, EC2, ECS), an attacker attaches an existing admin execution role to a new compute task and executes arbitrary AWS API calls as administrator.

Why is iam:CreatePolicyVersion on * a direct privilege escalation?

Setting a new default version on a policy already attached to the caller grants immediate Action: "*" on Resource: "*" without modifying trust relationships.

How do I safely scope iam:PassRole in Terraform?

List the exact target execution role ARN in Resource, add an iam:PassedToService StringEquals condition, and enforce a permissions_boundary on the role.

Related AWS IAM & Terraform Remediation Guides

Fix Wildcard Action: "*" / Resource: "*"

Scope full wildcard admin policies (IAM001, IAM004) into least-privilege JSON diffs.

Read Wildcard IAM Guide

Fix 0.0.0.0/0 SSH & RDS Security Groups

Lock down exposed ports 22, 3389, 5432, and 3306 (TF001–TF004) in Terraform.

Read Security Group Guide

Fix EC2 IMDSv1 & Unencrypted RDS

Enforce http_tokens = "required" and KMS encryption (TF007–TF012).

Read IMDSv2 & KMS Guide

Oriancy Local Security Quartet

4 Zero-Upload Scanners · 1 One-Time Bundle
DevSecOps Quartet Bundle — All 4 local CLIs & auditor packs on one-time Polar licenses · oriancy.com