liveBook · Manning

IMDSv2

As explained in Secure APIs

IMDSv2 is version 2 of the Amazon EC2 Instance Metadata Service protocol, which requires a session token for metadata requests.

IMDSv2 is the second version of Amazon EC2’s Instance Metadata Service protocol. It requires a temporary session token with metadata requests, preventing access through a single GET request. section 5.2

This requirement matters because server-side request forgery (SSRF) can trick a misconfigured service or WAF into relaying requests to internal endpoints. An exposed metadata service can disclose AWS access keys and enable serious cloud-account compromise. section 5.2

Metadata access through SSRF

A threat actor exploited a WAF misconfiguration to relay a request to an EC2 metadata endpoint during the Capital One breach, retrieving AWS access keys. Requiring a temporary token blocks the simple single-request pattern used by such relays. section 5.2

Use IMDSv2 alongside SSRF defenses:

  • Upgrade EC2 instances to IMDSv2 and review metadata-service configuration. section 5.2
  • Block user-controlled requests to localhost, internal networks, and sensitive metadata endpoints; use sandboxing or an outbound proxy when arbitrary URLs are required. section 5.2

How Secure APIs covers it

How deep it goes
Defines token-based protection and its SSRF rationale, but does not detail the token request or implementation sequence.
Examples
Uses the Capital One breach and a figure showing a WAF relaying requests to an EC2 metadata endpoint.
What you can do after
Operate/configure EC2 instances with IMDSv2 and combine it with endpoint restrictions and sandboxed outbound requests.
How it connects
Connects SSRF, EC2 metadata service, WAF misconfiguration, and AWS access keys.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.