Skip to content

bug: prevent SSRF via URL injection in provider URLs#1597

Open
akhilesharora wants to merge 1 commit intoPortkey-AI:mainfrom
akhilesharora:fix/ssrf-provider-url-injection
Open

bug: prevent SSRF via URL injection in provider URLs#1597
akhilesharora wants to merge 1 commit intoPortkey-AI:mainfrom
akhilesharora:fix/ssrf-provider-url-injection

Conversation

@akhilesharora
Copy link
Copy Markdown

@akhilesharora akhilesharora commented Apr 10, 2026

Description: (required)

  • Provider URL components like resourceName are concatenated directly into fetch URLs without validation. A # in the value breaks the URL - e.g. resourceName=httpbin.org# builds https://httpbin.org#.openai.azure.com/openai, which hits httpbin.org instead of Azure. The api-key header goes with it.
  • Added allowlist regex on resourceName, vertexRegion, and vertexProjectId before URL construction
  • Added redirect: 'manual' when customHost is set so a validated host can't 302 to an internal endpoint
  • Fixes bug: SSRF via URL fragment injection in provider URL construction #1596

Tests Run/Test cases added: (required)

  • Rejects values with #, /, @, ?; accepts normal names and regions
  • Verified end-to-end: unpatched gateway connects to httpbin.org, patched returns 400
  • 23 tests, no regressions

Type of Change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

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
@akhilesharora akhilesharora force-pushed the fix/ssrf-provider-url-injection branch from 5472a1a to cb7b709 Compare April 17, 2026 07:57
@akhilesharora akhilesharora changed the title bug: prevent SSRF via URL fragment injection in provider URL construction bug: prevent SSRF via URL injection in provider URLs Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: SSRF via URL fragment injection in provider URL construction

1 participant