Interview Prep/Kubernetes/Security Hardening & Compliance

Why set IMDSv2 hop limit to 1 on nodes?

IntermediateProductionSecurity Hardening & Compliance
Answer

Pods can reach the EC2 metadata service and steal the node's IAM role credentials, which often have broad rights. Requiring IMDSv2 and setting HttpPutResponseHopLimit to 1 stops containers in non-host-network Pods from fetching tokens (the extra network hop), forcing them to use IRSA/Pod Identity instead.

aws ec2 modify-instance-metadata-options --instance-id i-0abc --http-tokens required --http-put-response-hop-limit 1
All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Security Hardening & Compliance