Backport: fix(security): validate redirect targets in download functions to prevent SSRF bypass#13127
Merged
vercel-ai-sdk[bot] merged 1 commit intorelease-v6.0from Mar 5, 2026
Conversation
…vent SSRF bypass (#13111) ## Background The existing `validateDownloadUrl` (added in #13085) only validates the initial URL before `fetch()`. Since `fetch()` follows HTTP redirects by default, an attacker can bypass SSRF protections by providing a safe-looking public URL that 302-redirects to internal endpoints (e.g., `http://169.254.169.254/latest/meta-data/`), enabling in-band response body exfiltration through the AI model's response. ## Summary Added `response.redirected` check with `validateDownloadUrl(response.url)` in both `downloadBlob` (`@ai-sdk/provider-utils`) and `download` (`ai`) functions to validate the final URL after following redirects, before reading the response body. ## Manual Verification - `pnpm vitest run packages/provider-utils/src/download-blob.test.ts` — 16 tests pass - `pnpm vitest run packages/provider-utils/src/validate-download-url.test.ts` — 29 tests pass - `pnpm vitest run packages/ai/src/util/download/download.test.ts -t "SSRF"` — 5 tests pass
4 tasks
gr2m
approved these changes
Mar 5, 2026
Contributor
Author
|
|
Contributor
Author
|
🚀 Published in:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an automated backport of #13111 to the release-v6.0 branch. FYI @gr2m