Skip to content

Use backend-provided NFT media type instead of a server-side HEAD request - #3647

Open
tom2drum wants to merge 2 commits into
mainfrom
issue-3210
Open

Use backend-provided NFT media type instead of a server-side HEAD request#3647
tom2drum wants to merge 2 commits into
mainfrom
issue-3210

Conversation

@tom2drum

Copy link
Copy Markdown
Collaborator

Description

Resolves #3210. Resolves #3626.

The backend now returns the classified media type for each token instance directly (image_media_type / animation_media_type, values image / video / html). This PR reads those fields instead of the frontend making its own server-side HEAD request to the NFT metadata URL to detect the type.

That HEAD request lived in the /node-api/tokens/[hash]/instances/[id]/media-type route, which was an unauthenticated SSRF vector (#3626): it fetched an attacker-controlled URL from NFT metadata with no host/protocol/redirect validation. The route is deleted entirely, closing the hole. The cheap client-side fallbacks are kept: the media_type MIME check (CDN case) and the URL-extension guess still resolve the common cases; the backend field now covers what the HEAD request used to.

Environment variables

None.

Minimum API version

Core API v12.0.0+ (ships image_media_type / animation_media_type).

Breaking or incompatible changes

None. Instances on older backends without these fields fall back to the MIME/extension checks; only URLs that need content-type detection and lack a known extension stop resolving — the same URLs that drove the removed SSRF path.

Additional information

getMediaType is now synchronous (no network call). Visual output is unchanged, so existing Playwright snapshots stand; the two tests that mocked the deleted route now set the backend fields on the instance mock.

tom2drum and others added 2 commits August 18, 2026 19:38
…uest

Resolves #3210, resolves #3626

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tom2drum tom2drum added the don't merge PR is in draft, don't merge it label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

don't merge PR is in draft, don't merge it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSRF in /node-api/tokens/[hash]/instances/[id]/media-type — server-side HEAD request to unvalidated NFT metadata URL NFT media type from backend

1 participant