IMDSv2¶
IMDSv2 uses session-orientated requests, prohibiting access to any endpoints on the imds-mock without using a session token. A client must request a token with a maximum TTL of between one second and six hours before further requests.
It is good security practice to only support IMDSv21 when launching an EC2. Enable the --imdsv2
flag to simulate this behaviour.
Enforce Strict IMDSv2¶
Using a Session Token¶
- Request a session token by providing the
X-aws-ec2-metadata-token-ttl-seconds
header with a value between1
and21600
seconds (six hours): - Include the token in any subsequent requests by providing the
X-aws-ec2-metadata-token
header:
-
The AWS Security blog post, Add defense in depth against open firewalls, reverse proxies, and SSRF vulnerabilities with enhancements to the EC2 Instance Metadata Service, details why using IMDSv2 is important to EC2 security ↩