Cloud security
Instance metadata & SSRF
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 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]].
Read next
- Least privilege (cloud IAM) A cloud access key should grant only the exact actions and resources its job needs; a wildcard grant hands over far more.
- Serverless injection A serverless function that folds untrusted input into a template or format string can be driven to reflect its own environment — where its role credentials live.
- Command injection Running your own operating-system commands by sending input a web app pastes into a shell command line.