Pods can call the cloud metadata endpoint and grab the node's IAM role credentials. How do you block that?
IntermediateScenarioKubernetes Security
Answer
Situation read → If pods can reach 169.254.169.254, they can act with the node role. That is an SSRF and privilege escalation path.
What I'd do →
- Enforce IMDSv2 with hop limit 1 on nodes:
aws ec2 modify-instance-metadata-options --instance-id i-... --http-tokens required --http-put-response-hop-limit 1, and set it in the launch template. - Give pods their own roles with Pod Identity or IRSA so they do not need node credentials.
- Add NetworkPolicy egress deny to
169.254.169.254/32for app namespaces. - Keep the node role minimal.
Why → Hop limit 1 stops containers that are not using host networking from getting IMDSv2 tokens.
Interview tip → Link this to SSRF; the Capital One breach is the reference everyone knows.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate