Cloud Security

Least Privilege in Practice: Moving from Broad IAM Policies to Scoped Permissions

By ··11 min read

Least privilege is one of those security principles that everyone agrees with in theory and almost nobody implements correctly in practice. Here is what makes it hard — and what makes it tractable.

Why least privilege fails in practice

The most common failure mode is straightforward: engineers attach AdministratorAccess or PowerUserAccess to get something working quickly, intend to tighten it later, and never do. The policy sticks. Months pass. The role accumulates more trust relationships. By the time anyone looks, you have a role with administrator access trusted by six different services, two CI/CD systems, and an EC2 instance profile.

A related pattern: break-glass accounts. An administrator role created for emergency access, with the intention that it would only be used in genuine emergencies. In practice, it gets used for convenience — for one-off operations that would take too long to do through the normal deployment pipeline. The break-glass becomes the normal path.

These patterns are not a failure of intention — they are a failure of process. Least privilege needs to be the path of least resistance, not a constraint that slows things down.

Auditing what you have

Before tightening anything, you need to understand the current state. Three tools are useful here.

AWS IAM Access Analyzer identifies external access — policies that grant access to resources from outside your account or organization. Run it across all regions and review every finding. External access that you did not explicitly intend is almost always a problem.

# Get all IAM users, roles, groups, and policies in one call
aws iam get-account-authorization-details \
  --output json > iam-snapshot.json

# Find all managed policies attached to roles
aws iam get-account-authorization-details \
  --filter Role \
  --query 'RoleDetailList[*].{Name:RoleName,Policies:AttachedManagedPolicies[*].PolicyName}' \
  --output table

# Find all roles with AdministratorAccess
aws iam get-account-authorization-details \
  --filter Role \
  --query 'RoleDetailList[?AttachedManagedPolicies[?PolicyName==`AdministratorAccess`]].RoleName' \
  --output text

The policy tightening workflow

The most reliable way to generate a scoped IAM policy is to use CloudTrail to see what API calls a role has actually made — then build a policy from that activity rather than from what the role theoretically needs.

AWS provides IAM Access Analyzer policy generation for exactly this purpose. Enable CloudTrail in all regions, wait 30–90 days for representative activity to accumulate, then generate a policy from the trail:

# Generate a policy based on CloudTrail activity for a role
aws accessanalyzer start-policy-generation \
  --policy-generation-details '{"principalArn":"arn:aws:iam::123456789:role/MyRole"}' \
  --cloud-trail-details '{
    "accessRole":"arn:aws:iam::123456789:role/AccessAnalyzerRole",
    "trailList":[{
      "cloudTrailArn":"arn:aws:cloudtrail:us-east-1:123456789:trail/my-trail",
      "allRegions":true
    }],
    "startTime":"2025-06-01T00:00:00Z",
    "endTime":"2025-08-31T23:59:59Z"
  }'

The generated policy is a starting point, not a final answer. Review it, add any additional permissions for actions that are infrequent but legitimate, then test thoroughly in a non-production environment before applying.

Resource-level conditions

Least privilege is not just about which actions are permitted — it is about which resources those actions can target. A policy that allows s3:GetObject on arn:aws:s3:::* is significantly more permissive than one that allows it on a specific bucket.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ReadSpecificBucket",
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:ListBucket"],
      "Resource": [
        "arn:aws:s3:::my-app-data-bucket",
        "arn:aws:s3:::my-app-data-bucket/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:PrincipalOrgID": "o-yourorgid"
        }
      }
    }
  ]
}

Condition keys are a powerful tool. aws:PrincipalOrgID restricts access to principals within your AWS organization. aws:SourceIp restricts API calls to specific IP ranges. aws:MultiFactorAuthPresent requires MFA for sensitive operations.

SCPs as guardrails

Service Control Policies (SCPs) apply at the AWS Organizations level — they restrict what can be done in an account regardless of what IAM policies permit. This makes them the right tool for enforcing hard boundaries that should never be crossed, even by account administrators.

Common SCP guardrails include: preventing CloudTrail from being disabled, restricting which regions workloads can be deployed to, preventing IAM users from being created with console access, and blocking the purchase of Reserved Instances or Savings Plans without approval.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyDisableCloudTrail",
      "Effect": "Deny",
      "Action": [
        "cloudtrail:StopLogging",
        "cloudtrail:DeleteTrail",
        "cloudtrail:UpdateTrail"
      ],
      "Resource": "*"
    }
  ]
}

SCPs vs permission boundaries

SCPs and permission boundaries serve different purposes. SCPs are applied at the organization or organizational unit level and restrict what any principal in that account can do — including account administrators. Permission boundaries are applied to individual IAM entities (users or roles) and set the maximum permissions that entity can have, regardless of what policies are attached.

Use SCPs for organization-wide guardrails — things that should never happen in any account. Use permission boundaries to delegate IAM management safely: an engineer can create roles and policies, but only within the boundary of what the permission boundary allows. This prevents privilege escalation through IAM without requiring central approval for every new role.

Warning: tightening policies in production

Never tighten IAM policies in production without testing in a non-production environment first. Policy changes that seem straightforward can break applications in ways that are not immediately obvious — a service that only calls a particular API weekly will not fail until the next scheduled invocation. Test with the least-privilege policy for at least a full operational cycle (typically 2–4 weeks) before applying to production, and have a rollback plan ready.

The path from broad IAM policies to least privilege is not a one-time project — it is an ongoing discipline. Maintaining a strong IAM posture over time means treating policy generation as part of the feature development process, running regular Access Analyzer reviews, and having SCPs in place that prevent the most dangerous drift from happening at all.

About the author

Written by Mahmoud Ali, founder of CoretiTech.

Get in touch →
Least Privilege in Practice: Moving from Broad IAM Policies to Scoped Permissions | CoretiTech