Metadata and link-local fetches

A server that fetches a caller-influenced address can reach link-local services, including a cloud metadata endpoint the caller cannot open from their own machine.

Lesson 56 of 69 · 15 min read · practice only with authorization

Diagram

From a preview URL to an address only the server should refuse

Follow the path. One example at a time.

Step 1 of 4

Feature

A preview, an import, or a webhook asks the server to fetch a URL.

Illustration: the feature names a document
document_id = "8841"
# The caller picks a document you store.
# They do not pick an address on your network.
What changes the outcome
Caller

Chooses the address.

Server

Connects from inside the network.

Role

The job can read metadata.

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

4 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Who can reach metadata

    What fails
    The metadata service answers the machine, not the user. A fetch from the app is a fetch from the machine.
    Who is affected
    Anyone whose data that cloud role can read, and whoever pays for what the role can start.
    What you would notice
    A feature that takes a URL and a role that still includes metadata read.
    What you change
    Remove metadata permissions from the fetcher. Require the session token flow your cloud vendor documents for workloads that truly need it.
  2. Ranges to refuse

    What fails
    Loopback, private, and link-local are not “internal hostnames you hope nobody types.” They are the network location of admin surfaces.
    Who is affected
    Operators and customers who depend on those admin surfaces staying unreachable.
    What you would notice
    A fetcher with no deny step after DNS, or a deny step that only checks the text of the URL.
    What you change
    Classify every resolved address. Refuse the three ranges. Do not allow a literal address to skip the check.
  3. Names that point inward

    What fails
    A public-looking name can resolve to a private address. The check has to run on the answer, not the spelling.
    Who is affected
    The same people, because the connection still comes from the server.
    What you would notice
    Logs that show a fetch to an internal address after a normal-looking hostname.
    What you change
    Re-resolve and re-check immediately before connect. Prefer an allow-list of hosts you operate.
  4. The smaller feature

    What fails
    The safest preview does not take a URL. It takes an id for a document you already stored.
    Who is affected
    Callers who were never supposed to aim the server, and the owners of internal services.
    What you would notice
    A product requirement written as “paste any link.”
    What you change
    Change the contract to an id or a fixed set of partners. Keep the deny rules even then.

The server is in a different place than the caller

Server-side request forgery matters because the request leaves from the application, inside a network the caller cannot route to. Link-local and metadata addresses are the sharp version of that fact. Cloud instances answer questions about themselves on an address that is not the public internet. Whoever can make the instance ask is whoever the instance will answer.

A preview, a PDF renderer, a webhook “test” button, and an image importer are the usual features. They look like convenience. They are a client for every protocol and every address the server allows. Write the feature as a client with a policy, not as a pass-through.

The role is the impact

A metadata response is only as bad as the credentials it can hand out. A fetcher that runs with a role able to read secrets, start machines, or pull objects turns a curious URL into those actions. A fetcher with no cloud role can still poke internal HTTP, which is bad enough, and it cannot inherit the account.

Take the metadata permission off the preview job even if you believe the URL filter is perfect. Defense in depth here is specific: the network check and the identity check fail in different ways, and you want both. Follow your provider’s current guidance for instance credentials. Workloads that genuinely need them should use the short-lived mechanism the provider documents, not a role glued to a URL fetcher.

Check the address you will connect to

Blocking a hostname you have seen in a write-up is not a control. Attackers and accidents both use other names, decimal addresses, and DNS that changes. Resolve the name, classify every answer, and refuse loopback, private, and link-local. If any answer is refused, do not connect.

You would notice a fetcher that uses a generic HTTP client with redirects on and no address policy, and a cloud policy that still lists metadata or broad read. The finding names the feature, the ranges, and the role. It does not include a URL aimed at a real metadata service.

What you change

Prefer a document id, or a partner host from configuration. When a URL is truly required, enforce the address policy after DNS and again after every redirect. Disable protocols you do not need. Log the resolved address you refused so an operator can see the attempt without reproducing it.

Put the fetcher on a network that cannot route to management ports, and on an identity that cannot read metadata. Add a test that a name resolving to a private address is rejected. That test belongs in unit scope with an address you chose, not against production.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

A preview feature fetches a URL the caller supplies. The server can reach a link-local metadata service and the job’s role can read it. What failed?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

  1. MapServer-side request forgery: fetchers, internal targets, and allow-lists that holdHow features that fetch a URL — webhooks, previews, importers, PDF renderers — can be pointed at internal services, how testers confirm SSRF safely with a canary host, and how to build an allow-list that survives redirects and DNS tricks.
  1. 01Checking every hop of a server-side fetchAn allow-list that only looks at the first URL loses when that host redirects the server somewhere else.

Practice

  1. LabSSRF allowlist evaluatorAn image import feature fetches URLs on the server. Combine host matching, address checks, redirect checks, and pinning until nine test URLs behave.

Glossary

  1. CardServer-side request forgeryThe server is induced to fetch a URL the attacker chooses, which can reach internal services the attacker cannot see directly.