highCWE-269OWASP A01:2021

IAM Overly Permissive Policy

Your IAM policy uses Action: '*' or Resource: '*', granting far more permissions than needed and turning any credential leak into a full account takeover.

How It Works

The principle of least privilege means giving each role exactly the permissions it needs — nothing more. Action: '*' with Resource: '*' is essentially admin access. When these credentials are stolen (via SSRF, hardcoded keys, or phishing), the attacker can do anything: delete databases, exfiltrate all S3 data, create new admin users, disable CloudTrail logging. Least privilege limits the blast radius of any credential compromise.

Vulnerable Code
// BAD: wildcard IAM policy (Terraform)
resource "aws_iam_role_policy" "app_policy" {
  role = aws_iam_role.app.id
  policy = jsonencode({
    Statement = [{
      Effect   = "Allow"
      Action   = "*"        // can do ANYTHING
      Resource = "*"        // on ANY resource
    }]
  })
}
Secure Code
// GOOD: minimal permissions scoped to specific resources
resource "aws_iam_role_policy" "app_policy" {
  role = aws_iam_role.app.id
  policy = jsonencode({
    Statement = [{
      Effect   = "Allow"
      Action   = ["s3:GetObject", "s3:PutObject"]  // only what the app needs
      Resource = "arn:aws:s3:::my-app-bucket/*"    // only this bucket
    }]
  })
}

Real-World Example

The 2019 Capital One breach escalated from an SSRF vulnerability to a full data dump because the compromised EC2 instance had an IAM role with s3:GetObject on Resource: '*' — not just the specific buckets the app needed. Proper scoping would have limited the breach to a single bucket.

How to Prevent It

  • Start with zero permissions and add only what's needed — never start with '*' and restrict later
  • Use AWS IAM Access Analyzer to identify overly permissive policies in your account
  • Scope Resource to specific ARNs (arn:aws:s3:::my-bucket/*) rather than '*'
  • Use AWS managed policies only as a starting point — create custom policies for production workloads
  • Audit IAM policies quarterly using AWS IAM Credential Report and Access Advisor

Affected Technologies

Node.jsPython

Data Hogo detects this vulnerability automatically.

Scan Your Repo Free

Related Vulnerabilities