Skip to content

Fix restrict url proxying to a fixed upstream host#3

Open
kochrac wants to merge 2 commits intovercel:mainfrom
kochrac:patch-1
Open

Fix restrict url proxying to a fixed upstream host#3
kochrac wants to merge 2 commits intovercel:mainfrom
kochrac:patch-1

Conversation

@kochrac
Copy link

@kochrac kochrac commented Feb 23, 2026

fixing this requires ensuring that the URL used in fetch is derived only from validated components, not directly from raw user input. That means: parse the user-provided URL, verify its scheme, hostname, (optionally) port and path against strict rules and an allow‑list, then either (a) reject the request if any constraint fails, or (b) build a canonical upstream URL string from the validated URL object instead of the original string.

For this specific code, the best fix without changing desired functionality is:

  1. Parse the URL once (const parsed = new URL(url);).
  2. Enforce:
    • parsed.protocol is http: or https: (reject others).
    • parsed.hostname matches the allow‑list (vidgen.x.ai).
    • Optionally, restrict ports to standard HTTP(S) ports or no port.
  3. Use parsed.toString() (or parsed.href) as the argument to fetch, not the original url string, so that the sink depends on the validated object.
  4. Slightly refactor so the parsed URL is available to both the validation block and the fetch call.

All required changes are confined to app/api/video-proxy/route.ts, around the existing validation at lines 13–22 and the fetch(url) at line 25.

@vercel
Copy link
Contributor

vercel bot commented Feb 23, 2026

@kochrac is attempting to deploy a commit to the Esteban Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant