Course contentsShow
← Security
Lesson 1935 of 3,05239. Cloud Security - Compute and ServerlessFree lesson

SSRF Attacks Against IMDS

How Server-Side Request Forgery vulnerabilities allow attackers to query IMDS from application code and steal credentials.

SSRF Attacks Against IMDS

What you'll learn: How attackers exploit Server-Side Request Forgery vulnerabilities to steal cloud credentials by making applications query the Instance Metadata Service.

The Core Threat

Server-Side Request Forgery (SSRF) is a vulnerability where an attacker tricks a web application into making HTTP requests on their behalf. When this happens on a cloud VM, it becomes catastrophic because the application can reach http://169.254.169.254 — the IMDS endpoint — and retrieve IAM credentials, SSH keys, and other sensitive data that the VM's role grants access to.

Think of it like this: You have a personal assistant (the web app) who fetches documents for you. If someone convinces your assistant to grab documents from your locked safe (IMDS) and hand them over, they've just stolen your keys.

How the Attack Works

  1. Find the vulnerable input: Attackers look for application features that fetch URLs — image processors, webhooks, PDF generators, URL preview tools
  2. Inject the IMDS URL: Instead of a legitimate URL, they provide http://169.254.169.254/latest/meta-data/iam/security-credentials/role-name
  3. Application makes the request: The server-side code, running on the VM with IMDS access, queries the metadata service
  4. Credentials leaked: The response contains temporary AWS credentials (access key, secret key, session token) that the attacker can now extract

Real-World Impact

Once attackers have these credentials, they can:

  • Access S3 buckets, databases, and other resources the role permits
  • Pivot laterally through your cloud environment
  • Exfiltrate data or deploy ransomware

Key Takeaway: SSRF vulnerabilities transform web application flaws into cloud infrastructure compromises by weaponizing legitimate IMDS access. Always validate and restrict user-supplied URLs, and enforce IMDSv2 to require authenticated requests with session tokens.