What is IMDSv2 and why should it be enforced?
IntermediateConceptCloud Security, CIS and Compliance
Answer
The EC2 instance metadata service at 169.254.169.254 hands out the instance role's temporary credentials. IMDSv1 answers any GET, so an SSRF bug turns into credential theft (the Capital One breach pattern). IMDSv2 requires a session token obtained with a PUT and a custom header, which most SSRF vectors cannot send, and the hop limit stops the token leaving the host.
aws ec2 modify-instance-metadata-options --instance-id i-0abc \
--http-tokens required --http-put-response-hop-limit 1
On EKS nodes, hop limit 1 also blocks pods from reaching node credentials, which is what we want when pods use IRSA or Pod Identity. Enforce with an SCP or the account-level IMDS default setting.
More on Cloud Security, CIS and Compliance
What is the cloud shared responsibility model?BeginnerWhat is CSPM?BeginnerWhat are CIS Benchmarks, and what is Level 1 vs Level 2?BeginnerHow do you run a CIS assessment of an AWS account with Prowler?IntermediateName the main AWS security services and what each does.BeginnerWhat should you know about CloudTrail configuration?Intermediate