whoAMI Attack Lets Hackers Gain Code Execution in AWS Accounts via AMI Name Confusion
![whoAMI Attack Lets Hackers Gain Code Execution in AWS Accounts via AMI Name Confusion whoAMI Attack Lets Hackers Gain Code Execution in AWS Accounts via AMI Name Confusion](https://www.blackhatethicalhacking.com/wp-content/uploads/2025/02/877x440-Images-for-the-News-posts-22.png)
See Also: So, you want to be a hacker?
Offensive Security, Bug Bounty Courses
How Attackers Leverage Name Confusion
By publishing an AMI with a name similar to a trusted resource, attackers can trick AWS environments into selecting their malicious AMI. If an organization’s system fetches AMIs using wildcards or improper filtering, it may unknowingly launch an EC2 instance using the attacker’s backdoored AMI.
Unlike traditional AWS account takeovers, this attack does not require breaching the victim’s account. Instead, attackers create a public AMI, name it strategically, and wait for vulnerable systems to pull and deploy it automatically.
AWS Response and Mitigation
After being alerted by DataDog, Amazon confirmed that some of its internal non-production systems were vulnerable to whoAMI attacks.
AWS released a fix on September 19, 2024, followed by a new security feature called “Allowed AMIs” in December. This feature lets customers create a whitelist of trusted AMI providers, preventing unauthorized AMI selection.
Protecting Your AWS Environment
Amazon advises all AWS users to:
- Specify AMI owners when using the
ec2:DescribeImages
API to ensure that only trusted AMIs are retrieved. - Enable the “Allowed AMIs” feature via AWS Console → EC2 → Account Attributes → Allowed AMIs to block untrusted AMIs.
- Audit and update infrastructure code (e.g., Terraform, AWS CLI, Python Boto3, Go AWS SDK) to safely retrieve AMIs.
- Check for unauthorized AMIs in use by enabling AWS Audit Mode in ‘Allowed AMIs’ and switching to Enforcement Mode to block them.
Additionally, Terraform version 5.77 (released in November 2024) now warns users when "most_recent = true"
is used without an owner filter, with stricter enforcement coming in Terraform 6.0.
For organizations concerned about existing risks, DataDog has released an AWS scanner to detect EC2 instances running untrusted AMIs, available on GitHub.
With attackers actively exploiting misconfigured AMI selection, AWS users must review their AMI retrieval processes to avoid falling victim to whoAMI attacks.
Are u a security researcher? Or a company that writes articles about Cyber Security, Offensive Security (related to information security in general) that match with our specific audience and is worth sharing? If you want to express your idea in an article contact us here for a quote: [email protected]
Source: bleepingcomputer.com