bug: prevent SSRF via URL injection in provider URLs#1597
Open
akhilesharora wants to merge 1 commit intoPortkey-AI:mainfrom
Open
bug: prevent SSRF via URL injection in provider URLs#1597akhilesharora wants to merge 1 commit intoPortkey-AI:mainfrom
akhilesharora wants to merge 1 commit intoPortkey-AI:mainfrom
Conversation
A `#` in values like resourceName or vertexRegion rewrites the effective hostname when templated into a URL. resourceName=httpbin.org# ends up hitting httpbin.org with the Azure api-key header attached. `/`, `@`, `?` do the same. Touches every provider that builds a URL from user input: Azure OpenAI, Vertex AI, Bedrock, Cortex, Oracle, SageMaker, Workers AI, Fireworks AI. Plus the batch/file/realtime handlers that fetch directly instead of going through getFullURL. Adds a shared validator in src/providers/utils/urlValidation.ts with two entry points: one for hostname components, one for the final URL (rejects fragment and userinfo). Also flips to redirect: 'manual' when customHost is set so a validated host can't 302 to an internal endpoint. Tests hit the real provider configs, not local copies. Fixes Portkey-AI#1596
5472a1a to
cb7b709
Compare
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.
Description: (required)
resourceNameare concatenated directly into fetch URLs without validation. A#in the value breaks the URL - e.g.resourceName=httpbin.org#buildshttps://httpbin.org#.openai.azure.com/openai, which hitshttpbin.orginstead of Azure. Theapi-keyheader goes with it.resourceName,vertexRegion, andvertexProjectIdbefore URL constructionredirect: 'manual'whencustomHostis set so a validated host can't 302 to an internal endpointTests Run/Test cases added: (required)
#,/,@,?; accepts normal names and regionsType of Change: