Join our Newsletter — 33% off our NHI Course
Home› Guides› Cloud Machine Image Name Confusion Attacks: Owner Filters,…
Guide Cloud Security

Cloud Machine Image Name Confusion Attacks: Owner Filters, Allow-Lists and Detection

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 15 min read
On this page

When automation picks a virtual machine image by searching for a name and taking the newest match, anyone who can publish a public image with a matching name can decide what your servers boot. This class of weakness, called a cloud image name confusion attack, was described for Amazon Machine Images (AMIs) as "whoAMI" by Datadog Security Labs in February 2025, and the same lookup pattern exists wherever images are found by name, family or filter. This guide explains how the lookup goes wrong, where it hides in infrastructure as code and scripts, and the owner filters, allow-lists and detection checks that close it on each major cloud. It is written for cloud and DevOps engineers and the owners of Terraform, Pulumi, CloudFormation and build pipelines. Clouds are listed alphabetically (Amazon Web Services, Google Cloud, Microsoft Azure); order is not a ranking.

Key takeaways

  • The bug is in the lookup, not the cloud. A search by image name with "most recent" selection and no owner constraint can return an image published by a stranger; the instance then runs that stranger's code with your instance role.
  • Always pin the publisher. On AWS set owners or an owner-id filter, on Google Cloud always name the image project, and on Azure reference images by publisher, offer and SKU or by a gallery image ID you control.
  • Add a platform guardrail behind the code fix. EC2 Allowed AMIs, the Google Cloud compute.trustedImageProjects organisation policy and Azure Policy image rules block untrusted images even when a template is wrong.
  • Start in audit mode. Allowed AMIs has an audit-mode state and an AWS Config rule that flags instances already running from images outside the criteria, so you can measure before you enforce.
  • A golden image pipeline removes most of the risk. When workloads launch only from images your own account built, signed off and published, public name lookups disappear from production code.

What image name confusion is

Every major cloud offers public or community image catalogues so customers can launch an operating system without building it. Images carry a human-readable name and a stable, unique identifier (an AMI ID, an image self-link, a gallery image resource ID). Names are not unique across publishers: two accounts can publish images with the same or similar names. Image name confusion happens when a tool resolves a name pattern to an identifier without restricting who published the image, and then chooses one result, usually the newest.

The weakness is closely related to dependency confusion in package registries, where a build pulls a public package that shadows an internal one. See the Malicious Package and Dependency Confusion Guide. The image form is worse: the image is the whole operating system and runs before any agent or endpoint control is added.

TermMeaning
Image name confusionA lookup by name or pattern returns an image from an unintended publisher
whoAMIDatadog Security Labs' name for the AWS form of the weakness, published 12 February 2025
Owner filterA lookup constraint that limits results to named publisher accounts or aliases
Image allow-listA platform setting or policy that only permits launches from approved publishers or images
Golden imageAn internally built, hardened, approved image that workloads must launch from

How the attack works

Datadog's research describes the conditions, and this guide keeps to the concept. Three things must be true at once:

  1. A name-based search: code calls an image search API (for example EC2 DescribeImages) with a name filter or regular expression such as a distribution name with a wildcard.
  2. No publisher constraint: the search does not restrict the owner, so public images from any account are candidates.
  3. Automatic selection: the code takes the most recent match, so an image published later with a matching name wins.

An attacker who guesses a commonly used name pattern publishes a public image that matches it. The next time the vulnerable code runs, it resolves to the attacker's image and launches it. The resulting instance runs with whatever instance role, network position and user data the template gives it, which is why the impact is closer to a supply chain compromise (MITRE ATT&CK T1195 Supply Chain Compromise) than to a misconfiguration. A related technique, T1525 Implant Internal Image, covers an insider-planted image in your own account, which owner filters do not stop.

