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 →
- 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). - Revoke active sessions for the role if there's any doubt.
- 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
- Set it as the account default and in launch templates; add an SCP requiring
ec2:MetadataHttpTokens = required. - On EKS, give pods their own roles (IRSA or Pod Identity) and block pod access to node IMDS.
- 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.
More on Security incidents
An AWS access key for a production IAM user was pushed to a public GitHub repo 20 minutes ago. What do you do in the first 30 minutes?AdvancedYou find pods in your cluster running a crypto miner. What do you do?AdvancedA critical CVE is announced in a library you use. You have 200 images across 40 repos. How do you find and patch everything fast?IntermediateGuardDuty reports an EC2 instance talking to a known command-and-control IP. What do you do?AdvancedYou discover an S3 bucket with customer data has been public for three months. What now?IntermediateAn engineer left the company three weeks ago and you find their access key was used yesterday. How do you respond and fix the process?Beginner