Skip to content
Access control Write-up Intermediate

Aws ec2 Auto Scaling Privilege Escalation

The AWS managed policy DataScientist grants autoscaling and iam:PassRole permissions, allowing a user with that policy to create an EC2 Auto Scaling group that launches an instance with a more privileged role. The attacker can then obtain a reverse shell on that instance and use the role's credentials to escalate privileges.

Edoardo Rosa Follow

Published on infosecwriteups.com

This article is about a privilege escalation abusing AWS managed policies and default configurations.

Edoardo Rosa, 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

Likely the combination of autoscaling permissions and iam:PassRole in the DataScientist managed policy allows a user to create an EC2 instance with a privileged role attached, leading to privilege escalation.

Impact

An attacker with the DataScientist policy and iam:PassRole could escalate to administrative privileges, though AWS may alert on instance credential exfiltration.

What the attacker needed

Access to a role with DataScientist policy; iam:PassRole permission; Knowledge of a privileged role name; A subnet allowing egress traffic

The fix

The report recommends following AWS security best practices: use least privilege policies, avoid overly permissive managed policies, and restrict iam:PassRole.

How it was found

  1. Create a launch configuration that uses the privileged role demo-EC2Admin and an AMI with a reverse shell user-data script.
  2. Create an Auto Scaling group with that launch configuration to start an EC2 instance.
  3. Receive a reverse shell from the EC2 instance.
  4. Use the demo-EC2Admin role from the instance to gain administrative privileges.

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 cloud computing, permissions decide what actions a user can take. This report shows that a built-in permission set (called a policy) allowed a user to start a virtual server (EC2 instance) and give it a more powerful identity. By doing so, the user could effectively become that more powerful identity and take over the account.

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.

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.