According to the Datadog write-up, the research found the vulnerable pattern in multiple software projects in August 2024, reported it to AWS on 16 September 2024, and estimated that about 1% of organisations it monitors were affected. AWS released Allowed AMIs on 1 December 2024, and the HashiCorp AWS provider added a warning for unsafe lookups in version 5.77.

Where it shows up (IaC, scripts, marketplaces)

  • Terraform: the aws_ami data source with most_recent = true and name or name_regex filters but no owners. Since AWS provider 6.0.0 (18 June 2025) this is an error unless owners, an owner-id filter or an image-id filter is set, or the operator explicitly sets allow_unsafe_filter = true, which the provider documentation advises against. Modules pinned to provider 5.x still only warn.
  • SDK and CLI scripts: Bash, Python, Go, Java and Pulumi code calling describe-images then sorting by creation date. Datadog lists all of these, plus the AWS Labs aws-simple-ec2-cli tool, fixed in v0.11.0.
  • Build pipelines: image builders (Packer templates, EC2 Image Builder recipes, CI jobs) that find a base image by name before hardening it. A confused base flows into every golden image built from it, so this is the highest-value place to check.
  • Community catalogues: Azure community galleries let any subscription owner publish images publicly. Microsoft states that it does not verify or test community images or publisher information and that community images are not scanned for malware; the deploying customer is responsible for the image.
  • Marketplace listings: commercial listings are a separate channel with publisher onboarding. They still need a publisher constraint, because a typo or a look-alike publisher name resolves to a different product. See the Cloud Marketplace Purchasing Security guide.

Safe and unsafe lookups

The difference is usually one line. This unsafe Terraform pattern searches all public AMIs by name and takes the newest:

1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.

Sample 1
data "aws_ami" "base" {
  most_recent = true
  filter {
    name   = "name"
    values = ["ubuntu-*-24.04-amd64-server-*"]
  }
  # no owners: any publisher's image can match
}

