Interview Prep/DevSecOps/Kubernetes Security

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 →

  1. 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.
  2. Give pods their own roles with Pod Identity or IRSA so they do not need node credentials.
  3. Add NetworkPolicy egress deny to 169.254.169.254/32 for app namespaces.
  4. 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.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security