liveBook · Manning

EC2 metadata service

As explained in Secure APIs

The EC2 metadata service is a locally accessible service that provides metadata and credential-related information for an Amazon EC2 instance.

The EC2 metadata service is a locally reachable endpoint that provides information about an Amazon EC2 instance, including credentials associated with its IAM roles. section 5.2

SSRF against instance credentials

The endpoint http://169.254.169.254/latest/meta-data/ can reveal IAM role information and credentials. If a server-side request forgery (SSRF) flaw lets an attacker reach it, the attacker may reuse those credentials to call AWS APIs directly. section 5.2

Reduce this exposure by:

  • Using IMDSv2, which requires a temporary token instead of allowing a single GET request. section 5.2
  • Upgrading EC2 instances to IMDSv2; it ships by default with Amazon Linux instances since March 2023. section 5.2
Figure 5.5 Capital One’s SSRF attack happened due to a misconfiguration in its WAF, which allowed the threat actor to relay a request to Capital One’s EC2 instance metadata endpoint and retrieve its AWS access keys.
figure

The figure illustrates how a WAF misconfiguration enabled SSRF to relay a request to the EC2 metadata endpoint and retrieve AWS access keys. section 5.2

How Secure APIs covers it

How deep it goes
Explains the endpoint, credential impact, historical breach, and IMDSv2 mitigation without detailing service internals.
Examples
Uses the metadata endpoint, the Capital One breach, and a figure showing retrieval of AWS access keys.
What you can do after
Operate/configure EC2 instances with IMDSv2 rather than relying on unauthenticated metadata requests.
How it connects
Connects the service to SSRF, IAM roles, AWS API calls, WAF misconfiguration, and cloud credential theft.

Also explained in

Compare how 2 books explain EC2 metadata service →

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.