Skip to content
Access control Write-up Intermediate

Passing A Role To Cloudformation To Escalate Privileges

An IAM user with limited permissions could pass a role to CloudFormation that allowed the service to attach an inline policy to that user, granting full administrative access. The attacker used this to escalate their own privileges.

Yani Follow

Published on infosecwriteups.com

Least privilege is a principle of granting only necessary permissions to complete a task. But how to achieve least privilege and build securely in AWS cloud?

Yani, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The user had iam:PassRole permission on a role that CloudFormation could assume, and that role allowed updating IAM policies, so the user could indirectly grant themselves any permission.

Impact

The attacker could escalate their own privileges to full administrative access, gaining control over the AWS account.

What the attacker needed

IAM user with iam:PassRole and cloudformation:CreateStack; A role assumable by CloudFormation with IAM policy update…

The fix

Restrict iam:PassRole to only roles that cannot modify IAM policies or otherwise escalate privileges, and avoid granting CloudFormation roles broad IAM permissions.

How it was found

  1. The attacker, with iam:PassRole and cloudformation:CreateStack permissions, lists IAM roles to find one that CloudFormation can assume.
  2. The attacker finds the cloudformation-demo role, which has an inline policy allowing CloudFormation to update IAM user policies.
  3. The attacker writes a CloudFormation template that defines an inline policy granting full administrative access and attaches it to their own IAM user.
  4. The attacker runs the AWS CLI create-stack command, passing the cloudformation-demo role with the --role-arn flag.
  5. CloudFormation creates the stack and attaches the admin policy to the attacker's IAM user.
  6. The attacker verifies in the IAM console that the admin policy is attached.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

In AWS, an IAM user is an identity with permissions. Some services, like CloudFormation, can act on your behalf if you hand them a role (a set of permissions). Here, a user was allowed to hand CloudFormation a powerful role, and CloudFormation then gave the user full admin rights.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by Yani

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.