Exploiting fine-grained AWS IAM permissions for total cloud compromise: a real world example (part 2/2)
The attacker had limited AWS IAM permissions but could create EC2 instances with a privileged role and use user data to run a reverse shell. They then accessed the instance metadata to steal the role's credentials and escalate to full account access.
medium.com
Published on medium.com
{{media:0}}
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 IAM policy allowed the user to create EC2 instances with an arbitrary IAM instance profile and to pass a privileged role, enabling privilege escalation.
Impact
An attacker with limited IAM permissions could escalate to full administrative access over the AWS account, allowing them to create backdoor users and access all resources.
What the attacker needed
Limited IAM permissions including ec2:RunInstances and…; A privileged IAM role that can be attached to EC2; Network access to the created instance (security group…
How it was found
- Identify a privileged role (danger-role) that can be attached to an EC2 instance.
- Create a user data script that launches a reverse shell to the attacker's listener.
- Launch an EC2 instance with the privileged role and the user data script, specifying a security group and subnet that allow outbound traffic.
- Once the reverse shell connects, retrieve the instance metadata to obtain the role's credentials.
- Use the stolen credentials to create a backdoor IAM user with full access.
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 services like AWS, permissions control what actions a user can perform. The attacker had some permissions but not full admin. They discovered they could create a virtual server (EC2 instance) and assign it a more powerful role. By running a script on that server, they gained access to it and then retrieved the role's temporary credentials, which gave them full control.
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.