Skip to content

fix: allow inline data URLs in download validation#13376

Merged
gr2m merged 2 commits intovercel:mainfrom
fahe1em1:codex/vercel-ai-13354-data-uri-fix
Mar 19, 2026
Merged

fix: allow inline data URLs in download validation#13376
gr2m merged 2 commits intovercel:mainfrom
fahe1em1:codex/vercel-ai-13354-data-uri-fix

Conversation

@fahe1em1
Copy link
Copy Markdown
Contributor

Summary

  • allow data: URLs through validateDownloadUrl because they are inline content, not network fetches
  • keep the existing SSRF protections for http: and https: URLs unchanged
  • add tests covering both validator acceptance and download() support for inline data URLs

Testing

  • pnpm exec prettier --check packages/provider-utils/src/validate-download-url.ts packages/provider-utils/src/validate-download-url.test.ts packages/ai/src/util/download/download.test.ts
  • pnpm install --frozen-lockfile
  • Attempted package-local vitest runs, but the local workspace currently fails to resolve some internal package entries before reaching these tests under Node v24.14.0

Why This Is Small And Safe

This only changes protocol handling for data: URLs, which are already inline payloads and do not make outbound network requests. All existing hostname and private-address SSRF checks still apply to real network URLs.

Closes #13354.

@tigent tigent bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented maintenance CI, internal documentation, automations, etc labels Mar 12, 2026
@gr2m gr2m added ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. and removed ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label maintenance CI, internal documentation, automations, etc labels Mar 19, 2026
Copy link
Copy Markdown
Collaborator

@gr2m gr2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for introducing this regression. Changes look good, thanks for adding a test to prevent future regressions.

@gr2m gr2m added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Mar 19, 2026
@gr2m gr2m merged commit 0009f97 into vercel:main Mar 19, 2026
19 of 20 checks passed
vercel-ai-sdk bot pushed a commit that referenced this pull request Mar 19, 2026
## Summary
- allow `data:` URLs through `validateDownloadUrl` because they are
inline content, not network fetches
- keep the existing SSRF protections for `http:` and `https:` URLs
unchanged
- add tests covering both validator acceptance and `download()` support
for inline data URLs

## Testing
- `pnpm exec prettier --check
packages/provider-utils/src/validate-download-url.ts
packages/provider-utils/src/validate-download-url.test.ts
packages/ai/src/util/download/download.test.ts`
- `pnpm install --frozen-lockfile`
- Attempted package-local `vitest` runs, but the local workspace
currently fails to resolve some internal package entries before reaching
these tests under Node `v24.14.0`

## Why This Is Small And Safe
This only changes protocol handling for `data:` URLs, which are already
inline payloads and do not make outbound network requests. All existing
hostname and private-address SSRF checks still apply to real network
URLs.

Closes #13354.

Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
@vercel-ai-sdk vercel-ai-sdk bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Mar 19, 2026
@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

vercel-ai-sdk bot commented Mar 19, 2026

✅ Backport PR created: #13624

vercel-ai-sdk bot added a commit that referenced this pull request Apr 2, 2026
This is an automated backport of #13376 to the release-v6.0 branch. FYI
@fahe1em1

---------

Co-authored-by: fahe1em1 <131003503+fahe1em1@users.noreply.github.com>
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
vercel-ai-sdk bot added a commit that referenced this pull request Apr 2, 2026
This is an automated backport of #13376 to the release-v6.0 branch. FYI
@fahe1em1

---------

Co-authored-by: fahe1em1 <131003503+fahe1em1@users.noreply.github.com>
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hazemadelkhalel added a commit to activepieces/activepieces that referenced this pull request Apr 7, 2026
Update @ai-sdk/provider-utils to 4.0.23 which includes the fix for
inline data URL validation (vercel/ai#13376). Align generate-image.ts
with extract-structured-data.ts by passing file.data (Buffer) directly
instead of constructing data: URLs. Replace deprecated
experimental_generateImage with stable generateImage export.
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 URL validation in @ai-sdk/provider-utils@4.0.19 rejects data: URIs passed as inline images

2 participants