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.
Diagram
From a preview URL to an address only the server should refuse
Step 1 of 4
Feature
A preview, an import, or a webhook asks the server to fetch a URL.
document_id = "8841" # The caller picks a document you store. # They do not pick an address on your network.
Chooses the address.
Connects from inside the network.
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.
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.
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.
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.
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.
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.