Interview Prep/DevSecOps/Identity, Least Privilege & OIDC for CI

Why is IMDSv2 with a hop limit of 1 important for EKS and EC2?

BeginnerProductionIdentity, Least Privilege & OIDC for CI
Answer

IMDSv2 requires a session token obtained via PUT, which defeats most SSRF attacks that can only make GET requests. A hop limit of 1 means packets from inside containers (an extra network hop) cannot reach the metadata service, so pods cannot steal the node's IAM role.

aws ec2 modify-instance-metadata-options --instance-id i-0abc \
  --http-tokens required --http-put-response-hop-limit 1

Enforce it account-wide with the EC2 IMDS defaults setting and an SCP condition on ec2:MetadataHttpTokens.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Identity, Least Privilege & OIDC for CI