Skip to content

Interview question · Cloud, Container & AI Infrastructure Security

Why are cloud metadata endpoints an SSRF target, and how do modern defences work?

One link-local address hands out the machine's credentials to anything that can make a request from it. That includes a fooled agent with a fetch tool.

mediumEssentialNewPreparation tags: Amazon, Google, MicrosoftUpdated Nov 2026

TL;DR: Cloud VMs and containers reach a metadata service at a link-local address (169.254.169.254 on the major clouds) that returns instance details and, often, temporary credentials for the attached role. Any SSRF on that machine can request them. Modern defences require session tokens obtained with a PUT request and limit hop counts (AWS IMDSv2), or mandatory headers that browsers and naive fetchers do not send (GCP and Azure), so simple GET-based SSRF fails. Defence in depth: enforce IMDSv2, set hop limit 1 for containers that do not need metadata, block metadata from application network paths, and give workloads least-privilege roles so stolen credentials are worth little.

How to approach it

Explain what the metadata service provides and why it is reachable from any process on the host. Then describe how token and header requirements block typical SSRF, where they still fail, and the layered controls.

A strong answer

FIG · METADATA ENDPOINT · SSRF TO CLOUD CREDENTIALS
Session tokens and hop limits stop simple forwarded requests

Legacy metadata (v1-style)

SSRF to 169.254.169.254

simple GET

Role credentials returned

temporary but powerful

Cloud account access

Outcome, unsafe: Credentials stolen

Any SSRF is enough

Token-required metadata

PUT for session token

custom header

Hop limit 1

containers cannot relay

Least-privilege role too

Outcome, safe: Simple SSRF fails

Block metadata from apps that don't need it

Why it is a target. Instances get credentials without storing secrets by asking the local metadata service. That convenience means any code that can make an HTTP request from the instance, including an SSRF in a web application, a vulnerable dependency, or an agent's fetch tool steered by injected text, can obtain the role's credentials and use them from anywhere until they expire.

How modern defences work.

Cloud mechanismWhat it blocks
AWS IMDSv2: session token from a PUT with a TTL header, presented on each requestSSRF that can only make GET requests or cannot set custom headers
IMDSv2 hop limit (TTL on responses)Requests forwarded from containers or through extra network hops, when set to 1
GCP: required Metadata-Flavor: Google headerFetchers that do not let attackers set headers
Azure: required Metadata: true header, rejects requests with X-Forwarded-ForSimple proxies and fetchers

Where they still fail. An SSRF that lets the attacker choose method and headers, or code execution on the host, defeats them. They raise the bar; they do not remove the credential.

Layered controls.

  1. Enforce IMDSv2 (disable v1) across accounts with organisation policy.
  2. Set the hop limit to 1 where containers do not need instance credentials; give pods their own workload identity instead.
  3. Block the metadata address from application egress paths, especially for fetch tools and sandboxes.
  4. Apply SSRF defences in code: resolve and reject link-local and private addresses.
  5. Least-privilege instance and workload roles, so the credential reaches little.
  6. Detect use of instance credentials from outside the instance's expected network or from unusual API patterns.

Agents. A browsing or fetch tool on a cloud host is a ready-made SSRF. Run it in an isolated network segment with no metadata access, behind an egress proxy that rejects non-public addresses.

What interviewers probe next

  • "Why do containers complicate this?" Containers on a node can often reach the node's metadata service and inherit the node's role unless hop limits or network policy block it.
  • "How would you detect stolen instance credentials?" Alerts when credentials issued to an instance are used from IP addresses outside your environment, which cloud threat-detection services support.
  • "Is IMDSv2 enough for an SSRF in a feature that lets users set headers?" No; block the address at the network layer too.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

A web app on a cloud VM has a server-side request forgery bug, and the instance has a role with access to production storage buckets.

  1. Start here

    Why is the metadata service the main target?

How it's scored

Weak: Knows the address but not the defences.

Hire: Explains credential theft via SSRF and IMDSv2 tokens and hop limits.

Strong Hire: Covers other clouds' header requirements, their limits, container inheritance, least-privilege roles, detection, and agent fetch tools.

Common mistakes

  • Leaving IMDSv1 enabled for compatibility.
  • Giving node roles broad permissions that pods inherit.
  • Relying on application-level URL filters alone.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 10, and we keep track of how far you get in every topic.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in doubles your free answers, from 5 to 10 per topic, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.