The safe version names the publisher account (here, the account the distribution publishes from, which you should confirm in the distribution's own documentation) or uses an AWS-maintained parameter:

Sample 1
data "aws_ami" "base" {
  most_recent = true
  owners      = ["123456789012"]   # the publisher's account ID, or "self" for your own images
  filter {
    name   = "name"
    values = ["golden-ubuntu-24.04-*"]
  }
}

# Or resolve an AWS-published AMI through a public SSM parameter:
# image_id = "resolve:ssm:/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64"

On Google Cloud the google_compute_image data source takes family with a project; if project is omitted the provider project is used, so always set it explicitly to the image project you intend (for example a distribution's public image project, or your own image project). On Azure, reference a Marketplace image with publisher, offer and sku, and a gallery image by its full resource id, sharedGalleryImageId or communityGalleryImageId, copied from the gallery rather than built from a display name.

Preventing it with owner filters and allow-lists

Fix the code first, then add a platform control so a future template mistake fails closed. The table lists each cloud's own controls; the sections after it give the settings.

CloudLookup constraint in codePlatform guardrailAudit before enforcing
Amazon Web Servicesowners or owner-id filter; SSM public parameters for AWS imagesEC2 Allowed AMIs, per Region, centrally through an AWS Organizations declarative policyaudit-mode state; Config rule ec2-instance-launched-with-allowed-ami
Google CloudExplicit project on every image or family referenceOrganisation policy compute.trustedImageProjects at organisation, folder or projectApply to a test folder or project first and review results
Microsoft Azurepublisher/offer/sku or a full gallery image IDAzure Policy rules on Microsoft.Compute/imagePublisher or Microsoft.Compute/imageId, assigned at management groupAssign the policy with an Audit effect before Deny

Amazon Web Services

  • Allowed AMIs criteria: up to 10 ImageCriterion blocks (OR between blocks, AND inside each), using ImageProviders (amazon, aws-marketplace, aws-backup-vault, 12-digit account IDs or none), ImageNames, MarketplaceProductCodes, creation and deprecation age conditions, and Amazon Inspector scan result conditions. AWS recommends pairing ImageNames with ImageProviders because names alone may not identify an AMI uniquely.
  • Scope: the setting is per Region and applies to public AMIs and AMIs shared with the account; AMIs the account owns are always usable. Include amazon if you run managed services such as ECS or EKS that launch AWS images.
  • Central management: an AWS Organizations declarative policy applies the setting across accounts and Regions and stops local changes. See the AWS Organizations and SCPs Guide.
  • Availability: Inspector-based scan conditions block AMIs that Inspector has not scanned, so turn those on only once Inspector coverage is in place.

Google Cloud

  • Trusted image policy: the list constraint constraints/compute.trustedImageProjects takes allowedValues or deniedValues entries of the form projects/IMAGE_PROJECT, or allValues: DENY to block all public images. It restricts which projects persistent disks, and so boot disks, can be created from.
  • What it does not restrict: Google documents that custom images in the local project and image files in Cloud Storage are outside the policy, so control who can create images in workload projects as well.
  • Families: image families point to the latest non-deprecated image in a project; Google recommends testing the newest family image before production and promoting it into a production family in your own project. See the Google Cloud Organization Policy Guide.

Microsoft Azure

  • Publisher allow-list: the Azure Policy sample "Only allow certain image publishers from the Marketplace" denies virtual machines and scale sets whose Microsoft.Compute/imagePublisher is not in an approved list.
  • Approved images: the "Approved VM images" sample denies virtual machines whose Microsoft.Compute/imageId is not in an approved list, and a further sample permits only images from a named resource group, which suits a golden image gallery.
  • Community galleries: Microsoft provides a policy rule that denies galleries whose sharing profile is set to Community, which stops your own subscriptions publishing images publicly by accident. Use the portal's Report option or the MSRC abuse form for malicious community images. See the Azure Policy and Management Groups Guide.

How to implement

  1. Inventory lookups: search repositories for aws_ami, describe-images, DescribeImages, google_compute_image, source_image_reference and imageReference, and list each one with its publisher constraint or lack of one. IaC scanners can flag these; see the Checkov and IaC Scanners Guide.
  2. Fix code: add owners or projects, or switch to IDs from your own gallery. Upgrade the Terraform AWS provider to 6.x so unsafe lookups fail at plan time, and treat any allow_unsafe_filter = true as a review finding.
  3. Turn on audit: Allowed AMIs in audit-mode in every used Region, Azure Policy with Audit effect, and the Google trusted image policy on a test folder.
  4. Review results: resolve every running instance launched from an unexpected publisher (rebuild, or approve the publisher with a recorded reason).
  5. Enforce in rings: sandbox accounts and projects, then non-production, then production, keeping a documented exception path.
  6. Roll back safely: if enforcement breaks a managed service or scaling group, return that scope to audit (Allowed AMIs audit-mode, Azure Audit effect, or remove the folder-level Google constraint), fix the criteria, and re-enforce. Note that changes to central policies need the central owner.

Detecting untrusted images in use

  • AWS: the Config rule ec2-instance-launched-with-allowed-ami (identifier EC2_INSTANCE_LAUNCHED_WITH_ALLOWED_AMI) marks running or stopped instances NON_COMPLIANT when their AMI does not meet the criteria, and works while the setting is enabled or in audit mode. describe-instance-image-metadata returns per-instance image details for the same check. In CloudTrail, look for RunInstances whose imageId belongs to an account outside your approved owner list, and for DescribeImages calls without an owner parameter followed by a launch. See the AWS CloudTrail Guide.
  • Google Cloud: query disks' sourceImage through Cloud Asset Inventory and alert on any image project outside the trusted list; review organisation policy violation logs after enforcement.
  • Microsoft Azure: query properties.storageProfile.imageReference across subscriptions with Azure Resource Graph and flag publishers outside the allow-list or any communityGalleryImageId; Azure Policy compliance results give the same view once the audit assignment is in place.
MetricTarget
Image lookups in code without a publisher constraintZero, enforced in CI
Regions and accounts with Allowed AMIs enabled, or projects and subscriptions under an image policy100% of used scopes
Running instances from non-approved publishersZero, or each with a recorded exception and expiry
Share of production instances launched from internal golden imagesRising towards 100%
Median age of golden images in useInside your patch policy window

The golden image pipeline as the long-term fix

Owner filters reduce who can supply an image; a golden image pipeline reduces it to you. Build from a pinned base image (by ID or an owner-constrained lookup), harden it, scan it, record its provenance, and publish it to an image location only the pipeline can write. Workloads then launch only from that location, which an allow-list can express exactly (your account ID and an ImageNames prefix on AWS, your image project on Google Cloud, your gallery resource group on Azure). The Server Build and Golden Image Hardening Guide covers the build, hardening, secrets and lifecycle steps in depth.

  • Protect the pipeline identity: the role that publishes golden images can plant a backdoor in every server (T1525), so give it a dedicated identity, short-lived credentials and change approval. See the Infrastructure as Code Security Guide.
  • Do not over-share: share golden images only with the accounts that need them and never publicly; the Public AMI and Snapshot Exposure guide covers the opposite risk of leaking your own images.
  • Small versus large organisations: a small team can reach most of the benefit with owner-pinned lookups plus Allowed AMIs or the equivalent policy; a large estate should centralise images in one build account or project and enforce the allow-list through organisation-level policy.

Common failure patterns

  • Owner filter only in some modules: the main module is fixed but an older module, a sandbox template or a one-off script still searches without an owner.
  • Allow-list by name alone: an Allowed AMIs criterion with ImageNames but no ImageProviders re-creates the original problem inside the guardrail.
  • Escape hatch left on: allow_unsafe_filter = true added to make a provider upgrade pass and never removed.
  • Base image confusion in the builder: production launches only golden images, but the image builder itself finds its base image by name, so a confused base is hardened and approved.
  • One Region only: Allowed AMIs enabled where the team usually works, while an unused Region accepts any public image.
  • Omitted project: a Google Cloud family lookup without project resolves in the provider project, so a family name created there is silently used.

Framework mapping

Control areaNIST SP 800-53 Rev. 5NIST CSF 2.0ATT&CK
Approved images onlyCM-7(5) Authorized Software, Allow-by-exception; CM-2 Baseline ConfigurationPR.PS-01T1195 Supply Chain Compromise
Image provenance and authenticitySR-4 Provenance, SR-11 Component Authenticity, CM-14 Signed ComponentsID.AM-08, PR.PS-02T1195.002 Compromise Software Supply Chain
Image integrity in the pipelineSI-7 Software, Firmware, and Information IntegrityPR.PS-01T1525 Implant Internal Image
Detecting launches from untrusted imagesCM-7, SI-7DE.CM-09T1578 Modify Cloud Compute Infrastructure

Practitioner checklist

  • Every image lookup in IaC, scripts and builders names a publisher account, alias, project or gallery ID.
  • Terraform AWS provider at 6.x or later, and no allow_unsafe_filter = true without a recorded exception.
  • EC2 Allowed AMIs in audit mode, then enabled, in every Region you use, managed through a declarative policy.
  • Google Cloud compute.trustedImageProjects set at organisation or folder level with an explicit project list.
  • Azure Policy publisher or image ID rules assigned at management group scope, plus the rule blocking Community gallery sharing.
  • Config rule, Asset Inventory query or Resource Graph query reporting instances from non-approved publishers, reviewed weekly.
  • Golden image pipeline with a pinned base image, a dedicated publishing identity and images shared only with named accounts.
  • IaC scanning in pull requests that fails on unconstrained image lookups.

Standards and references

Related NHI Mgmt Group resources: Server Build and Golden Image Hardening Guide · Cloud Security Guide · Amazon EC2 Security Guide · Software Supply Chain Security Guide · Container Image Security Guide

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.