The EC2 Instance Metadata Service (IMDS) provides instance information and, when an instance profile is attached, temporary credentials for the associated role. Applications use these credentials to call AWS APIs without storing long-lived access keys on the host. If an attacker can make a vulnerable application send a request to the metadata endpoint, or can access metadata from an overly permissive workload, the resulting credentials may provide a path to cloud resources.
Instance Metadata Service Version 2 (IMDSv2) adds a session-oriented request flow that requires a token obtained through a PUT request and supplied in subsequent metadata requests. Requiring IMDSv2 can reduce some classes of metadata exposure, but it should be paired with least-privilege instance roles, application SSRF defenses, and network controls. A token requirement is not a reason to allow a server-side fetcher to access the metadata address.
Configure new instances, launch templates, and Auto Scaling groups to require tokens. AWS exposes instance metadata options through launch and modification APIs, and account-level defaults may affect new launches. Check the effective options on actual instances; a template change does not automatically update every existing instance. During migration, inventory workloads that still make IMDSv1 requests and upgrade SDKs or agents before enforcement.
Use the provider's metrics and transition tooling to identify remaining IMDSv1 use. Roll out in stages: measure current calls, update supported software, enable token requirements in a test environment, and then enforce across production groups. Include replacement instances and scale-out paths in the review so that a hardened manually launched host is not undermined by an older Auto Scaling configuration.
IMDSv2 controls how a workload requests metadata; IAM controls what the retrieved credentials can do. Assign an instance role only the permissions needed for the host's workload. Avoid attaching broad administrative policies or a shared role that spans unrelated applications. Separate roles by environment and service, and scope resource ARNs and actions as narrowly as the service allows.
Temporary credentials still carry authority while valid. Monitor role usage and investigate unexpected API calls. Do not assume that short-lived credentials are harmless if an attacker can repeatedly retrieve them. Remove unused instance profiles, restrict who can attach or replace them, and use workload identity systems where they provide a better isolation boundary for containers or pods.
Applications that fetch user-supplied URLs should apply SSRF protections before network access. Reject loopback, link-local, private, and special-use destinations as required by the feature; validate DNS answers and redirects; and use egress controls to block metadata endpoints where possible. A hostname allowlist is safer than a general-purpose proxy if product requirements permit it. IMDSv2 token use is one layer, not a complete SSRF mitigation.
For containers, consider metadata hop-limit settings and the network architecture. AWS documentation notes that response hop limits affect whether containers can reach IMDS in common setups; changing them can affect compatibility. Test the actual runtime and CNI rather than applying a value without validating the workload. Where containers should not access instance credentials, block that route and provide narrowly scoped workload credentials instead.
Track which instances allow IMDSv1, which roles are attached, and which workloads request metadata. Use available metrics such as ImdsV1Enabled and metadata access telemetry to find old configurations and calls. Alert when a new instance launches with tokens optional, an instance profile changes unexpectedly, or role usage departs from the workload's baseline.
Review cloud audit events for role changes and related infrastructure updates. Keep a mapping from instance and role to service owner so a response team can quickly identify the affected application. If a credential is suspected to be exposed, contain the workload, assess the role's recent API activity, revoke or replace credentials through the appropriate AWS process, and investigate the original access path.
Test both supported and prohibited behavior. A maintained AWS SDK should obtain credentials through the expected provider chain when IMDSv2 is required. A request that omits the IMDSv2 token should fail. A workload that is not authorized for metadata should not reach it through the container or host network. Confirm that provisioning tools preserve the required setting on replacement and scale-out instances.
Check compatibility with monitoring agents, bootstrap scripts, and third-party software before fleet-wide enforcement. If a workload cannot use IMDSv2, treat it as an exception with an owner, a specific dependency, compensating controls, and a retirement date. Do not make a permanent broad exception just to keep an old image working.
Inventory instances and profiles; require IMDSv2 for new launches; measure and remove remaining IMDSv1 calls; limit role permissions; block metadata access from workloads that do not need it; harden user-controlled outbound requests; validate container hop behavior; monitor metadata and role changes; and test replacement-instance configuration. Review the design after changes to network layout, container runtime, or credential delivery.
IMDSv2 improves the metadata request boundary, but strong protection comes from multiple controls. If an application can be tricked into reaching metadata, or the instance role can modify unrelated infrastructure, a single protocol change will not contain the incident. Combine token enforcement with careful egress design, least privilege, and operational monitoring.