Concepts / Cloud security

Cloud security

Instance metadata & SSRF

Also called IMDS, 169.254.169.254, metadata credential theft, SSRF to metadata

Every cloud instance reads its role's short-term keys from a link-local metadata service; an app with an SSRF can be made to read them for an attacker.

The app fetches the keys for the attacker
The app fetches the keys for the attacker

The attacker cannot reach 169.254.169.254, but the app on the instance can. An app that fetches any URL it is given will fetch the role's credentials and hand them back.

The instance metadata service (IMDS) gives a cloud instance its role's short-term credentials at 169.254.169.254, an address reachable only from the instance. Server-side request forgery (SSRF) is an app fetching a URL an attacker names. Give it http://169.254.169.254/latest/meta-data/iam/security-credentials/<role> and it returns the role's key, secret and token. Fix the SSRF, block that address, and require IMDSv2, which needs a PUT for a token first. See [[cloud-least-privilege]] and [[serverless-injection]].

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab