SSRF, the EC2 metadata service and stolen IAM role credentials: an AWS incident response playbook for revoking sessions, isolating the instance and hardening security groups, so the next request gets a polite no.
Every EC2 instance with an IAM role has a little service sitting at 169.254.169.254 . Ask it for credentials and it gives you some. That's its job. It's the reason your app doesn't need access keys in a config file.
The catch is who's allowed to ask. On an instance still running IMDSv1, the answer is anyone who can get the box to make an HTTP GET. It's the colleague who reads out the office door code to anyone who rings and says "it's me".
How the attacker got the keys
The instance ran a web app with a "fetch this URL for me" feature. Link previews, import from URL, that sort of thing. Nobody had thought much about which URLs it would fetch.
Photo by Jefferson Santos on Unsplash
That's SSRF, server-side request forgery.…