SSRF Protection for NFT Metadata Fetching
Fetch untrusted NFT metadata with scheme, destination and redirect controls, so a public token URI cannot become access to internal services.

Overview
When translating these concepts into an integration, keep the scope described by the wallet history api with the result. The examples in wallet transaction history and smart contract event logs show how the same distinction affects neighbouring data questions.
A token URI is untrusted input. A backend that fetches arbitrary URLs can expose internal network resources or consume excessive resources unless it constrains the fetch path.
Validate the destination at each step
Allow only intended schemes and destinations under a documented policy. Account for DNS resolution, private and loopback addresses, redirects and alternate address encodings. A hostname string check alone may be insufficient. Apply egress controls and avoid forwarding application credentials or cookies to metadata hosts.
Worked example: a redirect to an internal address
A seemingly public metadata URL redirects to a private service address. If validation occurs only before the first request, the fetcher may follow the redirect into the internal network. Revalidate each destination or disable redirects under the chosen policy, and enforce network-layer restrictions as an additional boundary.
Bound content handling
Set request deadlines, maximum response bytes and allowed content types. Treat returned HTML, SVG and image references as untrusted too. Test slow responses, large compressed payloads and invalid JSON. Report metadata unavailable without changing token ownership. Log safe failure reasons rather than full credential-bearing URLs.
A practical acceptance test
Use a public URL redirecting to loopback, a hostname resolving to a private address and an oversized response. The fetcher should enforce its destination and resource policies in all cases. No application credentials should follow redirects. Fetch failure must leave the NFT’s chain identity intact and produce only a safe metadata-unavailable diagnostic.
Questions about the topic
Frequently asked questions
Is a public-looking hostname sufficient protection?
No. Resolution and redirects can change the actual destination.
Should failed metadata remove the asset record?
No. Metadata delivery and chain ownership are separate concerns.
Standards & technical documentation

