Your app had an SSRF bug. Could the attacker have stolen AWS credentials, and how do you prevent that?

AdvancedScenarioSecurity incidents
Answer

Situation read → With IMDSv1, an SSRF to http://169.254.169.254/latest/meta-data/iam/security-credentials/<role> returns the instance role's credentials. That's exactly how the Capital One breach happened.

What I'd do →

  1. Check if IMDSv1 was enabled on those instances, and look in CloudTrail for the role's credentials used from IPs outside your VPC (GuardDuty flags this as InstanceCredentialExfiltration).
  2. Revoke active sessions for the role if there's any doubt.
  3. Enforce IMDSv2 (session token required, which simple SSRF can't obtain) and a hop limit of 1 so containers can't reach it.
aws ec2 modify-instance-metadata-options --instance-id i-0abc \
  --http-tokens required --http-put-response-hop-limit 1
  1. Set it as the account default and in launch templates; add an SCP requiring ec2:MetadataHttpTokens = required.
  2. On EKS, give pods their own roles (IRSA or Pod Identity) and block pod access to node IMDS.
  3. Fix the SSRF itself: allowlist outbound destinations.

Why → IMDSv2 turns the most common SSRF-to-credentials path into a dead end.

Interview tip → Explain why hop limit 1 matters: it stops containers from using the node's role.

All Real-World Interview questions Roadmap: Interview readiness

More on Security incidents