Deep Dive into AWS IMDSv2 Architecture and Exploitation
Why session-oriented metadata requests prevent SSRF and how to enforce it at scale. Cloud infrastructure security is not just about protecting public endpoints. Some of the most sensitive information is available through internal services that applications use every day. One important example is the Amazon EC2 Instance Metadata Service (IMDS). It provides running EC2 instances with information…
AWS introduced Instance Metadata Service Version 2 (IMDSv2) to enhance security by requiring session-oriented authentication and additional network protections for EC2 instances. IMDSv2 introduces a two-stage authentication process where a temporary session token must be obtained before metadata requests can be made. This design aims to prevent Server-Side Request Forgery (SSRF) attacks that target internal metadata endpoints.
When an application contains an SSRF vulnerability, attackers may attempt to exploit it to access sensitive information and potentially gain access to AWS resources. To reproduce IMDSv2 requests, use the AWS CLI or cURL commands to first obtain a session token via a PUT request to the token endpoint, and then include that token in subsequent GET requests to retrieve metadata.
Enforcing IMDSv2 settings can be achieved through Infrastructure as Code tools like Terraform, which allow configuring instances to require IMDSv2 during launch. However, IMDSv2 is not a silver bullet against SSRF. To fully protect against SSRF exploitation, application-level protections, restricted IAM permissions, and network controls should be implemented.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to