AWS IMDSv2
What is AWS IMDSv2?
AWS IMDSv2The session-token-based replacement for the AWS EC2 Instance Metadata Service, designed to defeat SSRF-based credential theft of EC2 instance role tokens by requiring a PUT-issued, short-lived token on every request.
IMDSv2 is the second version of the EC2 Instance Metadata Service, introduced in 2019 in direct response to the Capital One breach and other SSRF-driven cloud credential theft attacks. Unlike IMDSv1, where any code on the instance — including a webserver tricked into making a GET to `http://169.254.169.254/latest/meta-data/iam/security-credentials/`— could read the instance role credentials, IMDSv2 requires the client to first issue a PUT to `/latest/api/token` with a TTL header, then include the returned session token on every metadata read. A reflected or server-side request forgery cannot easily issue both calls because the PUT requires a non-default HTTP method and a custom header, and the response is a short-lived token. IMDSv2 also lets administrators set the `HttpPutResponseHopLimit` to 1, blocking containers on the host from reaching the metadata service. As of 2023, new AWS resources and most launch templates default to `HttpTokens: required`; legacy AMIs and infra still permitting IMDSv1 remain a common Wiz/CSPM finding and an active path for cloud token theft.
● Examples
- 01
An EC2 launch template sets `HttpTokens: required` and `HttpPutResponseHopLimit: 1`, blocking both IMDSv1 access and container-side metadata theft.
- 02
A CSPM finding flags every EC2 instance still allowing IMDSv1 because the legacy CentOS AMI was launched before the org-wide policy.
● Frequently asked questions
What is AWS IMDSv2?
The session-token-based replacement for the AWS EC2 Instance Metadata Service, designed to defeat SSRF-based credential theft of EC2 instance role tokens by requiring a PUT-issued, short-lived token on every request. It belongs to the Cloud Security category of cybersecurity.
What does AWS IMDSv2 mean?
The session-token-based replacement for the AWS EC2 Instance Metadata Service, designed to defeat SSRF-based credential theft of EC2 instance role tokens by requiring a PUT-issued, short-lived token on every request.
How does AWS IMDSv2 work?
IMDSv2 is the second version of the EC2 Instance Metadata Service, introduced in 2019 in direct response to the Capital One breach and other SSRF-driven cloud credential theft attacks. Unlike IMDSv1, where any code on the instance — including a webserver tricked into making a GET to `http://169.254.169.254/latest/meta-data/iam/security-credentials/`— could read the instance role credentials, IMDSv2 requires the client to first issue a PUT to `/latest/api/token` with a TTL header, then include the returned session token on every metadata read. A reflected or server-side request forgery cannot easily issue both calls because the PUT requires a non-default HTTP method and a custom header, and the response is a short-lived token. IMDSv2 also lets administrators set the `HttpPutResponseHopLimit` to 1, blocking containers on the host from reaching the metadata service. As of 2023, new AWS resources and most launch templates default to `HttpTokens: required`; legacy AMIs and infra still permitting IMDSv1 remain a common Wiz/CSPM finding and an active path for cloud token theft.
How do you defend against AWS IMDSv2?
Defences for AWS IMDSv2 typically combine technical controls and operational practices, as detailed in the full definition above.
What are other names for AWS IMDSv2?
Common alternative names include: EC2 Instance Metadata Service v2, IMDSv2.
● Related terms
- cloud-security№ 092
AWS IMDSv1 Attack
Theft of EC2 instance role credentials by sending unauthenticated GET requests to the legacy IMDSv1 endpoint, typically via SSRF.
- cloud-security№ 208
Cloud Metadata SSRF
A server-side request forgery attack that abuses a vulnerable application to query a cloud provider's instance metadata service and steal temporary credentials.
- attacks№ 1120
Server-Side Request Forgery (SSRF)
A web vulnerability that allows an attacker to coerce a server into making HTTP or other network requests on their behalf, often against internal systems.
- cloud-security№ 212
Cloud Token Theft
Stealing OAuth, SAML, or signing tokens from a cloud identity service and replaying them to impersonate users or services without needing passwords.
- cloud-security№ 561
IAM Misconfiguration (cloud)
Insecure or overly permissive cloud Identity and Access Management settings that allow users, roles, or services to perform actions beyond what they actually need.
- cloud-security№ 209
Cloud Misconfiguration
A security gap caused by incorrect or insecure settings of cloud services, such as exposed storage, weak IAM policies, or open management ports.