Skip to content

fix(ai/core): skip SSRF validation for data: URLs in downloadAssets#13188

Open
jgarrison929 wants to merge 1 commit intovercel:mainfrom
jgarrison929:fix/data-url-ssrf-false-positive
Open

fix(ai/core): skip SSRF validation for data: URLs in downloadAssets#13188
jgarrison929 wants to merge 1 commit intovercel:mainfrom
jgarrison929:fix/data-url-ssrf-false-positive

Conversation

@jgarrison929
Copy link

Problem

The SSRF protection added in @ai-sdk/provider-utils@4.0.19 rejects data: URLs during downloadAssets(), breaking inline file attachments (images, PDFs) sent as base64 data URLs.

The flow:

  1. downloadAssets() converts string data to URL objects via new URL(data)data: URLs are valid URLs
  2. The instanceof URL filter passes them through to the download pipeline
  3. validateDownloadUrl() rejects data: protocol (only allows http:/https:)
  4. Error: AI_DownloadError: URL scheme must be http or https, got data:

Fix

Add && part.data.protocol !== 'data:' to the filter in downloadAssets() so data: URLs are excluded from the download queue.

This is safe because convertToLanguageModelV4DataContent() in data-content.ts already handles data: URLs correctly — it extracts the base64 payload and media type at line 53.

Changes

  • packages/ai/src/prompt/convert-to-language-model-prompt.ts — one filter condition added
  • packages/ai/src/prompt/convert-to-language-model-prompt.test.ts — test verifying data: URLs are not downloaded and are correctly decoded

Fixes #13103

data: URLs are inline content, not remote resources, but downloadAssets()
was converting them to URL objects and sending them through the download
pipeline where validateDownloadUrl() rejects non-HTTP(S) protocols.

Filter out data: URLs before the download step. They are already handled
correctly by convertToLanguageModelV4DataContent() which extracts the
base64 payload and media type.

Adds a test verifying data: URLs are not downloaded and are correctly
decoded.

Fixes vercel#13103
@tigent tigent bot added ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. bug Something isn't working as documented labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSRF protection in provider-utils@4.0.19 rejects data: URLs in downloadAssets

1 participant